A simple full-stack AI app that acts as a personalized fitness coach. Users sign up, set their training preferences, and chat with an AI trainer that adapts to their goals, experience level, equipment, and preferred coaching tone.
- Backend: FastAPI
- Frontend: Streamlit
- LLM: Groq (
llama-3.1-8b-instant) via LangChain - Database: SQLite via SQLAlchemy
.
├── main.py # FastAPI backend (auth, preferences, chat endpoints)
├── dbSQLAlchemy.py # SQLAlchemy models + CRUD helpers
├── app.py # Streamlit entry: login / signup
├── pages/frontend.py # Streamlit page: preferences form + chat UI
├── start.sh # Launch backend + frontend together
├── requirements.txt
└── .env.example
python -m venv venv
source venv/bin/activate # macOS / Linux
# venv\Scripts\activate # Windowspip install -r requirements.txtCopy .env.example to .env and fill in your Groq API key:
cp .env.example .envGROQ_API=your_groq_api_key_hereYou can get an API key from console.groq.com.
bash start.shThis starts:
- FastAPI on
http://localhost:8000 - Streamlit on
http://localhost:8081
Open the Streamlit URL in your browser.
In one terminal:
uvicorn main:app --host 0.0.0.0 --port 8000 --reloadIn another:
streamlit run app.py| Method | Path | Purpose |
|---|---|---|
| POST | /signup/ |
Create a new user |
| POST | /login/ |
Look up an existing user |
| POST | /update_preferences/ |
Save / update training preferences |
| POST | /chat/ |
Send a message to the AI trainer |
| GET | /chat_history/{username} |
Fetch a user's full chat history |
On every /chat/ call the backend:
- Loads the user's saved preferences and full chat history from SQLite.
- Rebuilds LangChain memory from the stored messages.
- Builds a system prompt that interpolates the user's
goal,experience,days_per_week,equipment, andtone. - Runs the prompt + history + new message through the Groq LLM.
- Persists both the user's message and the assistant's reply.
- The database file
my_database.dbis created automatically on first run; there are no migrations. - Authentication is username-only (no passwords) — this project is intended as a demo, not a production deployment.
MIT — see LICENSE.