This website is built with React and hosted at apt.benjaminshen.com.
This project is open-source. Forks and contributions are welcomed.
- Clone the repo. Duplicate
src/exampleEnv.json
andfunctions/exampleEnv.json
and rename the files toenv.json
in their respective folders. - Edit
app.name
andapp.address
insrc/env.json
. - Follow the instructions under Firebase.
- Follow the instructions under Gmail and GroupMe.
This section is essential for setting up the app by yourself. Firebase is used for its hosting, authentication, cloud functions, and cloud firestore.
- Create a new Firebase project. Upgrade the project to the Blaze plan to use Cloud functions.
- Work in the top-level folder of the cloned repo. Log in to your newly created project using the Firebase CLI. Run
firebase use --add
, select your project id, and name it "default". - Create a new app in the Firebase console. Make sure to set up Firebase Hosting for the app.
- Follow the instructions under Hosting.
- In the Firebase console's Settings > General, under your newly created app, copy the config object to
firebase.config
insrc/env.json
. The config object looks likeCopy the json object and convert it into a hash by replacing the keys with string literals.const firebaseConfig = { apiKey: "...", authDomain: "...", databaseURL: "...", projectId: "...", storageBucket: "...", messagingSenderId: "...", appId: "..., measurementId: "..." };
- Follow the instructions under Admin.
- Follow the instructions under Authentication.
- Run
firebase deploy
in the top-level folder to deploy all of the features. You can now view the project where it is hosted.
- If you want to host your app on a custom domain, click "Add Custom Domain" in the Hosting tab in the Firebase console and follow the instructions.
- Copy your app's url to
app.url
infunctions/env.json
.
- In the Firebase Console's Settings > Service accounts, click "Generate new private key" and copy the contents to
firebase.credentials
infunctions/env.json
. - Edit
firebase.databaseUrl
infunctions/env.json
. This should just be the same asfirebase.config.databaseURL
insrc/env.json
("https://<project-id>
.firebaseio.com").
- Set up email authentication on the Firebase console and manually add users for you and your housemates. Add their UIDs as a string list field to
app/private
in Firestore. - Pick a guest password that your guests can sign up with, and write it to
app.guestPassword
infunctions/env.json
. - Customize your email templates in the firebase console.
This section is for sending doorbell notifications via Gmail.
- Log in to your Google account, navigate to your Security tab, turn on "Less Secure Apps." If you still run into issues with the cloud function, try clearing the Captcha.
- Edit
gmail.auth.user
andgmail.auth.pass
infunctions/env.json
with your email address and password. Editgmail.sender
with the sender's display name. Editgmail.recipients
with a list of email recipients (eg. your housemates).
This section is for sending doorbell notifications in a GroupMe chat. If you don't have a GroupMe account or don't want to use GroupMe, you can skip this section.
- Go to dev.groupme.com. Log in and copy your access token to
groupme.auth_token
infunctions/env.json
. - Create a new bot in your house group chat. If you don't have a group chat, you can create a new one on the Groupme app.
- Copy the bot id to
groupme.bot_id
infunctions/env.json
.
Before starting to work on the project, make sure to run yarn install
in the top-level folder and npm install
in functions/
.
All of the frontend code is in public/
and src/
. To host the frontend locally, run yarn start
. Run yarn build
to build the distribution code (in build/
) from React.
Run yarn deploy
to build the frontend and deploy all the Firebase features. Append --only <feature>
to only deploy that feature (eg. yarn deploy --only hosting
).
All of the backend code is in functions/src/
. To host the backend locally, run npm run shell
in the functions/
folder. In src/components/base.js
, uncomment the functions emulator line. Remember to comment it before deploying!
Run npm run deploy
in the functions/
folder to deploy all of the cloud functions. To deploy a specific function, run firebase deploy --only functions:<functionName>
(eg. firebase deploy --only functions:doorbell
).