Repsense is an AI-powered fitness companion that turns workout history into adaptive programming. It combines a FastAPI backend, an agentic LLM pipeline, and a Next.js frontend to generate routines, capture feedback, and iterate on training plans.
- Routine generation based on uploaded workout history
- Feedback capture with routine resolution and episodic memory
- Routine history with contextual metadata and quick “Add to chat”
- Magic authentication for secured routine access
- Turso-backed storage with a lightweight SQL migration system
frontend/— Next.js app (Magic auth, chat UI, routines, history)backend/— FastAPI API (profiles, chat, routines)agentic/— LLM pipeline and intent/feedback logic
- Python 3.9+
- Node.js 18+
- Turso database (libsql)
Backend (/Users/prakharojha/Desktop/me/personal/repsense/.env):
OPENAI_API_KEY— required for LLM callsTURSO_DATABASE_URL— Turso connection URLTURSO_AUTH_TOKEN— Turso auth token (if required)MAGIC_SECRET_KEY— Magic admin secret for token validationOPIK_ENABLED— optional (1to enable tracing)
Frontend (/Users/prakharojha/Desktop/me/personal/repsense/frontend/.env.local):
NEXT_PUBLIC_API_URL— backend URL (defaulthttp://localhost:8000)NEXT_PUBLIC_MAGIC_PUBLISHABLE_KEY— Magic publishable key
cd /Users/prakharojha/Desktop/me/personal/repsense
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtRun database reset and migrations (Turso):
python3 -m backend.storage.reset_dbStart the API:
uvicorn backend.app:app --reloadcd /Users/prakharojha/Desktop/me/personal/repsense/frontend
npm install
npm run devFrontend routes:
http://localhost:3000/— Loginhttp://localhost:3000/home— Landing pagehttp://localhost:3000/routines— Routine history
- Users upload their workout history (CSV).
- The system generates a profile and uses it to create routines on request.
- When users give feedback (positive, negative, or injury), the system resolves which routine they mean and stores the outcome as episodic memory.
- Future prompts are enriched with recent chat context and past routine outcomes to generate better recommendations.
- Users can open new chats and still refer to previously generated workouts to improve and provide feedback to the agent.
We integrated Opik tracing to monitor LLM calls and enriched query construction, validating when memory and feedback are used in generation and evaluating output quality.
Feedback is resolved via a single LLM call that compares the user’s feedback text against the five most recent routine candidates. If ambiguous, the system asks a clarification question.
Migrations are stored in:
/Users/prakharojha/Desktop/me/personal/repsense/backend/storage/migrations
The reset script drops all tables and re-applies migrations:
python3 -m backend.storage.reset_db- Routine endpoints are protected with Magic auth. If
MAGIC_SECRET_KEYis missing, routine fetches will fail. - Routine history titles are disambiguated in the UI when duplicates exist.