Agent systems / Product / Case study
Winperium
A routine, habit and goal product with Alfred, an AI coach that proposes changes but never applies them silently.

01 / Idea
A routine product with a coach inside.
Winperium helps people turn goals into routines and see how consistently they carry them out. Alfred, its AI coach, reads the context the user has authorized and helps plan, analyse and adjust.
The product puts the assistant together with the less visible work of a deployed system: authentication, recurrence rules, data modeling, usage quotas and iteration after launch.
02 / Stack
Python where the intelligence lives.
The backend is an async FastAPI application on PostgreSQL, with SQLAlchemy 2 and Alembic. Authentication covers email verification, one-time login codes, revocable refresh tokens and Google sign-in. The frontend is a Next.js 16 app with React Query and GSAP, installable as a PWA.
The AI layer is a LangGraph state machine with role-specific OpenAI models: gpt-4o-mini for routing, Alfred and the critic, and GPT-5 for the analytical Feedbacker. At runtime only the user's query is embedded, with text-embedding-3-small. The backend runs entirely in Python.
Application
FastAPI · SQLAlchemy 2 · Alembic
Thin routes, a service layer, and repositories that own every query and the user-ownership boundary.
Data & identity
PostgreSQL · Redis · JWT · Google Identity
Product data, revocable refresh tokens, email verification and shared rate limiting in production.
Intelligence
LangGraph · OpenAI structured outputs · FAISS + BM25
Route intent, retrieve audited evidence and validate every model response against a schema.
03 / Architecture
Give each layer a clear job.
Routes validate transport contracts and delegate. Services coordinate repositories, and repositories own the SQL and the user-ownership boundary. The AI path adds its own preflight: idempotent replays, billing access, route selection and quota reservation all happen before the graph runs.
The graph works on serializable state. Database sessions, credentials and provider clients stay in the runtime context, never in agent state, so every run can be traced and persisted without leaking them.
01 / Responsibility
Product layer
Goals, recurring habits, routine items, completion logs, vacation periods and consistency dashboards.
02 / Responsibility
Application API
Routes stay thin; services and repositories hold the rules. Alembic owns the schema, and Railway runs migrations before every deploy.
03 / Responsibility
Alfred
One public assistant over four internal capabilities: deterministic, conversational, analytical (the Feedbacker) and knowledge-augmented.
04 / Responsibility
Human in the loop
A suggested change becomes a validated, simulated pending patch, applied only when the user accepts, edits or rejects it.
04 / Flow
From intent to a decision the user makes.
The compiled graph has 56 nodes. Local safety checks and high-confidence classification run first; the router model is only called when the intent is ambiguous.
When Alfred suggests changing a goal, habit or routine item, it produces a pending patch. The patch is validated against public schemas, simulated against the current state and applied only through explicit accept, edit or reject endpoints.
- 01
Preflight
Replay idempotent requests, check the plan, choose the route and reserve quota before any inference.
- 02
Route
Local rules resolve clear intents; a small router model is consulted only when the intent is ambiguous.
- 03
Retrieve
Hybrid search over a 45-document audited corpus. Weak evidence returns an empty pack, not unrelated context.
- 04
Respond
Role-specific models answer through strict schemas, a critic reviews analysis, and any change waits for the user.
05 / Challenges
Reliability beyond the first response.
Long analytical requests exposed two production issues. On Railway and mobile networks, an SSE stream that stayed silent while retrieval or the Feedbacker ran could be closed mid-answer; the stream now sends a heartbeat every eight seconds, independent of model latency.
The Feedbacker plus the critic could also exceed the graph's request timeout once retries stacked up. The fix gave each model role its own retry budget, made both fail fast, and skipped the critic when the Feedbacker was unavailable, keeping the worst case inside the limit.
06 / Status
Deployed. Still being refined.
Winperium runs as a public beta at winperium.app. The API is deployed on Railway with migrations applied before every release, and a scheduled GitHub Actions workflow takes encrypted daily database backups.
The RAG corpus is machine-audited, not human-reviewed, and is labeled that way; it is not presented as authoritative health guidance. No user counts, revenue or retention figures are claimed.