Tech Crush Cohort 7 Backend Mini Project
This project is a beginner-friendly backend REST API designed to help users manage and track their daily habits. It allows for core CRUD operations (Create, Read, Update, Delete) and includes a check-in feature to monitor progress.
As per the project guidelines, the following team members contributed to the repository:
- Emmanuel Shigiri Imoh (masterpiece34): Repository setup, GitHub collaboration, testing of end points.
- Alliu Emmanuel (EmmanuelAlliu): Data and Services Codebase
- Dosumu Emmanuel (Emmydos): GitHub collaboration, validation branch
- Edem Sokatsi (SokatsiEdem): README documentation.
- Egba Henry Chukwuemeka (evangelisthenryce-creator): GitHub collaboration validation branch
- Animasaun Farouk (animasaunfarouk0-prog)
- Ernest James (gavileway-dot): Route
- ENobong Umoette (enodavidpro): Reviewed pull requests and merged branches
- Runtime: Node.js
- Framework: Express.js
- Module System: ES Modules (import/export)
- Storage: Local JSON file (
data/habit.json) usingfs/promises
To get our project running locally, follow these steps:
- Clone the repository:
git clone https://github.com/Masterpiece34/habit-tracker-app-api.git
- Navigate to the project directory:
cd habit-tracker-app-api - Install dependencies:
npm install
- Start the server:
npm start
All endpoints return proper HTTP status codes and handle data in JSON format.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/habit |
Retrieve a list of all habits. |
| GET | /api/habit/:id |
Retrieve a specific habit by its unique ID. |
| POST | /api/habit |
Create a new habit. |
| PUT | /api/habit/:id |
Update an existing habit. |
| DELETE | /api/habit/:id |
Remove a habit from the tracker. |
| POST | /api/habit/:id/checkin |
Check-in a habit for a date (updates streak). |
Create a Habit (POST /api/habit):
- Request Body:
{"name": "Read Bible", "description": "Daily reading"} - Response:
201 Created-{"message": "Habit created successfully", "data": {"id": "c3d4e5f6-a1b2-4890-abcd-ef4434567890", "name": "Read Bible", "createdAt": "2026-07-01T00:00:00.000Z"}}
Get All Habits (GET /api/habit):
- Response:
200 OK[ { "id": "a1b2c3d4-e5f6-4890-abcd-ef4434567890", "name": "Drink Water" }, { "id": "a1b2c3d4-j5f6-4891-abcd-ef1234567111", "name": "Meditate" } ]
Check-in a Habit (POST /api/habit/:id/checkin):
- Request Body (Optional):
{"date": "2026-07-08"} - Response:
200 OK{ "message": "Habit checked in successfully", "data": { "id": "a1b2c3d4-e5f6-4890-abcd-ef4434567890", "name": "Drink Water", "checkIns": ["2026-07-08"], "currentStreak": 1, "longestStreak": 1 } }
- Validation: The API checks for required fields (e.g., name cannot be empty) and appropriate data types, returning a
400 Bad Requestfor invalid input(server-side error). - Data Persistence: All habits are stored in a JSON file under the
data/directory. - Timestamps: Every habit includes
createdAtandupdatedAtfields. - Check-in & Streaks: Users can mark habits as completed for the day. The bonus challenge includes streak calculation based on consecutive check-ins.
- Data is stored in a JSON file. It is not suitable for high-concurrency production environments.
- We did not provide any frontend interface because this is a backend-focused project.