What it is
FitWise is a web app that creates workout plans through a chat assistant and then watches you perform them through a webcam. It counts repetitions, scores each one, and gives short feedback as text or Bengali speech. The language models run locally through LM Studio. Only the optional voice feedback calls a hosted API.
The problem
Workout apps usually separate planning from execution. A chat tool can write a routine, but it cannot see whether you squat deep enough. A pose tracker can see you, but it only supports the exercises its authors hard-coded.
FitWise connects the two. The assistant that writes the routine also generates the tracking configuration for each exercise in it, so the camera side is not limited to a fixed list.
How it works
The app is a SvelteKit project with server routes under src/routes/api/. Three flows share one Postgres database (through Prisma) and one vector store (Qdrant).
| Flow | Entry point | What happens |
|---|---|---|
| Chat and planning | api/chat/+server.ts | Streams a reply with the Vercel AI SDK. The model can call three tools: createWorkout, saveWorkout, and generateExerciseConfig. |
| Exercise configuration | api/exercise-config/+server.ts | Asks the model for a structured config (Zod schema) and saves it in the ExerciseConfig table. |
| Form feedback | api/feedback/+server.ts | Takes per-rep measurements and returns a score, a class (good, okay, bad), and a short comment. |
Retrieval (RAG)
RAG (retrieval-augmented generation) means the app fetches relevant text and adds it to the prompt before the model answers. A Python script in embedding/ scrapes RP Strength hypertrophy articles, splits them into chunks of up to 2,000 characters, embeds them, and stores them in a Qdrant collection named rp_exercises.
The chat route only searches that collection when the message contains a fitness keyword. It keeps results with a similarity score of at least 0.7. The feedback route uses a lower cut-off of 0.6 and only runs retrieval when the user enables it.
Pose tracking
The browser runs MediaPipe's pose landmarker (@mediapipe/tasks-vision) on the webcam stream. src/lib/workout-utils.ts turns the 33 landmarks into joint angles and processes them in four steps:
- Combine the configured joint angles into one weighted signal.
- Smooth the signal with a moving average.
- Detect peaks and valleys, with a minimum distance between peaks, to split the signal into repetitions.
- Send each finished repetition (duration, angle range, range of motion) to the feedback route.
Exercise configurations
A generated configuration lists the landmark triples that define each tracked angle, a weight, a target low and high angle, whether to invert the signal, the starting direction, and the minimum peak distance. The ExerciseConfig table stores it as JSON next to metadata such as movement pattern and key joints. Workout exercises link to a config by foreign key. The client also keeps an in-memory cache.
What I built
I built the whole project alone. That covers the pose tracking and rep segmentation, workout chat and management, the Qdrant retrieval pipeline, the local-model feedback and the Sarvam voice output.
Design decisions
Structured output instead of free text. The config and feedback routes call generateObject with a Zod schema. A small local model can still return malformed JSON, but the schema gives a clear validation point. The config schema also bounds values, such as 5 to 20 frames for peak distance.
Generated tracking configs instead of a fixed exercise list. An earlier version tracked only bicep curls, squats, and push-ups (docs/DYNAMIC_EXERCISE_CONFIG.md). Generating configs removes that limit. The cost is that a model can choose wrong joints, and the app has no automatic check for that. The repo includes pages to view and test saved configs.
Local models. The app uses qwen/qwen3-4b for chat and a DeepSeek R1 distilled Qwen3 8B model for feedback, both served by LM Studio over an OpenAI-compatible API. This keeps prompts and workout data on the machine, apart from the optional speech request. The trade-off is lower answer quality than hosted models and a hardware requirement.
Separate toggles for retrieval and voice. Each feedback request carries enableRAG and enableVoice flags. Retrieval and speech add latency, so the user can pick fast text feedback or slower, richer feedback. Speech comes from the Sarvam AI text-to-speech API.
Challenges I ran into
These notes are mine, from building the app during the hackathon.
Turning pose landmarks into usable angles. Raw MediaPipe output is noisy. I combined several joint angles into one weighted signal, smoothed it with a moving average, and used a peak detector that adapts to each exercise. Normalizing the angles also made them easier for the model to interpret.
Latency with several models running. Embedding, vector search, and generation each add delay, and the local models compete for RAM with the pose tracker. I raised the relevance threshold for retrieval and cached exercise configs so the app skips repeated generation.
Getting a clean knowledge base. The retrieval quality depends on the scraped text. I limited the sources to RP Strength articles rather than general fitness blogs.
Local model quality. Small models give less nuanced feedback than large hosted ones. I picked qwen3-4b for its instruction following and tuned prompts for it.
Run it locally
You need Node.js, pnpm, Docker, a PostgreSQL database, LM Studio, and a webcam.
-
Clone the repository and install dependencies.
git clone https://github.com/WhyAsh5114/fit-wise cd fit-wise pnpm install -
Start Qdrant.
docker run -p 6333:6333 -v $(pwd)/qdrant_storage:/qdrant/storage qdrant/qdrant -
In LM Studio, load a chat model (
qwen/qwen3-4b) and an embedding model (text-embedding-nomic-embed-text-v1.5). Start the local server on port 1234. -
Fill the vector store from the
embedding/directory.cd embedding uv sync uv run main.py cd .. -
Create a
.envfile with these variables.SARVAM_API_KEYis read by the feedback route for voice output.DATABASE_URL="postgresql://user:password@localhost:5432/fitwise" LM_STUDIO_URL="http://localhost:1234" EMBEDDING_MODEL="text-embedding-nomic-embed-text-v1.5" QDRANT_URL="http://localhost:6333" BETTER_AUTH_SECRET="your-secret-key" BETTER_AUTH_URL="http://localhost:5173" SARVAM_API_KEY="your-sarvam-key" -
Apply the database migrations and start the dev server.
pnpm prisma migrate dev pnpm dev
The feedback route also hard-codes http://172.21.96.1:1234 as the LM Studio address for its chat model. Change it in src/routes/api/feedback/+server.ts if your server runs elsewhere.
Reference
| Area | Choice | Used for |
|---|---|---|
| Framework | SvelteKit, Svelte 5, TypeScript | UI and server routes |
| UI | Tailwind CSS 4, shadcn-svelte components | Styling and components |
| AI orchestration | Vercel AI SDK (ai), Zod | Streaming chat, tool calls, structured output |
| Models | LM Studio (OpenAI-compatible API) | Chat, feedback, embeddings |
| Vector store | Qdrant | Exercise-science chunks for RAG |
| Pose tracking | MediaPipe Tasks Vision | In-browser landmark detection |
| Database | PostgreSQL with Prisma | Users, workouts, exercises, exercise configs |
| Authentication | Better Auth (anonymous plugin) | Sessions |
| Speech | Sarvam AI text-to-speech | Spoken feedback in Bengali |
Main database models: Workout, WorkoutExercise, and ExerciseConfig, plus the Better Auth tables.
Outcome
I built FitWise alone at Warpspeed 2025, a 24-hour Devfolio hackathon in Bengaluru on 21 June 2025. The hackathon page records no placement. The repository's commits run from 21 June to 22 June 2025, and the repo has no later activity.