Skip to content
oiibarPublic

About

A full-stack workout tracking platform featuring exercise logging, workout history, notes, activity statistics, and role-based administration. Includes secure session-based authentication, user data isolation, and audit logging. Built with React, Node.js, Express, and MongoDB.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FitTrack

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.

Workouts dashboard

Table of Contents

Features

  • 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 user role can only access their own workouts. Users with the admin role 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 logs collection.
  • Workout statistics and search. API endpoints return per-type aggregates and filter workouts by title or type.
  • Contact form. Messages are persisted to MongoDB.

Technology Stack

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)

Project Structure

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

Getting Started

Prerequisites

  • Node.js 18 or later
  • MongoDB 6 or later, running locally or hosted (for example, MongoDB Atlas)

1. Clone the repository

git clone https://github.com/oiibar/FitTrack.git
cd FitTrack

2. Configure and start the server

cd server
npm install
cp .env.example .env      # then edit the values as needed
npm run dev               # or `npm start` without auto-reload

The API listens on http://localhost:5000 by default.

3. Start the client

Open a second terminal:

cd client
npm install
npm run dev

The 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.

Creating an administrator

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.

Available scripts

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

Configuration

Server (server/.env)

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

Client

Variable Description
VITE_API_URL Base URL of the API. Defaults to /api (the dev proxy). Production builds read it from client/.env.production.

API Reference

All endpoints are prefixed with /api. Endpoints marked as authenticated require a valid session cookie.

Users (/api/user)

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)

Workouts (/api/workouts)

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
}

Miscellaneous

Method Endpoint Description
POST /api/contact Submit a contact message
GET /api/info Server metadata and uptime
GET /api/health Health check

Deployment

The client and the server are deployed as separate Vercel projects.

  • Server. server/vercel.json rewrites all requests to server/api/index.js, which exports the Express app as a serverless function. Set MONGO_URI, SESSION_SECRET and NODE_ENV=production in the Vercel project settings. Add the client's URL to CLIENT_URL if it is not already listed in server/index.js.
  • Client. Build with npm run build. The production API URL is read from VITE_API_URL in client/.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.

Screenshots

Sign up Workouts
Sign up Workouts
Edit workout Contact
Edit workout Contact

About

A full-stack workout tracking platform featuring exercise logging, workout history, notes, activity statistics, and role-based administration. Includes secure session-based authentication, user data isolation, and audit logging. Built with React, Node.js, Express, and MongoDB.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages