This is a backend application for managing workout routines, workout splits, and user authentication. It is built using Node.js, Express, MongoDB, and Zod for schema validation (not all schemas are validated yet). The application uses MinIO for blob storage to handle media files such as progress photos and exercise demonstrations.
Visit the live application at: v2.workoutmadeeasy.com
Frontend Repository: Workout Frontend
-
Clone the repository:
git clone https://github.com/RiadMefti/workout-backend.git cd workout-backend -
Install dependencies:
bun install
Create a .env file in the root directory and add the following environment variables:
PORT=8080
MONGO_DB=your_mongodb_connection_string
JWT_KEY=your_jwt_secret_key
MINIO_ACCESS_KEY=your_minio_access_key
MINIO_SECRET_KEY=your_minio_secret_key
MINIO_API_URL=your_minio_api_urlTo start the application in development mode, run:
bun run devThe server will start on the port specified in the .env file (default is 8080).
POST /auth/register- Register a new userPOST /auth/login- Login a user
GET /health- Check if the server is running
GET /workout- Get all workout splits for the userPOST /workout- Create a new workout splitPUT /workout/:id- Edit a specific workout splitDELETE /workout/:id- Delete a specific workout splitGET /workout/next-workout-index- Get the next workout index for the userPOST /workout/next-workout-index/:index- Increment the next workout index for the userGET /workout/active-split- Get the active workout split for the userPOST /workout/active-split/:splitId- Set a specific workout split as active
GET /workout-manager- Get all workout records for the userGET /workout-manager/:id- Get a specific workout record for the userPOST /workout-manager/active-workout- Create a new workout record for the user- View other users' workout history by adding them via email to your connections list.
- New Endpoints:
POST /workout-manager/connections— Add a user to your connections by email (body:{ email: string })GET /workout-manager/connections— Get your list of connectionsGET /workout-manager/connections/:email/workouts— Get all workouts for a connection (by email, only if added)
POST /storage/upload- Upload media filesGET /storage/file/:id- Retrieve media filesDELETE /storage/file/:id- Delete media files
workout-backend/
├── .env
├── .gitignore
├── bun.lockb
├── controllers/
│ ├── auth.controller.ts
│ ├── health.controller.ts
│ ├── workout-manager.controller.ts
│ └── workout-split.controller.ts
├── index.ts
├── middlewares/
│ ├── authorization.middleware.ts
│ └── error.middleware.ts
├── package.json
├── README.md
├── routes/
│ ├── auth.route.ts
│ ├── health.route.ts
│ ├── routes.ts
│ ├── workout-manager.route.ts
│ └── workout-split.route.ts
├── schemas/
│ ├── user.schema.ts
│ ├── workout-record.schema.ts
│ └── workout-split.schema.ts
├── services/
│ ├── auth.service.ts
│ ├── health.service.ts
│ ├── workout-manager.service.ts
│ └── workout-split.service.ts
├── tsconfig.json
├── types/
│ ├── user.types.ts
│ ├── workout.types.ts
│ └── response.types.ts
├── utils/
│ ├── logger.ts
│ └── helpers.ts
└── zod/
├── workout-manager.zod.ts
└── workout-split.zod.ts
- User authentication and authorization
- Workout split management
- Workout tracking and progress monitoring
- Media file storage using MinIO for:
- Progress photos
- Exercise demonstration videos
- Workout-related attachments
- Secure file upload and retrieval
- JWT-based authentication
- TypeScript support
- Zod schema validation