General:
- Full-stack TypeScript: We use TypeScript for both frontend and backend.
- Node.js: Server runtime.
Frontend:
- React: Frontend PWA.
- Simple-Peer: Core of video call and voice call.
- Styled-Component: CSS-in-JS library.
- Material-ui: Material Components for some general UI.
Backend
- Express: Framework for building API.
- MongoDB: Data storage, with mongoose to perform interaction.
- Socket.io: Core of real time functions e.g. text messenging, video call, voice call.
- JsonWebToken: for user authentication.
duplex/
├── client # React PWA
├── electron # Desktop version powered by electron
├── server # API and Web server
├── .eslintrc.js # eslint config
├── .gitignore # git ignore
├── .prettierignore # prettier ignore
├── .prettierrc.js # prettier config
├── package.json # Meta data of this project
└── yarn.lock # dependencies
Prettier and Eslint is used for code formatting. Formatting rules are defined in .eslintrc.js and .prettierrc.js Below is the setup precess on VSCode.
- Install Prettier extension on VSCode
- Set Prettier as default formatter(ctrl + shift + p ">format document" and choose prettier as default fomatter)
In general, CamelCase is used for filename and variable naming. Reusable constants are capitalized and in snake_case.
ExampleFileName
let exampleVariable
const EXAMPLE_CONSTANT
- clone this repository to local
git clone https://github.com/IamMrandrew/duplex.git
-
install Node.js
-
install Yarn
-
setup AWS S3 Bucket for image uploading
-
install project dependencies
cd client
yarn install
cd server
yarn install
cd electron
yarn install
- setup environment variables, create
.env
in./server
with the following config
PORT=port-for-the-app-to-listen
DB_URL=mongodb-url
JWT_TOKEN=self-define-token
NODE_ENV=production-or-development
S3_BUCKET_NAME=aws-s3-bucket-name
AES_KEY = self-define-key
To develop client PWA run
cd client
yarn start
Please read README.md for more details about frontend.
To develop the API and Web server run
cd server
yarn start
Please read README.md for more details about backend.
To develop the desktop version run
cd electron
yarn start
Please read README.md for more details about electron.
- API & Web server is deployed on Heroku. Tutorial
- MongoDB cluster is deployed on AWS via Atlas.
- Image storage is deployed on AWS S3. Tutorial
In order to deploy a Typescript MERN stack application on Heroku, we can add the following script in package.json
To determine how to start your app, Heroku first looks for a Procfile. If no Procfile exists for a Node.js app, we will attempt to start a default web process via the start script in your package.json.
"start": "node server/index.js",
"heroku-postbuild": "YARN_PRODUCTION=false yarn --cwd client install && yarn --cwd server install && yarn --cwd client build && yarn --cwd server build"