- π Overview
- π¦ Features
- π Structure
- π» Installation
- ποΈ Usage
- π Hosting
- π License
- π Authors
The Fitness Tracker App is a web application designed to help fitness enthusiasts easily track their goals. This MVP is built using React for the frontend and Node.js for the backend, utilizing MongoDB for data storage, it enables users to set fitness goals, monitor their progress, and share achievements with their friends.
Feature | Description | |
---|---|---|
π | User Authentication | Secure user authentication using JWT (JSON Web Tokens) for protected routes and user data management. |
π― | Goal Setting | Users can create and manage their fitness goals, including setting titles, descriptions, and target dates. |
π | Progress Tracking | Users can log and track their progress towards their fitness goals, with features to view progress over time. |
π± | Social Sharing | Users can share their achievements and progress with friends via social media. |
βοΈ | Architecture | The app is built with a modular architecture, separating frontend and backend functionalities for easier maintenance and scalability. |
π | Dependencies | Utilizes libraries like axios for API requests, react-router-dom for routing, mongoose for MongoDB interactions, and bcrypt for password hashing. |
π‘οΈ | Security | Implements robust security practices, including password hashing and JWT-based authentication. |
ποΈ | Database | Leverages MongoDB Atlas for cloud-based database management, ensuring scalable and reliable data storage. |
β‘οΈ | Performance | Optimizes data fetching and API calls using caching and efficient database queries. |
𧩠| Modularity | The codebase is structured in a modular way to maintain clean and reusable code and enhance maintainability. |
βββ README.md
βββ .gitignore
βββ package.json
βββ public
β βββ index.html
β βββ favicon.ico
βββ src
β βββ components
β β βββ Button.jsx
β β βββ Input.jsx
β β βββ Modal.jsx
β β βββ AuthForm.jsx
β β βββ GoalCard.jsx
β β βββ Header.jsx
β β βββ Footer.jsx
β βββ pages
β β βββ Home.jsx
β β βββ Dashboard.jsx
β β βββ Goals.jsx
β βββ hooks
β β βββ useAuth.js
β β βββ useFetch.js
β βββ context
β β βββ AuthContext.js
β βββ services
β β βββ api.js
β β βββ auth.js
β βββ utils
β β βββ helpers.js
β βββ styles
β βββ global.css
βββ api
βββ controllers
β βββ authController.js
β βββ goalController.js
βββ models
β βββ User.js
β βββ Goal.js
βββ services
β βββ authService.js
β βββ goalService.js
βββ middlewares
β βββ authMiddleware.js
βββ config
β βββ db.js
βββ routes
βββ authRoutes.js
βββ goalRoutes.js
βββ .env
βββ startup.sh
- Clone the repository:
git clone https://github.com/coslynx/fitness-tracker-app.git cd fitness-tracker-app
- Install dependencies:
npm install
- Configure environment variables:
cp .env.example .env
- Fill in the
.env
file with your MongoDB connection URI, JWT secret, and other necessary configurations.# Port for the server to listen on PORT=3001 # MongoDB connection URI MONGODB_URI=mongodb+srv://<username>:<password>@<cluster>/<database>?retryWrites=true&w=majority # Secret key for JWT token generation JWT_SECRET=thisisasecretkeyforjwt # JWT token expiration time JWT_EXPIRES_IN=1d
- Fill in the
- Start the development server:
npm run dev
- Access the application:
- Web interface: http://localhost:3000
- API endpoint: http://localhost:3001/api
Tip
- The app uses environment variables for configuration, mainly set in
.env
file. - API base URL is configured in
/src/services/api.js
file. - Default port is set to 3001 and UI is served from port 3000, make sure that ports are not conflicting with other services.
Provide specific examples relevant to the MVP's core features. For instance:
-
π User Registration:
curl -X POST http://localhost:3001/api/auth/register -H "Content-Type: application/json" -d '{"username": "newuser", "email": "user@example.com", "password": "securepass123"}'
-
π User Login:
curl -X POST http://localhost:3001/api/auth/login -H "Content-Type: application/json" -d '{"email": "user@example.com", "password": "securepass123"}'
-
π Create a Goal:
curl -X POST http://localhost:3001/api/goals -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_JWT_TOKEN" -d '{"title": "Run a Marathon", "description": "Complete a full marathon in under 4 hours.", "targetDate": "2024-12-31", "progress": 0}'
Provide detailed, step-by-step instructions for deploying to the most suitable platform for this MVP. For example:
- Create a new Web Service on Render.
- Connect your GitHub repository.
- Configure the build command:
npm install && npm run build --prefix src
- Set the start command:
node server.js
- Configure environment variables:
- Add all variables defined in
.env
file.
- Add all variables defined in
- Deploy the app.
Provide a comprehensive list of all required environment variables, their purposes, and example values:
PORT
: Port for the server to listen on. Example:3001
MONGODB_URI
: Connection string for the MongoDB database. Example:mongodb+srv://<username>:<password>@<cluster>/<database>?retryWrites=true&w=majority
JWT_SECRET
: Secret key for JWT token generation. Example:thisisasecretkeyforjwt
JWT_EXPIRES_IN
: JWT token expiration time. Example:1d
Provide a comprehensive list of all API endpoints, their methods, required parameters, and expected responses. For example:
- POST /api/auth/register
- Description: Register a new user.
- Body:
{ "username": string, "email": string, "password": string }
- Response:
{ "username": string, "email": string, "id": string, "createdAt": string, "updatedAt": string }
- POST /api/auth/login
- Description: Logs in a user and returns a JWT token
- Body:
{"email": string, "password": string}
- Response:
{ "message": string, "token": string, "user": { "username": string, "email": string, "id": string, "createdAt": string, "updatedAt": string }}
- POST /api/goals
- Description: Create a new fitness goal
- Headers:
Authorization: Bearer TOKEN
- Body:
{ "title": string, "description": string, "targetDate": date, "progress": number }
- Response:
{ "_id": string, "userId": string, "title": string, "description": string, "targetDate": date, "progress": number, "createdAt": string, "updatedAt": string }
- GET /api/goals/:goalId
- Description: Get a goal by its ID
- Headers:
Authorization: Bearer TOKEN
- Response:
{ "_id": string, "userId": string, "title": string, "description": string, "targetDate": date, "progress": number, "createdAt": string, "updatedAt": string }
- PUT /api/goals/:goalId
- Description: Updates a goal by its ID
- Headers:
Authorization: Bearer TOKEN
- Body:
{ "title": string, "description": string, "targetDate": date, "progress": number }
- Response:
{ "_id": string, "userId": string, "title": string, "description": string, "targetDate": date, "progress": number, "createdAt": string, "updatedAt": string }
- DELETE /api/goals/:goalId
- Description: Deletes a goal by its ID
- Headers:
Authorization: Bearer TOKEN
- Response:
{ "message": string }
Explain the authentication process in detail:
- Register a new user or login to receive a JWT token.
- Include the token in the
Authorization
header for all protected routes:Authorization: Bearer YOUR_JWT_TOKEN
- The token expires based on the
JWT_EXPIRES_IN
setting, which is 1 day by default.
Provide comprehensive examples of API usage, including request and response bodies:
# Register a new user
curl -X POST http://localhost:3001/api/auth/register -H "Content-Type: application/json" -d '{"username": "fitnessuser", "email": "user@example.com", "password": "securepass123"}'
# Response
{
"username": "fitnessuser",
"email": "user@example.com",
"id": "666e4a5989977f4298765d3c",
"createdAt": "2024-06-17T14:07:05.127Z",
"updatedAt": "2024-06-17T14:07:05.127Z"
}
# Login a user
curl -X POST http://localhost:3001/api/auth/login -H "Content-Type: application/json" -d '{"email": "user@example.com", "password": "securepass123"}'
# Response
{
"message": "Login successful",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NjZlND...",
"user": {
"username": "fitnessuser",
"email": "user@example.com",
"id": "666e4a5989977f4298765d3c",
"createdAt": "2024-06-17T14:07:05.127Z",
"updatedAt": "2024-06-17T14:07:05.127Z"
}
}
# Create a new goal
curl -X POST http://localhost:3001/api/goals -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_JWT_TOKEN" -d '{"title": "Run a Marathon", "description": "Complete a full marathon in under 4 hours.", "targetDate": "2024-12-31", "progress": 0}'
# Response
{
"_id": "666e4a7889977f4298765d3d",
"userId": "666e4a5989977f4298765d3c",
"title": "Run a Marathon",
"description": "Complete a full marathon in under 4 hours.",
"targetDate": "2024-12-31T00:00:00.000Z",
"progress": 0,
"createdAt": "2024-06-17T14:07:36.231Z",
"updatedAt": "2024-06-17T14:07:36.231Z"
}
Note
This Minimum Viable Product (MVP) is licensed under the GNU AGPLv3 license.
This MVP was entirely generated using artificial intelligence through CosLynx.com.
No human was directly involved in the coding process of the repository: fitness-tracker-app
For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:
- Website: CosLynx.com
- Twitter: @CosLynxAI
Create Your Custom MVP in Minutes With CosLynxAI!