- π Overview
- π¦ Features
- π Structure
- π» Installation
- ποΈ Usage
- π Hosting
- π License
- π Authors
This repository contains a Minimum Viable Product (MVP) for a fitness tracker web application. It allows users to set fitness goals, track progress, and share achievements. Built using React for the frontend and Node.js for the backend, with MongoDB for data storage, it targets fitness enthusiasts seeking a simple yet effective tracking solution. The application provides user authentication, goal setting, progress visualization, and social sharing capabilities.
Feature | Description | |
---|---|---|
βοΈ | Architecture | The application uses a modular architecture with React components on the frontend and a RESTful API with Node.js and Express on the backend. The data is stored in MongoDB, providing scalability and flexibility. |
π | Documentation | The repository includes a README.md file that provides a detailed overview of the MVP, its dependencies, setup instructions, and API documentation. |
π | Dependencies | The application relies on libraries such as react , react-router-dom , axios , express , mongodb , and jsonwebtoken for core functionality. All dependencies are managed using npm . |
𧩠| Modularity | The codebase is structured into reusable components and modules, promoting code reusability, maintainability, and ease of expansion. |
π§ͺ | Testing | Includes unit tests for key React components and API endpoints to ensure the reliability and robustness of the codebase. |
β‘οΈ | Performance | Optimized for performance with efficient data fetching using axios , React rendering optimization techniques, and optimized database queries. |
π | Security | Includes user authentication, password hashing, and secure communication via HTTPS to protect user data and prevent unauthorized access. |
π | Version Control | Utilizes Git for version control, allowing for easy tracking of changes and collaboration. Includes .gitignore to exclude unnecessary files. |
π | Integrations | Uses Axios for making HTTP requests to the backend API. Integration with MongoDB for persistence and data management. |
πΆ | Scalability | Designed with scalability in mind, the system utilizes a cloud-native architecture, containerization, and database indexing for better performance under increased loads. |
text src/ βββ components/ β βββ common/ β β βββ Button.jsx β β βββ Input.jsx β β βββ Modal.jsx β βββ auth/ β β βββ AuthForms.jsx β βββ goals/ β β βββ GoalForm.jsx β β βββ GoalList.jsx β βββ progress/ β βββ ProgressChart.jsx β βββ ProgressInput.jsx βββ pages/ β βββ Home.jsx β βββ Dashboard.jsx βββ hooks/ β βββ useAuth.js β βββ useApi.js βββ context/ β βββ AuthContext.js βββ services/ β βββ api.js βββ utils/ β βββ helpers.js βββ styles/ βββ global.css public/ βββ index.html βββ favicon.ico api/ βββ controllers/ β βββ mainController.js βββ models/ β βββ User.js β βββ Goal.js β βββ Progress.js βββ middlewares/ β βββ authMiddleware.js βββ config/ βββ db.js tests/ βββ api.test.js constants/ βββ apiEndpoints.js types/ βββ types.d.ts tailwind.config.js README.md .gitignore package.json .env startup.sh commands.json
-
Clone the repository: bash git clone https://github.com/coslynx/fitify-fitness-tracker.git cd fitify-fitness-tracker
-
Install dependencies: bash npm install
-
Set up the database:
- Ensure MongoDB is installed and running.
- Create a
.env
file in the root of the project based on the.env.example
file and configure theVITE_DATABASE_URL
environment variable. - The database will be automatically created when the application starts using the provided connection string, you do not need to create a database manually.
-
Configure environment variables: bash cp .env.example .env
-
Start the frontend development server: bash npm run dev
-
Start the backend API server: bash
npm run api
-
Access the application:
- Web interface: http://localhost:5173
- API endpoint: http://localhost:5173/api
Tip
- The API base URL is configured in the
.env
file using theVITE_API_BASE_URL
variable. - The JWT secret is configured using
VITE_JWT_SECRET
. - The MongoDB connection URL is configured using
VITE_DATABASE_URL
.
Provide specific examples relevant to the MVP's core features. For instance:
-
π User Registration: bash curl -X POST http://localhost:5173/api/auth/signup
-H "Content-Type: application/json"
-d '{"username": "newuser", "email": "user@example.com", "password": "securepass123"}' -
π Login: bash curl -X POST http://localhost:5173/api/auth/login
-H "Content-Type: application/json"
-d '{"email": "user@example.com", "password": "securepass123"}' -
π Creating a Goal: bash curl -X POST http://localhost:5173/api/goals
-H "Content-Type: application/json"
-H "Authorization: Bearer YOUR_JWT_TOKEN"
-d '{"name": "Run a marathon", "description": "Train to run a full marathon", "targetValue": 26.2, "unit": "miles", "startDate": "2024-08-01", "endDate": "2024-12-31"}' -
π Adding Progress: bash curl -X POST http://localhost:5173/api/progress
-H "Content-Type: application/json"
-H "Authorization: Bearer YOUR_JWT_TOKEN"
-d '{"goalId": "goal_id_here", "date": "2024-07-20", "value": 100}'
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 to the service.
-
Set up the following environment variables: bash VITE_API_BASE_URL=https://your-render-api-url.com VITE_DATABASE_URL=mongodb+srv://:@.mongodb.net/?retryWrites=true&w=majority VITE_JWT_SECRET=your-secret-key VITE_NODE_ENV=production
- Make sure to replace placeholder values with your actual MongoDB connection string, JWT secret, and the Render API URL.
-
In your Render service's settings:
- Set the Build Command to
npm run build
- Set the Publish directory to
dist
- Set the Node version to
18
- Set the Start Command to
npm run start
- Set the Build Command to
-
Save your settings and deploy your application.
Provide a comprehensive list of all required environment variables, their purposes, and example values:
VITE_API_BASE_URL
: Base URL for the backend API Example:https://your-api-url.com/api
VITE_DATABASE_URL
: MongoDB connection string Example:mongodb+srv://<username>:<password>@<cluster>.mongodb.net/<database>?retryWrites=true&w=majority
VITE_JWT_SECRET
: Secret key for JWT token generation Example:your-secret-key
VITE_NODE_ENV
: Environment mode (development or production) Example:production
Provide a comprehensive list of all API endpoints, their methods, required parameters, and expected responses. For example:
-
POST /api/auth/signup
- Description: Register a new user.
- Body:
{ "username": string, "email": string, "password": string }
- Response:
{ "id": string, "username": string, "email": string }
-
POST /api/auth/login
- Description: Log in an existing user.
- Body:
{ "email": string, "password": string }
- Response:
{ "token": string }
-
GET /api/users/me
- Description: Get the current user's profile.
- Headers:
Authorization: Bearer TOKEN
- Response:
{ "id": string, "username": string, "email": string }
-
POST /api/goals
- Description: Create a new fitness goal.
- Headers:
Authorization: Bearer TOKEN
- Body:
{ "name": string, "description": string, "targetValue": number, "unit": string, "startDate": string, "endDate": string }
- Response:
{ "_id": string, "userId": string, "name": string, "description": string, "targetValue": number, "unit": string, "startDate": string, "endDate": string, "createdAt": string, "updatedAt": string }
-
GET /api/goals
- Description: Get all goals for the current user.
- Headers:
Authorization: Bearer TOKEN
- Response:
[ { "_id": string, "userId": string, "name": string, "description": string, "targetValue": number, "unit": string, "startDate": string, "endDate": string, "createdAt": string, "updatedAt": string } ]
-
GET /api/goals/:goalId
- Description: Get a single goal by ID.
- Headers:
Authorization: Bearer TOKEN
- Response:
{ "_id": string, "userId": string, "name": string, "description": string, "targetValue": number, "unit": string, "startDate": string, "endDate": string, "createdAt": string, "updatedAt": string }
-
POST /api/progress
- Description: Create a new progress entry.
- Headers:
Authorization: Bearer TOKEN
- Body:
{ "goalId": string, "date": string, "value": number }
- Response:
{ "_id": string, "userId": string, "goalId": string, "date": string, "value": number, "createdAt": string, "updatedAt": string }
-
GET /api/progress/:goalId
- Description: Get all progress entries for a specific goal.
- Headers:
Authorization: Bearer TOKEN
- Response:
[ { "_id": string, "userId": string, "goalId": string, "date": string, "value": number, "createdAt": string, "updatedAt": string } ]
Explain the authentication process in detail:
-
Register a new user or log in using
/api/auth/signup
or/api/auth/login
endpoints to receive a JWT token. -
Include the token in the Authorization header for all protected routes:
Authorization: Bearer YOUR_JWT_TOKEN
-
Tokens are valid for 1 hour, a refresh token mechanism is not implemented in this MVP.
Provide comprehensive examples of API usage, including request and response bodies:
bash
curl -X POST http://localhost:5173/api/auth/signup
-H "Content-Type: application/json"
-d '{"username": "fitnessuser", "email": "user@example.com", "password": "securepass123"}'
{ "_id": "user123", "username": "fitnessuser", "email": "user@example.com" }
curl -X POST http://localhost:5173/api/auth/login
-H "Content-Type: application/json"
-d '{"email": "user@example.com", "password": "securepass123"}'
{ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }
curl -X POST http://localhost:5173/api/goals
-H "Content-Type: application/json"
-H "Authorization: Bearer YOUR_JWT_TOKEN"
-d '{"name": "Run a marathon", "description": "Train to run a full marathon", "targetValue": 26.2, "unit": "miles", "startDate": "2024-08-01", "endDate": "2024-12-31"}'
{ "_id": "goal123", "userId": "user123", "name": "Run a marathon", "description": "Train to run a full marathon", "targetValue": 26.2, "unit": "miles", "startDate": "2024-08-01T00:00:00.000Z", "endDate": "2024-12-31T00:00:00.000Z", "createdAt": "2024-07-20T00:00:00.000Z", "updatedAt": "2024-07-20T00:00:00.000Z" }
curl -X POST http://localhost:5173/api/progress
-H "Content-Type: application/json"
-H "Authorization: Bearer YOUR_JWT_TOKEN"
-d '{"goalId": "goal123", "date": "2024-07-20", "value": 100}'
{ "_id": "progress123", "userId": "user123", "goalId": "goal123", "date": "2024-07-20T00:00:00.000Z", "value": 100, "createdAt": "2024-07-20T00:00:00.000Z", "updatedAt": "2024-07-20T00:00:00.000Z" }
[Add more examples covering all major API functionalities]
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: fitify-fitness-tracker
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!