- π Overview
- π¦ Features
- π Structure
- π» Installation
- ποΈ Usage
- π Hosting
- π License
- π Authors
The repository contains a Minimum Viable Product (MVP) for a Fitness Tracker application. It allows users to set fitness goals, track progress, and share achievements with friends, leveraging React for the frontend and Node.js for the backend with a MongoDB database.
Feature | Description | |
---|---|---|
π | Authentication | Secure user registration and login using JWT for session management. |
π― | Goal Setting | Users can define fitness goals, including name, description, target date, and target value. |
π | Progress Tracking | Users can track the progress of their goals, mark goals as complete or incomplete. |
π | Dashboard | Provides a user dashboard to view fitness statistics and track progress of set goals. |
βοΈ | Architecture | The codebase follows a structured architecture with distinct directories for components, pages, hooks, and contexts for better maintainability. |
π | Dependencies | Uses essential libraries like React Router, Formik, Yup, and Axios, along with Mongoose for MongoDB interactions and jsonwebtoken and bcrypt for authentication. |
𧩠| Modularity | Modular component design for easy updates and extensions with common components for buttons, inputs, and auth forms. |
π§ͺ | Testing | Includes basic unit tests for core components with React Testing Library. |
β‘οΈ | Performance | Optimized for initial MVP launch, with consideration for future performance enhancements. |
π | Security | Secure authentication with JWT tokens and password hashing using bcrypt. |
π | Integrations | Communicates with a Node.js backend using a RESTful API. |
π | Version Control | Utilizes Git for version control with GitHub. |
πΆ | Scalability | Designed to be scalable by using reusable components and scalable database. |
src
βββ components
β βββ common
β β βββ Button.jsx
β β βββ Input.jsx
β βββ auth
β β βββ AuthForms.jsx
β βββ dashboard
β β βββ DashboardStats.jsx
β βββ goals
β βββ GoalItem.jsx
βββ pages
β βββ Home.jsx
β βββ Dashboard.jsx
βββ hooks
β βββ useAuth.js
βββ contexts
β βββ AuthContext.js
βββ services
β βββ api.js
βββ utils
β βββ helpers.js
βββ styles
βββ global.css
public
βββ index.html
βββ favicon.ico
api
βββ controllers
β βββ authController.js
β βββ goalController.js
βββ models
β βββ userModel.js
β βββ goalModel.js
βββ routes
β βββ authRoutes.js
β βββ goalRoutes.js
βββ middlewares
β βββ authMiddleware.js
βββ services
βββ authService.js
βββ goalService.js
config
βββ database.js
tests
βββ components
βββ Button.test.jsx
assets
βββ images
.env
package.json
README.md
startup.sh
commands.json
Warning
- Node.js v18.17.1 or higher
- npm v9.6.7 or higher
- MongoDB v6.0 or higher
- Git
- Docker (optional for database)
- Clone the repository:
git clone https://github.com/coslynx/fit-track-social-app.git cd fit-track-social-app
- Install dependencies:
npm install
- Set up the database:
- Option 1: Using Docker
docker-compose up -d mongodb
- Option 2: Manual Setup
- Make sure you have MongoDB installed and running.
- Update the
VITE_DB_URL
in the.env
file to your MongoDB connection string.
- Option 1: Using Docker
- Configure environment variables:
cp .env.example .env # Fill in the necessary environment variables in the .env file
- Start the development server:
npm run dev
- Start the backend server:
# Using docker docker-compose up -d api # Or manually from api dir cd api npm install node server.js
- Access the application:
- Web interface: http://localhost:5173
- API endpoint: http://localhost:3001/api
Tip
- The application's configurations are managed through the
.env
file, which includes settings for the API base URL, JWT secret, and database connection. - To modify any settings, update the corresponding variables in the
.env
file and restart the application. - Make sure to use the
.env.example
as a template to create the.env
file.
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 '{"email": "user@example.com", "password": "securepass123", "name": "newuser"}'
-
π User Login:
curl -X POST http://localhost:3001/api/auth/login \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com", "password": "securepass123"}'
-
π Creating a Goal:
curl -X POST http://localhost:3001/api/goals \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{"name": "Run a Marathon", "description": "Complete a full marathon", "targetDate": "2024-12-31", "targetValue": 26.2}'
-
π Updating a Goal:
bash curl -X PUT http://localhost:3001/api/goals/YOUR_GOAL_ID \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{"completed": true}'
Provide detailed, step-by-step instructions for deploying to the most suitable platform for this MVP. For example:
- Ensure you have a VPS or cloud server running Node.js and MongoDB.
- Clone the repository onto the server:
git clone https://github.com/coslynx/fit-track-social-app.git cd fit-track-social-app
- Install dependencies for both frontend and backend
npm install cd api npm install cd ..
- Build the React frontend for production.
npm run build
- Copy the
dist
folder from theclient
directory and place it in thepublic
directory of theapi
folder. - Set up the required environment variables in the
.env
file on the server. - Start the server.
cd api node server.js
Provide a comprehensive list of all required environment variables, their purposes, and example values:
VITE_API_BASE_URL
: Base URL for the API server. Example:http://localhost:3001/api
VITE_JWT_SECRET
: Secret key for JWT token generation. Example:abcdefghijklmnopqrstuvwxyz123456
VITE_DB_URL
: MongoDB connection string. Example:mongodb://localhost:27017/fitness_tracker
VITE_PORT
: Port for the api server Example:3001
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:
{ "email": string, "password": string, "name": string }
- Response:
{ "success": boolean, "message": string, "user": { "id": string, "name": string, "email": string }, "token": string }
- POST /api/auth/login
- Description: Logs in an existing user
- Body:
{ "email": string, "password": string }
- Response:
{ "success": boolean, "message": string, "user": { "id": string, "name": string, "email": string }, "token": string }
- POST /api/auth/logout
- Description: Logs out a user
- Response:
{ "success": boolean, "message": string }
- POST /api/goals
- Description: Creates a new goal
- Headers:
Authorization: Bearer TOKEN
- Body:
{ "name": string, "description": string, "targetDate": string, "targetValue": number }
- Response:
{ "success": boolean, "message": string, "data": object }
- GET /api/goals
- Description: Get all goals for the user
- Headers:
Authorization: Bearer TOKEN
- Response:
Array of goals
- PUT /api/goals/:id
- Description: Updates a specific goal
- Headers:
Authorization: Bearer TOKEN
- Body:
{ "name": string, "description": string, "targetDate": string, "targetValue": number, "completed": boolean}
- Response:
{ "success": boolean, "message": string, "data": object }
- DELETE /api/goals/:id
- Description: Deletes a specific goal
- Headers:
Authorization: Bearer TOKEN
- Response:
{ "success": boolean, "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
- Tokens expire after 2 hours.
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 '{"email": "user@example.com", "password": "securepass123", "name": "newuser"}'
# Response
{
"success": true,
"message": "User registered successfully",
"user": {
"id": "6663e92105739a2e9127e556",
"name": "newuser",
"email": "user@example.com"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY2NjNlOTIxMDU3MzlhMmU5MTI3ZTU1NiIsImlhdCI6MTcxNzA0MTkwNCwiZXhwIjoxNzE3MDQ4OTA0fQ.qM_yWqg_0d_7r0y8_2T9Ue9c_2h_6j_8i_0Q_3v_1_c"
}
# Login an existing user
curl -X POST http://localhost:3001/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "securepass123"}'
# Response
{
"success": true,
"message": "Login successful",
"user": {
"id": "6663e92105739a2e9127e556",
"name": "newuser",
"email": "user@example.com"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY2NjNlOTIxMDU3MzlhMmU5MTI3ZTU1NiIsImlhdCI6MTcxNzA0MTk1MSwiZXhwIjoxNzE3MDQ4OTUxfQ.WdZ7uI1W017_3_Yp0g7_6_lU8R_3yT_6_2Z_zU_9_5_k"
}
# Create a new goal
curl -X POST http://localhost:3001/api/goals \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"name": "Run a Marathon", "description": "Complete a full marathon", "targetDate": "2024-12-31", "targetValue": 26.2}'
# Response
{
"success": true,
"message": "Goal created successfully",
"data": {
"userId": "6663e92105739a2e9127e556",
"name": "Run a Marathon",
"description": "Complete a full marathon",
"targetDate": "2024-12-31T00:00:00.000Z",
"targetValue": 26.2,
"completed": false,
"createdAt": "2024-06-08T15:20:13.618Z",
"updatedAt": "2024-06-08T15:20:13.618Z",
"id": "6663e93d05739a2e9127e557"
}
}
[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: fit-track-social-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!