FastAPI backend for TrackFitt β AI-powered workout recommendations, real-time tracking, token gamification.
Frontend β TrackFitt
graph TD
A[React Client] -->|REST API| B[FastAPI]
A -->|WebSocket| C[WS Manager]
B --> D{AI Layer}
D -->|Exercises| E[DeepSeek API]
D -->|Suggestions| F[Google AI Studio]
B --> G[(PostgreSQL)]
G --> H[17 Tables<br/>SQLAlchemy + Alembic]
B --> I[S3<br/>Profile Images]
AI Features:
- Exercise recommendations based on fitness level and goals
- Smart workout plan generation
- AI-powered exercise categorization
Core API:
- Full auth flow (JWT + role-based access)
- Exercise CRUD with 200+ pre-loaded exercises (CSV seed data)
- Workout creation, scheduling, and active tracking
- Workout history with detailed set/rep/weight logging
- Token economy (earn β request β distribute)
- User profiles with fitness/health/goal data
- Real-time WebSocket notifications
Admin API:
- User management (roles, activation)
- Exercise library management
- Token request approval/rejection
| Model | Purpose |
|---|---|
User |
Auth + roles (user/admin) |
UserProfile |
Physical metrics, fitness level, goals |
Exercise |
200+ exercises with categories |
ExerciseCategory |
Cardio, HIIT, Pilates, Flexibility, Strength |
Workout |
Custom workout templates |
WorkoutExercise + Set |
Exercises within workouts with sets |
ScheduledWorkout |
Planned future workouts |
WorkoutHistory |
Completed workout logs |
Token + TokenRequest |
Gamification currency |
Notification |
Real-time alerts |
AITracking |
AI interaction logs |
git clone https://github.com/abhiFSD/TrackFitt-API.git
cd TrackFitt-API
cp .env.example .env # Add your API keys
docker-compose up -d # Starts API + PostgreSQLAPI available at http://localhost:8000
pip install -r requirements.txt
# Setup database
alembic upgrade head
python init-db.py
# Run
uvicorn app.main:app --reload --port 8000| Component | Technology |
|---|---|
| Framework | FastAPI |
| Database | PostgreSQL 15 |
| ORM | SQLAlchemy 2.0 |
| Migrations | Alembic |
| AI | DeepSeek API + Google AI Studio |
| Auth | JWT (python-jose) + bcrypt (passlib) |
| Storage | AWS S3 (boto3) |
| Real-time | WebSockets |
| Deployment | Docker + Docker Compose |
| Data | CSV seed files (200+ exercises) |
βββ app/
β βββ main.py # FastAPI app + CORS + WebSocket
β βββ api/
β β βββ endpoints.py # 57 route handlers
β β βββ auth.py # JWT auth + password hashing
β βββ models/models.py # 17 SQLAlchemy models
β βββ schemas/schemas.py # Pydantic request/response schemas
β βββ services/
β β βββ websocket_service # Connection manager
β β βββ notification_* # Push notification system
β βββ db/database.py # DB session + engine
βββ dataCsv/ # Exercise seed data
β βββ cardio_exercises.csv
β βββ hiit_exercises.csv
β βββ pilates_exercises.csv
β βββ flexibility_exercises.csv
βββ migrations/ # Alembic migrations
βββ docker-compose.yml # API + PostgreSQL
βββ Dockerfile
βββ requirements.txt
cp .env.example .env| Variable | Required | Description |
|---|---|---|
AWS_REGION |
Yes | AWS region for S3 |
AWS_ACCESS_KEY_ID |
Yes | S3 access key |
AWS_SECRET_ACCESS_KEY |
Yes | S3 secret |
S3_BUCKET |
Yes | S3 bucket for uploads |
DEEPSEEK_API_KEY |
Yes | DeepSeek AI key |
GOOGLE_AI_STUDIO_KEY |
Optional | Google AI key |
MIT