# endurannsu/backend architecture

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

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

## Overview

This repository implements a fitness-training platform: clients enter through a gateway, which routes requests to account and training APIs, exercise search, an LLM agent, and video-form analysis. The backend exposes user, exercise, training, and measurement capabilities; separate services handle retrieval and CV analysis. Exercise descriptions also use object storage, and the repository includes an exercise-ingestion workflow. Edges are limited to relationships visible in the excerpts or README; unsampled service internals and ingestion wiring are left unconnected where evidence is unavailable.

Main entry points: [`backend/src/main.py`](https://github.com/endurannsu/backend/blob/main/backend/src/main.py) (Backend API), [`gateway/src/gateway/proxy.py`](https://github.com/endurannsu/backend/blob/main/gateway/src/gateway/proxy.py) (API gateway), [`rag/src/retriever/routers/search.py`](https://github.com/endurannsu/backend/blob/main/rag/src/retriever/routers/search.py) (Exercise retrieval), [`exercise/internal/adapter/out/postgres/repository.go`](https://github.com/endurannsu/backend/blob/main/exercise/internal/adapter/out/postgres/repository.go) (Exercise repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Client entry"]
  node_gateway["API gateway<br/>[proxy.py]"]
end

subgraph group_fitness["Fitness APIs"]
  node_backend["Backend API<br/>[main.py]"]
  node_accounts["Accounts"]
  node_users["User profiles<br/>[user.py]"]
  node_exercises["Exercises<br/>[exercise.py]"]
  node_training["Training plans<br/>[training.py]"]
  node_measurements["Measurements<br/>[measurement.py]"]
  node_backenddb[("Backend database")]
  node_exercise_service["Exercise service"]
  node_exercise_store["Exercise repository<br/>[repository.go]"]
  node_object_store[("Object storage<br/>[client.go]")]
end

subgraph group_intelligence["AI services"]
  node_retriever["Exercise retrieval<br/>[search.py]"]
  node_rag_pipelines["RAG pipelines"]
  node_agent["LLM agent<br/>[agent.py]"]
  node_agent_tools["Agent tools<br/>[exercise_rag.py]"]
  node_llm["LLM proxy<br/>[router.py]"]
  node_cv["Video analysis<br/>[analyze.py]"]
  node_cv_live["Live analysis<br/>[ws.py]"]
end

subgraph group_ingestion["Exercise ingestion"]
  node_ingestion["Exercise ingestion"]
end

node_client(("Platform client"))

node_client -->|"sends requests"| node_gateway
node_gateway -->|"routes API calls"| node_backend
node_gateway -->|"routes search"| node_retriever
node_gateway -->|"routes agent calls"| node_agent
node_gateway -->|"routes LLM calls"| node_llm
node_gateway -->|"routes CV calls"| node_cv
node_backend -->|"registers routes"| node_accounts
node_backend -->|"registers routes"| node_users
node_backend -->|"registers routes"| node_exercises
node_backend -->|"registers routes"| node_training
node_backend -->|"registers routes"| node_measurements
node_backend -.->|"uses persistence"| node_backenddb
node_exercise_service -->|"delegates operations"| node_exercise_store
node_exercise_store -->|"stores descriptions"| node_object_store
node_retriever -.->|"uses retrieval"| node_rag_pipelines
node_agent -.->|"dispatches tools"| node_agent_tools
node_agent_tools -.->|"queries exercises"| node_retriever
node_cv -.->|"offers live analysis"| node_cv_live
node_ingestion -.->|"populates index"| node_retriever

click node_gateway "https://github.com/endurannsu/backend/blob/main/gateway/src/gateway/proxy.py"
click node_backend "https://github.com/endurannsu/backend/blob/main/backend/src/main.py"
click node_accounts "https://github.com/endurannsu/backend/tree/main/backend/src/backend/routers/access"
click node_users "https://github.com/endurannsu/backend/blob/main/backend/src/backend/routers/user.py"
click node_exercises "https://github.com/endurannsu/backend/blob/main/backend/src/backend/routers/exercise.py"
click node_training "https://github.com/endurannsu/backend/blob/main/backend/src/backend/routers/training.py"
click node_measurements "https://github.com/endurannsu/backend/blob/main/backend/src/backend/routers/measurement.py"
click node_backenddb "https://github.com/endurannsu/backend/tree/main/backend/src/backend/database/sqlalchemy"
click node_exercise_service "https://github.com/endurannsu/backend/tree/main/exercise/internal/adapter/in/http"
click node_exercise_store "https://github.com/endurannsu/backend/blob/main/exercise/internal/adapter/out/postgres/repository.go"
click node_object_store "https://github.com/endurannsu/backend/blob/main/exercise/internal/minio/client.go"
click node_retriever "https://github.com/endurannsu/backend/blob/main/rag/src/retriever/routers/search.py"
click node_rag_pipelines "https://github.com/endurannsu/backend/tree/main/rag/src/retriever/core/pipelines"
click node_agent "https://github.com/endurannsu/backend/blob/main/agent/src/agent/agent_backend/agent.py"
click node_agent_tools "https://github.com/endurannsu/backend/blob/main/agent/src/agent/agent_backend/tools/exercise_rag.py"
click node_llm "https://github.com/endurannsu/backend/blob/main/llm/src/llm/router.py"
click node_cv "https://github.com/endurannsu/backend/blob/main/cv_service/src/cv_service/routers/analyze.py"
click node_cv_live "https://github.com/endurannsu/backend/blob/main/cv_service/src/cv_service/routers/ws.py"
click node_ingestion "https://github.com/endurannsu/backend/tree/main/airflow/dags/exercise_ingestion/tasks"

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_gateway,node_client toneBlue
class node_backend,node_accounts,node_users,node_exercises,node_training,node_measurements,node_backenddb,node_exercise_service,node_exercise_store,node_object_store toneAmber
class node_retriever,node_rag_pipelines,node_agent,node_agent_tools,node_llm,node_cv,node_cv_live toneMint
class node_ingestion toneRose
```

## Components

### Client entry

- [API gateway](https://github.com/endurannsu/backend/blob/main/gateway/src/gateway/proxy.py): `gateway/src/gateway/proxy.py`

### Fitness APIs

- [Backend API](https://github.com/endurannsu/backend/blob/main/backend/src/main.py): `backend/src/main.py`
- [Accounts](https://github.com/endurannsu/backend/tree/main/backend/src/backend/routers/access): `backend/src/backend/routers/access`
- [User profiles](https://github.com/endurannsu/backend/blob/main/backend/src/backend/routers/user.py): `backend/src/backend/routers/user.py`
- [Exercises](https://github.com/endurannsu/backend/blob/main/backend/src/backend/routers/exercise.py): `backend/src/backend/routers/exercise.py`
- [Training plans](https://github.com/endurannsu/backend/blob/main/backend/src/backend/routers/training.py): `backend/src/backend/routers/training.py`
- [Measurements](https://github.com/endurannsu/backend/blob/main/backend/src/backend/routers/measurement.py): `backend/src/backend/routers/measurement.py`
- [Backend database](https://github.com/endurannsu/backend/tree/main/backend/src/backend/database/sqlalchemy): `backend/src/backend/database/sqlalchemy`
- [Exercise service](https://github.com/endurannsu/backend/tree/main/exercise/internal/adapter/in/http): `exercise/internal/adapter/in/http`
- [Exercise repository](https://github.com/endurannsu/backend/blob/main/exercise/internal/adapter/out/postgres/repository.go): `exercise/internal/adapter/out/postgres/repository.go`
- [Object storage](https://github.com/endurannsu/backend/blob/main/exercise/internal/minio/client.go): `exercise/internal/minio/client.go`

### AI services

- [Exercise retrieval](https://github.com/endurannsu/backend/blob/main/rag/src/retriever/routers/search.py): `rag/src/retriever/routers/search.py`
- [RAG pipelines](https://github.com/endurannsu/backend/tree/main/rag/src/retriever/core/pipelines): `rag/src/retriever/core/pipelines`
- [LLM agent](https://github.com/endurannsu/backend/blob/main/agent/src/agent/agent_backend/agent.py): `agent/src/agent/agent_backend/agent.py`
- [Agent tools](https://github.com/endurannsu/backend/blob/main/agent/src/agent/agent_backend/tools/exercise_rag.py): `agent/src/agent/agent_backend/tools/exercise_rag.py`
- [LLM proxy](https://github.com/endurannsu/backend/blob/main/llm/src/llm/router.py): `llm/src/llm/router.py`
- [Video analysis](https://github.com/endurannsu/backend/blob/main/cv_service/src/cv_service/routers/analyze.py): `cv_service/src/cv_service/routers/analyze.py`
- [Live analysis](https://github.com/endurannsu/backend/blob/main/cv_service/src/cv_service/routers/ws.py): `cv_service/src/cv_service/routers/ws.py`

### Exercise ingestion

- [Exercise ingestion](https://github.com/endurannsu/backend/tree/main/airflow/dags/exercise_ingestion/tasks): `airflow/dags/exercise_ingestion/tasks`

### Other components

- **Platform client**

## Connections

- Platform client → API gateway: sends requests
- API gateway → Backend API: routes API calls (evidence: `gateway/src/gateway/proxy.py`)
- API gateway → Exercise retrieval: routes search (evidence: `gateway/src/gateway/proxy.py`)
- API gateway → LLM agent: routes agent calls (evidence: `gateway/src/gateway/proxy.py`)
- API gateway → LLM proxy: routes LLM calls (evidence: `gateway/src/gateway/proxy.py`)
- API gateway → Video analysis: routes CV calls (evidence: `gateway/src/gateway/proxy.py`)
- Backend API → Accounts: registers routes (evidence: `backend/src/main.py`)
- Backend API → User profiles: registers routes (evidence: `backend/src/main.py`)
- Backend API → Exercises: registers routes (evidence: `backend/src/main.py`)
- Backend API → Training plans: registers routes (evidence: `backend/src/main.py`)
- Backend API → Measurements: registers routes (evidence: `backend/src/main.py`)
- Backend API → Backend database: uses persistence
- Exercise service → Exercise repository: delegates operations
- Exercise repository → Object storage: stores descriptions (evidence: `exercise/internal/adapter/out/postgres/repository.go`)
- Exercise retrieval → RAG pipelines: uses retrieval
- LLM agent → Agent tools: dispatches tools
- Agent tools → Exercise retrieval: queries exercises
- Video analysis → Live analysis: offers live analysis
- Exercise ingestion → Exercise retrieval: populates index
