A web application that empowers users to easily track their fitness goals, monitor progress, and share achievements with friends.
- π Overview
- π¦ Features
- π Structure
- π» Installation
- ποΈ Usage
- π Hosting
- π License
- π Authors
This repository houses the Minimum Viable Product (MVP) for a Fitness Tracker web application, designed to help users set and track their fitness goals, monitor progress, and connect with friends. The application leverages a robust tech stack, including Next.js, React, TypeScript, and Node.js, for a fast, engaging, and user-friendly experience.
Feature | Description | |
---|---|---|
π | User Authentication | Users can securely register and log in using their email and password or through social logins (e.g., Google, Facebook). |
π― | Goal Setting | Users can create personalized fitness goals with specific titles, targets, and deadlines. |
π | Progress Tracking | Users can log their workouts, including type, duration, and date, to track their progress towards their goals. |
π | Progress Visualization | The application provides visual representations of progress with charts and graphs, offering insightful data. |
π€ | Social Sharing | Users can connect with friends, share their achievements, and provide support and motivation. |
βοΈ | Architecture | The codebase follows a modular architectural pattern, ensuring easier maintenance and scalability. |
π | Documentation | The repository includes a README file that provides a detailed overview of the MVP, its dependencies, and usage instructions. |
π | Dependencies | The codebase relies on various external libraries and packages such as Next.js, React, Zustand, Prisma ORM, and others, which are essential for building and styling the UI components, managing state, and handling database interactions. |
𧩠| Modularity | The modular structure allows for easier maintenance and reusability of the code, with separate directories and files for different functionalities such as background, components, and content. |
π§ͺ | Testing | Unit tests are implemented using frameworks like Jest or React Testing Library to ensure the reliability and robustness of the codebase. |
β‘οΈ | Performance | Performance optimization is implemented to improve loading times and user experience. The system can be further optimized based on factors such as the browser and hardware being used. |
π | Security | Security is a top priority, with measures like input validation, data encryption, and secure communication protocols implemented. |
π | Version Control | Utilizes Git for version control with GitHub Actions workflow files for automated build and release processes. |
π | Integrations | The application integrates with external services through HTTP requests. It also interacts with browser APIs. |
πΆ | Scalability | The system is designed to handle increased user load and data volume, utilizing caching strategies and cloud-based solutions for better scalability. |
## π Structure
```text
fitness-tracker/
βββ public
β βββ images
β β βββ logo.png
β βββ favicon.ico
β βββ robots.txt
βββ pages
β βββ api
β β βββ auth
β β β βββ [...nextauth].js
β β βββ goals
β β β βββ route.ts
β β βββ progress
β β βββ route.ts
β βββ index.js
β βββ dashboard
β β βββ page.tsx
β βββ goals
β β βββ page.tsx
β βββ profile
β βββ page.tsx
βββ components
β βββ common
β β βββ Button.tsx
β β βββ Input.tsx
β β βββ Modal.tsx
β βββ layout
β βββ Header.tsx
β βββ Footer.tsx
βββ lib
β βββ api
β β βββ client.ts
β βββ utils
β βββ formatters.ts
βββ .eslintrc.js
βββ next.config.js
βββ prisma
β βββ schema.prisma
β βββ migrations
β β βββ _Rollbacks
β β βββ 20231026123456_init.sql
β βββ migrations
β βββ 20231026123456_init
β βββ migration.sql
βββ .env
βββ tests
βββ components
β βββ common
β β βββ Button.test.tsx
β β βββ Input.test.tsx
β β βββ Modal.test.tsx
β βββ layout
β βββ Header.test.tsx
β βββ Footer.test.tsx
βββ pages
β βββ index.test.js
β βββ dashboard
β β βββ page.test.tsx
β βββ goals
β β βββ page.test.tsx
β βββ profile
β βββ page.test.tsx
βββ lib
β βββ api
β β βββ client.test.ts
β βββ utils
β βββ formatters.test.ts
βββ services
β βββ api.test.ts
β βββ auth.test.ts
βββ hooks
βββ useAuth.test.ts
```
## π» Installation
### π§ Prerequisites
- Node.js v18+
- npm 6+ or yarn
- PostgreSQL 13+
### π Setup Instructions
1. Clone the repository:
```bash
git clone https://github.com/coslynx/Fitness-Tracker.git
cd Fitness-Tracker
```
2. Install dependencies:
```bash
npm install
```
3. Set up the database:
```bash
npx prisma generate
npx prisma db push
```
4. Configure environment variables:
```bash
cp .env.example .env
[Instruct to fill in necessary environment variables, including DATABASE_URL, NEXTAUTH_URL, NEXTAUTH_SECRET, and any other required variables. For example:]
# NextAuth.js Configuration
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your_strong_secret_key
# Database Connection
DATABASE_URL=postgres://username:password@host:port/database
```
## ποΈ Usage
### πββοΈ Running the MVP
1. Start the development server:
```bash
npm run dev
```
3. Access the application:
- Web interface: [http://localhost:3000](http://localhost:3000)
- API endpoint: [http://localhost:3000/api](http://localhost:3000/api)
### βοΈ Configuration
- The primary configuration file is `next.config.js` which contains settings for Next.js, including:
- Environment variables
- Image handling
- Experimental features
- Other configuration files such as `tailwind.config.js` for styling and `prisma/schema.prisma` for database schema are also crucial for the project.
### π Examples
Provide specific examples relevant to the MVP's core features. For instance:
- π **User Registration**:
```bash
curl -X POST http://localhost:3000/api/auth/signup -H "Content-Type: application/json" -d '{"email": "user@example.com", "password": "securepass123"}'
```
- π **Setting a Fitness Goal**:
```bash
curl -X POST http://localhost:3000/api/goals -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_JWT_TOKEN" -d '{"title": "Lose 10 lbs", "target": 150, "userId": 1}'
```
- π **Logging Progress**:
```bash
curl -X POST http://localhost:3000/api/progress -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_JWT_TOKEN" -d '{"type": "Running", "date": "2023-06-15", "duration": 30, "goalId": 1, "userId": 1}'
```
## π Hosting
### π Deployment Instructions
Provide detailed, step-by-step instructions for deploying to the most suitable platform for this MVP. For example:
#### Deploying to Vercel
1. Install the Vercel CLI:
```bash
npm install -g vercel
```
2. Login to Vercel:
```bash
vercel login
```
3. Deploy the code:
```bash
vercel
```
4. Set up environment variables:
```bash
vercel env [environment-name] [variable-name]=[value]
```
5. Run database migrations (if applicable):
```bash
vercel run [environment-name] npm run migrate
```
### π Environment Variables
Provide a comprehensive list of all required environment variables, their purposes, and example values:
- `DATABASE_URL`: Connection string for the PostgreSQL database
Example: `postgresql://user:password@host:port/database`
- `NEXTAUTH_URL`: The URL of your Next.js application
Example: `http://localhost:3000`
- `NEXTAUTH_SECRET`: Secret key for NextAuth.js authentication
Example: `your-256-bit-secret`
- `SENTRY_DSN`: DSN for Sentry error tracking
Example: `https://YOUR_DSN@sentry.io/PROJECT_ID`
- `HOTJAR_ID`: ID for Hotjar user behavior analysis
Example: `your_hotjar_id`
## π API Documentation
### π Endpoints
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: `{ "email": string, "password": string }`
- Response: `{ "id": string, "email": string, "token": string }`
- **POST /api/goals**
- Description: Create a new fitness goal
- Headers: `Authorization: Bearer TOKEN`
- Body: `{ "title": string, "target": number, "userId": number }`
- Response: `{ "id": string, "title": string, "target": number, "userId": number }`
- **GET /api/goals**
- Description: Get a list of all goals for the current user
- Headers: `Authorization: Bearer TOKEN`
- Response: `[{ "id": string, "title": string, "target": number, "userId": number }]`
- **GET /api/progress**
- Description: Get a list of user's activities
- Headers: `Authorization: Bearer TOKEN`
- Query Parameters:
- `userId`: User ID
- `goalId`: (Optional) Goal ID to filter by
- `startDate`: (Optional) Start date to filter activities (YYYY-MM-DD)
- `endDate`: (Optional) End date to filter activities (YYYY-MM-DD)
- Response: `[{ "id": string, "type": string, "date": date, "duration": number, "goalId": number, "userId": number }]`
- **POST /api/progress**
- Description: Add a new activity log
- Headers: `Authorization: Bearer TOKEN`
- Body: `{ "type": string, "date": date, "duration": number, "goalId": number, "userId": number }`
- Response: `{ "id": string, "type": string, "date": date, "duration": number, "goalId": number, "userId": number }`
### π Authentication
Explain the authentication process in detail:
1. Register a new user or login to receive a JWT token
2. Include the token in the Authorization header for all protected routes:
```
Authorization: Bearer YOUR_JWT_TOKEN
```
### π Examples
Provide comprehensive examples of API usage, including request and response bodies:
```bash
# Register a new user
curl -X POST http://localhost:3000/api/auth/signup -H "Content-Type: application/json" -d '{"email": "fitnessuser@example.com", "password": "securepass123"}'
# Response
{
"id": "user123",
"email": "fitnessuser@example.com",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
# Create a new goal
curl -X POST http://localhost:3000/api/goals -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_JWT_TOKEN" -d '{"title": "Lose 10 lbs", "target": 150, "userId": 1}'
# Response
{
"id": "goal123",
"title": "Lose 10 lbs",
"target": 150,
"userId": 1
}
# Get a list of goals for the current user
curl -X GET http://localhost:3000/api/goals -H "Authorization: Bearer YOUR_JWT_TOKEN"
# Response
[
{
"id": "goal123",
"title": "Lose 10 lbs",
"target": 150,
"userId": 1
},
{
"id": "goal456",
"title": "Run 5km daily",
"target": 30,
"userId": 1
}
]
# Log a new activity
curl -X POST http://localhost:3000/api/progress -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_JWT_TOKEN" -d '{"type": "Running", "date": "2023-06-15", "duration": 30, "goalId": 1, "userId": 1}'
# Response
{
"id": "activity789",
"type": "Running",
"date": "2023-06-15",
"duration": 30,
"goalId": 1,
"userId": 1
}
```
## π License & Attribution
### π License
This Minimum Viable Product (MVP) is licensed under the [GNU AGPLv3](https://choosealicense.com/licenses/agpl-3.0/) license.
### π€ AI-Generated MVP
This MVP was entirely generated using artificial intelligence through [CosLynx.com](https://coslynx.com).
No human was directly involved in the coding process of the repository: Fitness-Tracker
### π Contact
For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:
- Website: [CosLynx.com](https://coslynx.com)
- Twitter: [@CosLynxAI](https://x.com/CosLynxAI)
<p align="center">
<h1 align="center">π CosLynx.com</h1>
</p>
<p align="center">
<em>Create Your Custom MVP in Minutes With CosLynxAI!</em>
</p>
<div class="badges" align="center">
<img src="https://img.shields.io/badge/Developers-Drix10,_Kais_Radwan-red" alt="">
<img src="https://img.shields.io/badge/Website-CosLynx.com-blue" alt="">
<img src="https://img.shields.io/badge/Backed_by-Google,_Microsoft_&_Amazon_for_Startups-red" alt="">
<img src="https://img.shields.io/badge/Finalist-Backdrop_Build_v4,_v6-black" alt="">
</div>