FitTrack is a full-stack workout tracking application. Authenticated users can record exercises with load, sets, repetitions and muscle group, annotate them with notes, and manage their history. Administrators have an additional dashboard for managing user roles and can view workouts across all accounts.
- Features
- Technology Stack
- Project Structure
- Getting Started
- Configuration
- API Reference
- Deployment
- Screenshots
- Session-based authentication. Sign up, log in and log out. Sessions are stored server-side in MongoDB and delivered through an HTTP-only cookie.
- Workout management. Create, view, edit and delete workouts (title, weight, sets, reps and type). Deletion is a soft delete, so records are kept for auditing.
- Workout notes. Attach any number of notes to a workout.
- Role-based access control. Users with the
userrole can only access their own workouts. Users with theadminrole can view and manage every workout and promote or demote other users. - Input validation. The server validates and normalizes every workout field. Numeric fields are stored as numbers, and the request body can never overwrite ownership or system fields.
- Activity log. Create, update and delete actions are recorded in a
logscollection. - Workout statistics and search. API endpoints return per-type aggregates and filter workouts by title or type.
- Contact form. Messages are persisted to MongoDB.
| Layer | Technologies |
|---|---|
| Client | React 18, React Router 6, Vite 5, Tailwind CSS 3, Axios, React Toastify |
| Server | Node.js, Express 4, express-session, connect-mongo, bcrypt |
| Database | MongoDB (official Node.js driver) |
| Hosting | Vercel (client and server) |
FitTrack/
├── client/ # React single-page application
│ ├── src/
│ │ ├── api/ # Axios instance
│ │ ├── components/ # UI components (Admin, Auth, Header, Modal, Workouts)
│ │ ├── context/ # Auth and workouts React contexts
│ │ ├── helpers/ # Formatting utilities
│ │ ├── hooks/ # Custom hooks
│ │ ├── pages/ # Route-level pages
│ │ └── router/ # Route definitions
│ └── vite.config.js # Dev server and API proxy
├── server/ # Express REST API
│ ├── api/ # Vercel serverless entry point
│ ├── controllers/ # Request handlers
│ ├── db/ # MongoDB connection
│ ├── middleware/ # Authentication, roles and ownership checks
│ ├── routes/ # Route definitions
│ └── index.js # Application entry point
└── previews/ # Screenshots
git clone https://github.com/oiibar/FitTrack.git
cd FitTrackcd server
npm install
cp .env.example .env # then edit the values as needed
npm run dev # or `npm start` without auto-reloadThe API listens on http://localhost:5000 by default.
Open a second terminal:
cd client
npm install
npm run devThe application is served at http://localhost:3000. During development, Vite proxies all /api requests to http://localhost:5000, so the client and server share an origin and no CORS configuration is needed.
Set ADMIN_CODE in server/.env, then enter the same value in the optional Admin Code field when you sign up. Administrators can promote other users from the admin dashboard.
| Location | Command | Description |
|---|---|---|
| server | npm start |
Start the API |
| server | npm run dev |
Start the API with nodemon auto-reload |
| client | npm run dev |
Start the Vite development server |
| client | npm run build |
Build the client for production |
| client | npm run preview |
Preview the production build |
| client | npm run lint |
Run ESLint |
| Variable | Required | Description |
|---|---|---|
MONGO_URI |
Yes | MongoDB connection string |
SESSION_SECRET |
Yes | Secret used to sign session cookies |
PORT |
No | HTTP port (default 5000) |
NODE_ENV |
No | Set to production to enable Secure and SameSite=None session cookies |
ADMIN_CODE |
No | Signup code that grants the admin role |
CLIENT_URL |
No | Additional allowed CORS origins, comma separated |
| Variable | Description |
|---|---|
VITE_API_URL |
Base URL of the API. Defaults to /api (the dev proxy). Production builds read it from client/.env.production. |
All endpoints are prefixed with /api. Endpoints marked as authenticated require a valid session cookie.
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /signup |
No | Register a user and start a session |
| POST | /login |
No | Log in and start a session |
| POST | /logout |
No | Destroy the current session |
| GET | /me |
No | Return the user for the current session |
| GET | /users |
Admin | List all users |
| POST | /users/:id/promote |
Admin | Set a user's role (user or admin) |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | / |
Yes | List workouts (all workouts for administrators) |
| POST | / |
Yes | Create a workout |
| GET | /search |
Yes | Search by title (q) and/or type (type) |
| GET | /stats |
Yes | Workout count and average weight grouped by type |
| GET | /:id |
Yes | Get a single workout |
| PUT | /:id |
Yes | Update a workout's title, weight, type, sets or reps |
| PATCH | /:id/note |
Yes | Append a note to a workout |
| DELETE | /:id |
Yes | Soft-delete a workout |
Example workout payload:
{
"title": "Bench Press",
"weight": 80,
"type": "Chest",
"sets": 4,
"reps": 10
}| Method | Endpoint | Description |
|---|---|---|
| POST | /api/contact |
Submit a contact message |
| GET | /api/info |
Server metadata and uptime |
| GET | /api/health |
Health check |
The client and the server are deployed as separate Vercel projects.
- Server.
server/vercel.jsonrewrites all requests toserver/api/index.js, which exports the Express app as a serverless function. SetMONGO_URI,SESSION_SECRETandNODE_ENV=productionin the Vercel project settings. Add the client's URL toCLIENT_URLif it is not already listed inserver/index.js. - Client. Build with
npm run build. The production API URL is read fromVITE_API_URLinclient/.env.production.
Because the client and the server run on different domains in production, session cookies are issued with Secure and SameSite=None, which requires HTTPS.
| Sign up | Workouts |
|---|---|
![]() |
![]() |
| Edit workout | Contact |
|---|---|
![]() |
![]() |



