- π Overview
- π¦ Features
- π Structure
- π» Installation
- ποΈ Usage
- π Hosting
- π License
- π Authors
The fitness-tracker-app is a web application built as a Minimum Viable Product (MVP) that enables users to track their fitness goals, monitor their progress, and share their achievements with friends. It's designed for fitness enthusiasts who seek an easy-to-use platform for managing their fitness journey. The application uses React for the frontend and Node.js for the backend, with data stored in SQLite.
| Feature | Description | |
|---|---|---|
| π | User Authentication | Secure user registration and login functionality using email and password, with JWT for authentication. |
| π― | Goal Setting | Allows users to set personalized fitness goals, including name, target, unit, and optional start and end dates. |
| π | Progress Tracking | Enables users to log their fitness progress, track values over time, and view progress through charts. |
| π | Data Visualization | Provides visual representations of user progress using charts, which enhances user understanding of their fitness journey. |
| ποΈ | Data Storage | Uses SQLite for data storage, offering a simple and lightweight solution for the MVP. |
| βοΈ | RESTful API | Provides a RESTful API for the frontend to communicate with the backend server for all data operations. |
| βοΈ | React Frontend | The UI is built using React, offering a responsive and dynamic user interface. |
| π‘οΈ | Security | Implements token-based authentication and secure password handling to protect user data and privacy. |
| π± | Responsive Design | The UI is designed to be responsive, ensuring accessibility across devices. |
| π§© | Modular Structure | Organized codebase for easy maintenance and future scalability. |
βββ README.md
βββ package.json
βββ components
β βββ Button.jsx
β βββ Input.jsx
β βββ Modal.jsx
β βββ LoginForm.jsx
β βββ SignupForm.jsx
β βββ GoalCard.jsx
β βββ GoalForm.jsx
β βββ GoalList.jsx
β βββ ProgressChart.jsx
β βββ ProgressInput.jsx
β βββ Header.jsx
β βββ Footer.jsx
βββ pages
β βββ Home.jsx
β βββ Dashboard.jsx
β βββ Goals.jsx
β βββ Profile.jsx
βββ hooks
β βββ useAuth.js
β βββ useFetch.js
βββ context
β βββ AuthContext.js
βββ services
β βββ api.js
β βββ auth.js
βββ utils
β βββ helpers.js
β βββ validators.js
βββ styles
β βββ global.css
βββ public
β βββ index.html
β βββ favicon.ico
βββ types
β βββ index.js
βββ api
β βββ index.js
βββ models
β βββ index.js
βββ controllers
β βββ index.js
βββ middlewares
β βββ authMiddleware.js
βββ config
β βββ database.js
βββ tests
β βββ components
β β βββ Button.test.js
β β βββ GoalForm.test.js
β βββ services
β βββ api.test.js
β βββ auth.test.js
βββ constants
β βββ index.js
βββ .env
βββ startup.sh
βββ commands.json
Warning
- Node.js v18+
- npm v8+
- Basic knowledge of JavaScript and React
- Familiarity with RESTful APIs
- Clone the repository:
git clone https://github.com/coslynx/fitness-tracker-app.git cd fitness-tracker-app - Install dependencies:
npm install
- Create and configure the .env file:
cp .env.example .env
- Update environment variables in
.envto match your setup. - REACT_APP_API_BASE_URL defaults to
http://localhost:8080. - JWT_SECRET needs a secure key.
- DB_* variables for database connection.
- Update environment variables in
- Start the development server:
npm start
- Access the application:
- Web interface:
http://localhost:3000 - API endpoint:
http://localhost:8080/api
- Web interface:
Tip
- Customize API base URL in the
.envfile. - Set JWT secret for secure authentication in the
.envfile. - Modify SQLite database settings in
config/database.js. - Run
npm startto launch the development server.
Provide specific examples relevant to the MVP's core features:
- π User Registration:
curl -X POST http://localhost:8080/api/signup \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com", "password": "securepass123"}'
- π User Login:
curl -X POST http://localhost:8080/api/login \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com", "password": "securepass123"}'
- π Setting a Fitness Goal:
curl -X POST http://localhost:8080/api/goals \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{"name": "Run a Marathon", "target": 42, "unit": "km", "startDate": "2024-01-01", "endDate": "2024-12-31"}' - π Logging Progress:
curl -X POST http://localhost:8080/api/progress \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{"goalId": 1, "value": 5, "date": "2024-01-15"}'
Provide detailed, step-by-step instructions for deploying to a suitable platform.
- Set up a virtual server:
- Provision a virtual machine with Node.js and npm installed.
- Clone the repository:
- Use
git cloneto download the project to the server.
- Install dependencies:
- Run
npm installto set up the required packages.
- Configure Environment Variables:
- Configure the
.envvariables in the hosting environment. - Ensure all variables are securely set including database credentials, and JWT secret.
- Configure the
- Build the React App:
npm run build
- Start the Application:
- Use a process manager like
pm2orsystemdto run the Node.js application:
npm run start
- Use a process manager like
Provide a comprehensive list of all required environment variables, their purposes, and example values:
REACT_APP_API_BASE_URL: Base URL for the API, e.g.,http://localhost:8080orhttps://api.example.comJWT_SECRET: Secret key for JWT token generation, e.g.,thisIsARandomSecretKeyForJWTWhichIsLongEnoughDB_NAME: Database name. e.g.,fitness_tracker_dbDB_HOST: Host address for the database, e.g.,localhostDB_USER: Database username e.g.,userDB_PASSWORD: Database password, e.g.,passwordDB_PORT: Port number for the database connection, e.g.,5432
Provide a comprehensive list of all API endpoints, their methods, required parameters, and expected responses:
- POST /api/login
- Description: User login and token generation.
- Body:
{"email": string, "password": string} - Response:
{"user": object, "token": string}
- POST /api/signup
- Description: User registration and token generation.
- Body:
{"email": string, "password": string} - Response:
{"user": object, "token": string}
- GET /api/goals
- Description: Fetch all goals for the authenticated user.
- Headers:
Authorization: Bearer YOUR_JWT_TOKEN - Response:
[{"id": number, "userId": number, "name": string, "description": string, "target": number, "unit": string, "startDate": date, "endDate": date}]
- POST /api/goals
- Description: Create a new fitness goal.
- Headers:
Authorization: Bearer YOUR_JWT_TOKEN - Body:
{"name": string, "description": string, "target": number, "unit": string, "startDate": date, "endDate": date} - Response:
{"id": number, "userId": number, "name": string, "description": string, "target": number, "unit": string, "startDate": date, "endDate": date}
- PUT /api/goals/:id
- Description: Update an existing goal.
- Headers:
Authorization: Bearer YOUR_JWT_TOKEN - Body:
{"name": string, "description": string, "target": number, "unit": string, "startDate": date, "endDate": date} - Response:
{"id": number, "userId": number, "name": string, "description": string, "target": number, "unit": string, "startDate": date, "endDate": date}
- DELETE /api/goals/:id
- Description: Delete a goal.
- Headers:
Authorization: Bearer YOUR_JWT_TOKEN - Response:
204 No Content
- POST /api/progress
- Description: Add progress data for a specific goal.
- Headers:
Authorization: Bearer YOUR_JWT_TOKEN - Body:
{"goalId": number, "value": number, "date": date} - Response:
{"id": number, "goalId": number, "value": number, "date": date}
All protected routes require a valid JWT token, which can be acquired during the login or signup process. Include the token in the Authorization header:
Authorization: Bearer YOUR_JWT_TOKEN
Provide examples of API usage, including request and response bodies:
# Signup user
curl -X POST http://localhost:8080/api/signup \
-H "Content-Type: application/json" \
-d '{"email": "testuser@example.com", "password": "securepassword123"}'
# Response
{
"user": {
"id": 1,
"email": "testuser@example.com"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}# Login user
curl -X POST http://localhost:8080/api/login \
-H "Content-Type: application/json" \
-d '{"email": "testuser@example.com", "password": "securepassword123"}'
# Response
{
"user": {
"id": 1,
"email": "testuser@example.com"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}# Create a new goal
curl -X POST http://localhost:8080/api/goals \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"name": "Run 5K", "target": 5, "unit": "km", "startDate": "2024-01-01", "endDate": "2024-03-31"}'
# Response
{
"id": 1,
"userId": 1,
"name": "Run 5K",
"description": null,
"target": 5,
"unit": "km",
"startDate": "2024-01-01T00:00:00.000Z",
"endDate": "2024-03-31T00:00:00.000Z"
}# Add progress to a goal
curl -X POST http://localhost:8080/api/progress \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"goalId": 1, "value": 2, "date": "2024-01-15"}'
# Response
{
"id": 1,
"goalId": 1,
"value": 2,
"date": "2024-01-15T00:00:00.000Z"
}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!