BalanceCycle is a women's hormonal health and menstrual cycle-tracking application. It lets you log symptoms in plain, free-form text, uses a locally-run LLM (via Ollama) to structure and triage that text, predicts your next cycle, surfaces trends over time, and keeps a personal remedy journal — all without sending any data to third-party services.
⚠️ Not medical advice. BalanceCycle is a personal tracking and triage-support tool. It is not a substitute for professional medical diagnosis or treatment. Always consult a qualified healthcare provider for medical concerns.
- Free-text symptom logging — type or speak how you're feeling; an LLM extracts structured symptoms (name, body area, intensity, duration, category, severity) from your description.
- AI-assisted triage — every log is scored
mild/moderate/severeand mapped to a recommendation: home remedies, watch-and-wait, or "talk to a doctor," complete with a rationale. - Cycle tracking & prediction — log period start/end dates and get a predicted next period, fertile window, and a "Cycle Wheel" visualization.
- Trends & correlations — weekly severity bar charts, this-cycle-vs-last-cycle comparisons, and correlation insights across logged symptoms.
- Personal remedy journal — track which remedies you've tried for which symptoms and whether they helped.
- Doctor-visit export — generate a PDF summary (built entirely client-side) of your logs, cycles, and triage history to bring to an appointment.
- Privacy-first — the LLM runs locally via Ollama; no symptom data leaves your machine. A one-click "delete all data" option is available in Settings.
| Layer | Technology |
|---|---|
| Backend | Python, FastAPI, SQLAlchemy, Alembic |
| Database | PostgreSQL 16 |
| LLM | Ollama (default model: llama3.1), called via httpx |
| Frontend | React 19, Vite, React Router, Tailwind CSS, Recharts, lucide-react |
| PDF Export | jspdf + html2canvas (client-side, no server round-trip) |
| Containerization | Docker Compose (Postgres + Ollama + backend + frontend/nginx) |
| Testing | pytest, pytest-asyncio |
GitHub's automatic language detection currently reports this repository as 100% Python for its primary language stats; in practice the project is a full-stack app with a substantial React/JavaScript frontend under
frontend/, as reflected in the tech stack table above.
BalanceCycle/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI app entrypoint
│ │ ├── core/ # config + database setup
│ │ ├── models/ # SQLAlchemy models + Pydantic schemas
│ │ ├── routers/ # symptoms, triage, cycles, trends, remedies
│ │ ├── services/ # business logic (Ollama calls, triage engine, etc.)
│ │ └── alembic/ # DB migrations
│ ├── tests/ # pytest suite
│ ├── requirements.txt
│ └── Dockerfile
├── frontend/
│ ├── src/
│ │ ├── pages/ # Log, Triage, Trends, Resources, Settings, Splash
│ │ ├── components/ # CycleWheel, TrendsBars, SymptomFeed, VoiceInput, etc.
│ │ ├── hooks/ # API client, speech-to-text, local settings
│ │ └── lib/ # date utils, PDF export, notifications
│ ├── package.json
│ └── Dockerfile
├── docker-compose.yml
├── .env.docker
└── README.md
This spins up PostgreSQL, Ollama (with the model auto-pulled), the FastAPI backend, and the React frontend served via nginx.
git clone https://github.com/snpathaks/BalanceCycle.git
cd BalanceCycle
# Copy and edit environment variables (at minimum, change POSTGRES_PASSWORD)
cp .env.docker .env
docker compose up --buildOnce everything is healthy:
- Frontend: http://localhost
- Backend API docs (Swagger): http://localhost:8000/docs
- Ollama API:
http://localhost:11434
To stop and remove containers (keeping data volumes):
docker compose downTo also wipe the database and Ollama model cache:
docker compose down -vGPU note: the
ollamaservice indocker-compose.ymlrequests an NVIDIA GPU by default. If you don't have one, remove or comment out thedeploy.resources.reservations.devicesblock for theollamaservice before runningdocker compose up.
Prerequisites: Python 3.11+, Node.js 18+, PostgreSQL 16, and Ollama installed locally.
-
Start Ollama and pull the model
ollama serve ollama pull llama3.1
-
Backend
cd backend python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt cp .env.example .env # Edit .env: set DATABASE_URL to your local Postgres instance uvicorn app.main:app --reload
The API will be available at
http://localhost:8000(Swagger docs at/docs). -
Frontend
cd frontend npm install npm run devThe app will be available at
http://localhost:5173.
| Variable | Default | Description |
|---|---|---|
DATABASE_URL |
(required) | PostgreSQL connection string (postgresql+psycopg://...) |
OLLAMA_BASE_URL |
http://localhost:11434 |
Base URL of the running Ollama server |
OLLAMA_MODEL |
llama3.1 |
Ollama model used for symptom extraction |
ENVIRONMENT |
development |
development enables auto table creation on startup |
ALLOWED_ORIGINS |
http://localhost:5173 |
Comma-separated list of allowed CORS origins |
See backend/.env.example for the full template.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/log-symptom |
Submit free-text symptoms → LLM extraction → DB save |
| GET | /api/logs |
Paginated list of symptom logs |
| GET | /api/logs/{id} |
Single symptom log |
| POST | /api/triage |
Re-run triage on an existing log |
| GET | /api/triage/cards |
Categorized triage cards from recent logs |
| POST | /api/cycles |
Log a period start |
| PATCH | /api/cycles/{id} |
Mark a period's end date |
| GET | /api/cycles/predict |
Predict next period + fertile window |
| GET | /api/cycles/wheel |
Cycle Wheel visualization data |
| GET | /api/trends/bars |
Weekly severity bar chart data |
| GET | /api/trends/summary |
This-cycle-vs-last-cycle comparison + correlation insights |
| POST | /api/remedies |
Log a tried remedy |
| GET | /api/remedies |
List remedy journal |
| DELETE | /api/remedies/{id} |
Remove a remedy entry |
| GET | /api/export/data |
Full structured data export (used to generate the doctor-visit PDF) |
| DELETE | /api/user-data |
Permanently delete all data for a user |
| GET | /health |
Liveness probe |
Full interactive documentation is available at /docs (Swagger UI) once the backend is running.
cd backend
pytestTest coverage includes the triage engine (test_triage_engine.py) and the Ollama extraction service (test_ollama_service.py).
BalanceCycle is intended for personal tracking and informational purposes only. The triage suggestions and remedies it surfaces are not a substitute for professional medical advice, diagnosis, or treatment. If you are experiencing severe symptoms, please seek immediate medical attention.