This repo contains two applications:
- A frontend React App
- A backend api server
These two applications will communicate through HTTP requests, and need to be run separately.
More documentation of the codebase and its architecture can be found here.
If you haven't already, make sure you have node and NVM installed.
- Install Node Version Manager (NVM)
Then follow the instructions to update your
brew install nvm
~/.bash_profile
. - Open a new terminal
- Install the latest version of Node.js, (
20.5.0
at time of writing).nvm install 20
-
Clone repo to local machine, then install dependencies for both the
frontend
andapi
applications:cd frontend npm install cd ../api npm install
-
Install an ESLint plugin for your editor, for example ESLint for VSCode
-
Install MongoDB
brew tap mongodb/brew brew install [email protected]
Note: If you see a message that says
If you need to have [email protected] first in your PATH, run:
, follow the instruction. Restart your terminal after this. -
Start MongoDB
brew services start [email protected]
We need to create two .env
files, one in the frontend and one in the api.
Create a file frontend/.env
with the following contents:
VITE_BACKEND_URL="http://localhost:3000"
Create a file api/.env
with the following contents:
MONGODB_URL="mongodb://0.0.0.0/acebook"
NODE_ENV="development"
JWT_SECRET="secret"
For an explanation of these environment variables, see the documentation.
- Start the server application (in the
api
directory) in dev mode:
; cd api
; npm run dev
- Start the front end application (in the
frontend
directory)
In a new terminal session...
; cd frontend
; npm run dev
You should now be able to open your browser and go to
http://localhost:5174/signup
to create a new user.
Then, after signing up, you should be able to log in by going to
http://localhost:5174/login
.
you must create a folder called 'uploads' that sits directly under the 'api' directory. this is where users pictures will be served from, after they've been saved in the database. (this is related to the 'multer' middleware)