A full-stack phonebook application built with Node.js, Express, and MongoDB for backend, and a React-based frontend.
You can find a hosted version of the application here: https://phonebook-backend-part-3.fly.dev/
Make sure you have the following installed:
-
Clone the repository:
git clone https://github.com/your-username/phonebook.git cd phonebook -
Install dependencies:
cd frontend/ npm install cd ../backend/ npm install
-
Set up environment variables: Create a
.envfile in the /backend directory and add:MONGO_URI=your_mongodb_connection_string PORT=3001
-
Start the development server:
npm run dev
The server will start on
http://localhost:3001/.
To run the application in a production environment:
npm startThe frontend UI is built separately and needs to be bundled before deployment.
To build the UI from Part 2 of the project:
cd /frontend
npm run build:uiThe app is deployed using Fly.io in the backend dicrectory.
-
Deploy to Fly.io:
npm run deploy
-
Full deployment including UI build:
npm run deploy:full
-
View production logs:
npm run logs:prod
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/persons |
Get all contacts |
| GET | /api/persons/:id |
Get contact by ID |
| POST | /api/persons |
Add a new contact |
| DELETE | /api/persons/:id |
Delete a contact |
- The
deploy:fullcommand builds the UI and deploys both frontend and backend.