ARDIFIT AI Engine
A training-program engine that puts injuries first: deterministic rules build the plan, a guard-railed GPT-4 coach explains it.
- Clinical-safety layer
- Deterministic rule engine
- Guard-railed GPT-4 coach
- 5 languages incl. Arabic RTL
- Client
- ARDIFIT
- Year
- 2025–26
- Authorship
- Own build
- Status
- Role
- Sole back-end engineer and AI integrator: engine, safety layers, coach, tests, deployment and handover.
- Surfaces
- REST API · demo and admin UI · desktop and mobile
- Languages
- EN · RU · AR · ES · DE
- Stack
- Python · FastAPI · Pydantic · SQLAlchemy · OpenAI GPT-4 · pytest · Docker · Render · Vanilla JS demo UI
- Links
- Walkthrough on request
Survey — context and problem.
The problem
Turn a questionnaire into a safe multi-week plan — injuries first — and add an AI coach that knows what it must refuse.
ARDIFIT is a fitness start-up building personalised training programs. Its users fill in a questionnaire on the client’s WordPress site — goals, experience, equipment, schedule, subscription tier and, crucially, injuries — and expect a safe multi-week plan in return.
Safety was the constraint that shaped everything. A user with a severe lower-back injury and a sore knee must never receive an exercise that loads either region, yet every training day still has to contain a real workout rather than a list of stretches. The client supplied the exercise data packs and the training-logic rules; they needed an engine that applies those rules exactly and predictably, and can prove it with tests.
The client also wanted an AI coach — but a bounded one. It had to explain why an exercise was chosen and suggest safe substitutions, while refusing medical diagnosis, nutrition planning and any attempt to redesign the program on its own. The front end would be built in WordPress by another developer, so the engine had to be a clean, documented API.
Plan — the system, drawn first.
The solution
A FastAPI engine: clinical-safety layer, rule-based program generator with a minimum-workout guarantee, and a GPT-4 coach behind strict guardrails — covered by 183 tests.
The engine is a FastAPI service; the client’s documentation puts the split at roughly 90% deterministic rules and 10% language model. A questionnaire posted from WordPress goes through the clinical-safety layer first: severe injuries switch a region to an allow-list, moderate ones to a restricted list, and with several injuries an exercise must be safe for every injured region. The program generator maps goals and experience to a split and weekly volume, the selector matches movement patterns to available equipment with a three-tier fallback, and a minimum-workout guarantee keeps at least two genuine strength movements on every training day. Progression models and automatic deload weeks follow. Only then does GPT-4 come in — to explain the plan and suggest safe swaps, behind intent classification, refusals, tone sanitising and a response validator. A demo UI and Swagger docs make the whole flow testable.
Module key
- Questionnaire schema: 8 goals, 3 experience levels, 10 equipment types, 9 injury regions × 3 severities
- Allow-list and restricted-list injury modes; volume governance for severe injuries
- Program generator with progression models and automatic deload weeks
- 300-exercise master library built from the client’s data packs
- GPT-4 coach with intent classification, refusals and response validation
- Tier limits of 5, 20 and 100 coach questions a day
- Exercise GIFs via ExerciseDB, with fallbacks when the API fails
- Demo UI and API tester in EN, RU, AR (RTL), ES and DE; Swagger docs
Key decisions
-
Why 90% rules and 10% language model
Safety and repeatability cannot depend on sampling. Rules generate the plan and tests pin down its behaviour; the model only explains it.
-
Why safety runs before selection
Filtering unsafe exercises first, then selecting, means no later step can reintroduce a risky movement. With several injuries, an exercise must clear every injured region.
-
Why every day keeps a minimum workout
Restrictive profiles could otherwise collapse a day into mobility drills. The guarantee keeps at least two intentional strength, isometric or tempo movements.
-
Why the coach refuses by design
Diagnosis, nutrition plans and self-directed program changes are out of scope. Refusals, a banned-phrase cleaner, fallback replies and daily limits per tier keep it inside the client’s brief.
Elevations — the desktop screens.
All elevations 04
-
Fig. 4.1 Day cards of the generated program: each exercise with sets × reps, rest and tags for the injured regions it is cleared for. -
Fig. 4.2 Exercise library with search, filters and difficulty counts; cards show movement pattern, target muscles, default volume, progression level and coaching cues. -
Fig. 4.3 Built-in API tester calling the exercise-templates endpoint and showing the HTTP status, latency and a highlighted JSON response. -
Fig. 4.4 FastAPI Swagger documentation listing the rule-engine, OpenAI text and user-onboarding endpoints.
Details — the mobile screens.
Every mobile screen 06
Materials schedule — the stack, and why.
| Layer | Material | Why |
|---|---|---|
| 01Data | SQLAlchemy · SQLite / Postgres · 300-exercise library | Client data packs loaded into a relational model that runs locally and in production. |
| 02Logic | Python rule engine · clinical-safety layer · progression & deload | Deterministic, testable decisions: the same profile always yields the same safe plan. |
| 03Intelligence | OpenAI GPT-4 behind guardrails | Natural-language explanations without letting the model diagnose or redesign. |
| 04Interface | FastAPI · Swagger · demo UI in 5 languages | A documented JSON API for the client’s WordPress front end, plus a demo to walk through it. |
| 05Infra | Docker · Render · Vercel / Railway configs · pytest | Portable deployment options, with 183 tests handed over together with the code. |
Stack
Completion — outcome and links.
Verified facts
- automated tests
- 183
- Source: from the repository, Sep 2026
- exercises in the master library
- 300
- Source: from the repository, Sep 2026
- injury regions × severity levels
- 9 × 3
- Source: from the repository, Sep 2026
- UI languages, incl. Arabic RTL
- 5
- Source: from the repository, Sep 2026
Links
Delivered
Walkthrough on request
Want to see it running?
I can walk you through the live system on demo data and explain the decisions behind it.
Request a walkthrough





