Domain model and repository layout¶
This page shows what Dinatos stores (users, exercises, routines, activities and more). It also shows where the code is. Read this page first if you are new to the code. The backend and frontend pages use these terms and do not define them again.
For the same model from the point of view of a user, see Concepts.
Concepts¶
Each concept is a database table, or a small group of tables. The tables are
in backend/src/dinatos_backend/models/.
Term |
Meaning |
|---|---|
User |
A local account. Dinatos is a household app: many people share one server. Exactly one user owns each item, except exercises. |
Exercise |
One movement, for example “Romanian deadlift”. It is the only global resource. All users share one catalog. |
Routine |
A saved template with a name. It is an ordered list of exercises. Each exercise has planned sets. |
Activity |
A recorded gym session. It has the exercises that the user did, with sets, reps and weights. It comes from a routine or from a workout that the user builds during the session. All stats use activities. |
Planned workout |
A routine or free-form session that has a date in the future. It has a duration and a reminder lead time. It is one calendar entry. |
Superset |
Exercises that the user does back-to-back. Consecutive exercises with the same |
Set |
One row of weight, reps, distance and duration in a routine exercise or activity exercise. It has a |
Exercises: built-in and custom¶
Exercise.is_custom=Falsemarks the catalog that Dinatos ships. A new instance seeds it. It cannot change:PATCHandDELETEreturn 403. This protects the routines and tutorials that refer to the catalog.is_custom=Trueis the default. It marks an exercise that a user created. A user can edit and delete it.
Planned workouts are not activities¶
A plan must not count in stats before the user does the workout. When the user
saves a workout that started from a plan, the backend sets the
completed_activity_id of the plan to the new activity.
Planned workouts appear in the calendar on Home. They cause reminders on Android. The backend also publishes them as an ICS feed. See Calendar feed.
Tables at a glance¶
Table |
Purpose |
|---|---|
|
Accounts. One row of settings for each user |
|
Logins and API keys (see Authentication) |
|
The shared catalog |
|
Templates |
|
Sessions that the user did |
|
Calendar entries |
|
Weigh-ins and tape measurements, with dates |
|
Duplicate tracking for imports |
Note
When you add a table, you must also register it for backup. See Backup and data export.
Repository layout¶
dinatos/
backend/ FastAPI + async SQLAlchemy + pydantic API, backed by Postgres
frontend/ Flutter app (web and Android; Linux desktop packages too)
mcp_server/ Small stdio proxy to the backend's MCP endpoint
e2e/ Browser tests (Playwright) against the real web build
docs/ This site (Markdown, rendered with Sphinx + MyST)
packaging/ Linux .deb / AppImage packaging
The root Dockerfile and docker-compose.yml build and run all parts
together.
Each package directory has its own justfile. It does not need the other
packages (cd backend && just test). The root justfile imports each one as
a just module. For this reason, just backend test works from anywhere in
the repository.
The backend code has layers in backend/src/dinatos_backend/:
Directory |
Contents |
|---|---|
|
SQLAlchemy tables |
|
pydantic request and response shapes |
|
Business logic |
|
FastAPI routers ( |
Module boundaries¶
backend/tach.toml declares which layer can import which other layer.
just check and CI enforce it. The imports go in one direction:
config / models -> schemas -> db -> services -> api -> app (main.py)
If your change needs a new arrow, think again about the change first.