# silpoages/silpo-backend architecture

> Architecture diagram of the GitHub repository silpoages/silpo-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/silpoages/silpo-backend
- Repository: https://github.com/silpoages/silpo-backend

## Overview

Silpo is a server-side FastAPI API for a mobile mental-wellness product, backed by async SQLAlchemy and PostgreSQL. The main workflow is a client request entering the app’s registered HTTP routes, passing through route-level service dependencies, and using business services to operate on domain records; authentication additionally supports registration, login, and email confirmation. The graph preserves the listed mood, activity, good-practice, and emergency-contact capabilities, plus other domain models. Relationships for unsampled routes and storage are based on README statements and SOURCE INDEX references, not inspected implementations.

Main entry points: [`app/api/routes`](https://github.com/silpoages/silpo-backend/tree/develop/app/api/routes) (HTTP routes), [`app/models`](https://github.com/silpoages/silpo-backend/tree/develop/app/models) (Domain records), [`app/main.py`](https://github.com/silpoages/silpo-backend/blob/develop/app/main.py) (FastAPI app), [`app/services/user.py`](https://github.com/silpoages/silpo-backend/blob/develop/app/services/user.py) (User service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_app["FastAPI app<br/>[main.py]"]
  node_routes["HTTP routes"]
  node_dependencies["Service dependencies<br/>[deps.py]"]
end

subgraph group_identity["Identity"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_users["User service<br/>[user.py]"]
  node_security["Token security<br/>[security.py]"]
  node_confirmation["Email confirmation"]
  node_email["Transactional email<br/>[email.py]"]
end

subgraph group_wellness["Wellness features"]
  node_activities["Activities<br/>[activity.py]"]
  node_moods["Mood logs<br/>[mood_log.py]"]
  node_practices["Good practices<br/>[good_practice.py]"]
  node_contacts["Emergency contacts"]
end

subgraph group_data["Persistence and domain"]
  node_domain_models["Domain records"]
  node_postgres[("PostgreSQL")]
  node_settings["Runtime settings<br/>[config.py]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"registers"| node_routes
node_routes -->|"resolves services"| node_dependencies
node_routes -->|"calls services"| node_activities
node_routes -->|"calls services"| node_moods
node_routes -->|"calls services"| node_practices
node_routes -->|"calls services"| node_contacts
node_auth_routes -->|"calls service"| node_users
node_auth_routes -->|"calls service"| node_confirmation
node_users -->|"hashes and signs"| node_security
node_users -->|"sends confirmation"| node_confirmation
node_confirmation -->|"sends email"| node_email
node_activities -->|"queries activity records"| node_domain_models
node_moods -->|"uses mood records"| node_domain_models
node_practices -->|"uses practice records"| node_domain_models
node_contacts -->|"uses contact records"| node_domain_models
node_domain_models -->|"persisted via ORM"| node_postgres
node_app -->|"loads settings"| node_settings
node_email -->|"reads email config"| node_settings

click node_app "https://github.com/silpoages/silpo-backend/blob/develop/app/main.py"
click node_routes "https://github.com/silpoages/silpo-backend/tree/develop/app/api/routes"
click node_dependencies "https://github.com/silpoages/silpo-backend/blob/develop/app/api/deps.py"
click node_auth_routes "https://github.com/silpoages/silpo-backend/blob/develop/app/api/routes/auth.py"
click node_users "https://github.com/silpoages/silpo-backend/blob/develop/app/services/user.py"
click node_security "https://github.com/silpoages/silpo-backend/blob/develop/app/core/security.py"
click node_confirmation "https://github.com/silpoages/silpo-backend/blob/develop/app/services/email_confirmation.py"
click node_email "https://github.com/silpoages/silpo-backend/blob/develop/app/services/email.py"
click node_activities "https://github.com/silpoages/silpo-backend/blob/develop/app/services/activity.py"
click node_moods "https://github.com/silpoages/silpo-backend/blob/develop/app/services/mood_log.py"
click node_practices "https://github.com/silpoages/silpo-backend/blob/develop/app/services/good_practice.py"
click node_contacts "https://github.com/silpoages/silpo-backend/blob/develop/app/services/emergency_contact.py"
click node_domain_models "https://github.com/silpoages/silpo-backend/tree/develop/app/models"
click node_settings "https://github.com/silpoages/silpo-backend/blob/develop/app/core/config.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_routes,node_dependencies,node_client toneBlue
class node_auth_routes,node_users,node_security,node_confirmation,node_email toneAmber
class node_activities,node_moods,node_practices,node_contacts toneMint
class node_domain_models,node_postgres,node_settings toneRose
```

## Components

### API entry

- [FastAPI app](https://github.com/silpoages/silpo-backend/blob/develop/app/main.py): `app/main.py`
- [HTTP routes](https://github.com/silpoages/silpo-backend/tree/develop/app/api/routes): `app/api/routes`
- [Service dependencies](https://github.com/silpoages/silpo-backend/blob/develop/app/api/deps.py): `app/api/deps.py`

### Identity

- [Auth routes](https://github.com/silpoages/silpo-backend/blob/develop/app/api/routes/auth.py): `app/api/routes/auth.py`
- [User service](https://github.com/silpoages/silpo-backend/blob/develop/app/services/user.py): `app/services/user.py`
- [Token security](https://github.com/silpoages/silpo-backend/blob/develop/app/core/security.py): `app/core/security.py`
- [Email confirmation](https://github.com/silpoages/silpo-backend/blob/develop/app/services/email_confirmation.py): `app/services/email_confirmation.py`
- [Transactional email](https://github.com/silpoages/silpo-backend/blob/develop/app/services/email.py): `app/services/email.py`

### Wellness features

- [Activities](https://github.com/silpoages/silpo-backend/blob/develop/app/services/activity.py): `app/services/activity.py`
- [Mood logs](https://github.com/silpoages/silpo-backend/blob/develop/app/services/mood_log.py): `app/services/mood_log.py`
- [Good practices](https://github.com/silpoages/silpo-backend/blob/develop/app/services/good_practice.py): `app/services/good_practice.py`
- [Emergency contacts](https://github.com/silpoages/silpo-backend/blob/develop/app/services/emergency_contact.py): `app/services/emergency_contact.py`

### Persistence and domain

- [Domain records](https://github.com/silpoages/silpo-backend/tree/develop/app/models): `app/models`
- **PostgreSQL**
- [Runtime settings](https://github.com/silpoages/silpo-backend/blob/develop/app/core/config.py): `app/core/config.py`

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests (evidence: `app/main.py`)
- FastAPI app → HTTP routes: registers (evidence: `app/main.py`)
- HTTP routes → Service dependencies: resolves services (evidence: `app/api/routes/auth.py`)
- HTTP routes → Activities: calls services (evidence: `README.md`)
- HTTP routes → Mood logs: calls services (evidence: `README.md`)
- HTTP routes → Good practices: calls services (evidence: `README.md`)
- HTTP routes → Emergency contacts: calls services (evidence: `README.md`)
- Auth routes → User service: calls service (evidence: `app/api/routes/auth.py`)
- Auth routes → Email confirmation: calls service (evidence: `app/api/routes/auth.py`)
- User service → Token security: hashes and signs (evidence: `app/services/user.py`)
- User service → Email confirmation: sends confirmation (evidence: `app/services/user.py`)
- Email confirmation → Transactional email: sends email (evidence: `app/services/email_confirmation.py`)
- Activities → Domain records: queries activity records (evidence: `app/services/activity.py`)
- Mood logs → Domain records: uses mood records (evidence: `app/services/mood_log.py`)
- Good practices → Domain records: uses practice records (evidence: `app/services/good_practice.py`)
- Emergency contacts → Domain records: uses contact records (evidence: `app/services/emergency_contact.py`)
- Domain records → PostgreSQL: persisted via ORM (evidence: `README.md`)
- FastAPI app → Runtime settings: loads settings (evidence: `app/main.py`)
- Transactional email → Runtime settings: reads email config (evidence: `app/services/email.py`)
