# thehimel/learning-platform-api architecture

> Architecture diagram of the GitHub repository thehimel/learning-platform-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thehimel/learning-platform-api
- Repository: https://github.com/thehimel/learning-platform-api

## Overview

Learning Platform API is a FastAPI service for JWT-authenticated users, role-aware course management, enrollments, and ratings. Clients enter through the application and API routers, then follow distinct identity or learning workflows into services, repositories, and PostgreSQL. Rating aggregation may run as a background task. The graph also preserves health/root endpoints and cross-cutting error, security, logging, and rate-limit layers. Some integrations are represented from the tree and README where their implementation was not sampled.

Main entry points: [`app/main.py`](https://github.com/thehimel/learning-platform-api/blob/main/app/main.py) (FastAPI App), [`app/api/router.py`](https://github.com/thehimel/learning-platform-api/blob/main/app/api/router.py) (API Router), [`app/courses/router.py`](https://github.com/thehimel/learning-platform-api/blob/main/app/courses/router.py) (Course Router), [`app/courses/repository.py`](https://github.com/thehimel/learning-platform-api/blob/main/app/courses/repository.py) (Course Repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API Entry"]
  node_app["FastAPI App<br/>[main.py]"]
  node_api_router["API Router<br/>[router.py]"]
end

subgraph group_identity["Identity"]
  node_auth_router["Auth Router<br/>[router.py]"]
  node_auth_backend["JWT Backend<br/>[backend.py]"]
  node_user_router["User Router<br/>[router.py]"]
  node_user_manager["User Manager<br/>[manager.py]"]
end

subgraph group_learning["Learning Domain"]
  node_course_router["Course Router<br/>[router.py]"]
  node_course_service["Course Service<br/>[service.py]"]
  node_course_repo["Course Repository<br/>[repository.py]"]
  node_rating_worker["Rating Worker<br/>[router.py]"]
  node_course_models["Course Models<br/>[models.py]"]
end

subgraph group_platform["Platform Services"]
  node_health_router["Health Router<br/>[router.py]"]
  node_health_service["Health Service<br/>[service.py]"]
  node_index_router["Root Router<br/>[router.py]"]
  node_index_service["Root Service<br/>[service.py]"]
  node_error_handler["Error Handler"]
  node_security["Security Middleware<br/>[setup_security.py]"]
  node_request_logging["Request Logging"]
  node_limiter["Rate Limiter<br/>[limiter.py]"]
  node_db_session["Async DB Session<br/>[database.py]"]
end

node_client(("API Client"))
node_database[("PostgreSQL")]

node_client -->|"sends requests"| node_app
node_app -->|"includes routes"| node_api_router
node_api_router -->|"includes routes"| node_auth_router
node_api_router -->|"includes routes"| node_user_router
node_api_router -->|"includes routes"| node_course_router
node_app -->|"includes routes"| node_health_router
node_app -->|"includes routes"| node_index_router
node_auth_router -->|"dispatches auth"| node_auth_backend
node_user_router -->|"manages users"| node_user_manager
node_user_manager -->|"reads/writes users"| node_database
node_course_router -->|"dispatches courses"| node_course_service
node_course_service -->|"executes domain logic"| node_course_repo
node_course_repo -->|"queries models"| node_course_models
node_course_repo -->|"reads/writes data"| node_database
node_course_router -.->|"schedules rating"| node_rating_worker
node_rating_worker -.->|"recomputes rating"| node_course_service
node_health_router -->|"checks health"| node_health_service
node_index_router -->|"gets greeting"| node_index_service
node_app -->|"registers handlers"| node_error_handler
node_app -->|"adds security"| node_security
node_app -->|"adds logging"| node_request_logging
node_app -->|"configures limits"| node_limiter
node_db_session -->|"opens sessions"| node_database

click node_app "https://github.com/thehimel/learning-platform-api/blob/main/app/main.py"
click node_api_router "https://github.com/thehimel/learning-platform-api/blob/main/app/api/router.py"
click node_auth_router "https://github.com/thehimel/learning-platform-api/blob/main/app/auth/router.py"
click node_auth_backend "https://github.com/thehimel/learning-platform-api/blob/main/app/auth/backend.py"
click node_user_router "https://github.com/thehimel/learning-platform-api/blob/main/app/users/router.py"
click node_user_manager "https://github.com/thehimel/learning-platform-api/blob/main/app/users/manager.py"
click node_course_router "https://github.com/thehimel/learning-platform-api/blob/main/app/courses/router.py"
click node_course_service "https://github.com/thehimel/learning-platform-api/blob/main/app/courses/service.py"
click node_course_repo "https://github.com/thehimel/learning-platform-api/blob/main/app/courses/repository.py"
click node_rating_worker "https://github.com/thehimel/learning-platform-api/blob/main/app/courses/router.py"
click node_course_models "https://github.com/thehimel/learning-platform-api/blob/main/app/courses/models.py"
click node_health_router "https://github.com/thehimel/learning-platform-api/blob/main/app/health/router.py"
click node_health_service "https://github.com/thehimel/learning-platform-api/blob/main/app/health/service.py"
click node_index_router "https://github.com/thehimel/learning-platform-api/blob/main/app/index/router.py"
click node_index_service "https://github.com/thehimel/learning-platform-api/blob/main/app/index/service.py"
click node_error_handler "https://github.com/thehimel/learning-platform-api/blob/main/app/infra/common/exception_handler.py"
click node_security "https://github.com/thehimel/learning-platform-api/blob/main/app/infra/common/setup_security.py"
click node_request_logging "https://github.com/thehimel/learning-platform-api/blob/main/app/infra/common/setup_request_logging.py"
click node_limiter "https://github.com/thehimel/learning-platform-api/blob/main/app/infra/limiter/limiter.py"
click node_db_session "https://github.com/thehimel/learning-platform-api/blob/main/app/infra/database/database.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_api_router,node_client toneBlue
class node_auth_router,node_auth_backend,node_user_router,node_user_manager,node_database toneAmber
class node_course_router,node_course_service,node_course_repo,node_rating_worker,node_course_models toneMint
class node_health_router,node_health_service,node_index_router,node_index_service,node_error_handler,node_security,node_request_logging,node_limiter,node_db_session toneRose
```

## Components

### API Entry

- [FastAPI App](https://github.com/thehimel/learning-platform-api/blob/main/app/main.py): `app/main.py`
- [API Router](https://github.com/thehimel/learning-platform-api/blob/main/app/api/router.py): `app/api/router.py`

### Identity

- [Auth Router](https://github.com/thehimel/learning-platform-api/blob/main/app/auth/router.py): `app/auth/router.py`
- [JWT Backend](https://github.com/thehimel/learning-platform-api/blob/main/app/auth/backend.py): `app/auth/backend.py`
- [User Router](https://github.com/thehimel/learning-platform-api/blob/main/app/users/router.py): `app/users/router.py`
- [User Manager](https://github.com/thehimel/learning-platform-api/blob/main/app/users/manager.py): `app/users/manager.py`

### Learning Domain

- [Course Router](https://github.com/thehimel/learning-platform-api/blob/main/app/courses/router.py): `app/courses/router.py`
- [Course Service](https://github.com/thehimel/learning-platform-api/blob/main/app/courses/service.py): `app/courses/service.py`
- [Course Repository](https://github.com/thehimel/learning-platform-api/blob/main/app/courses/repository.py): `app/courses/repository.py`
- [Rating Worker](https://github.com/thehimel/learning-platform-api/blob/main/app/courses/router.py): `app/courses/router.py`
- [Course Models](https://github.com/thehimel/learning-platform-api/blob/main/app/courses/models.py): `app/courses/models.py`

### Platform Services

- [Health Router](https://github.com/thehimel/learning-platform-api/blob/main/app/health/router.py): `app/health/router.py`
- [Health Service](https://github.com/thehimel/learning-platform-api/blob/main/app/health/service.py): `app/health/service.py`
- [Root Router](https://github.com/thehimel/learning-platform-api/blob/main/app/index/router.py): `app/index/router.py`
- [Root Service](https://github.com/thehimel/learning-platform-api/blob/main/app/index/service.py): `app/index/service.py`
- [Error Handler](https://github.com/thehimel/learning-platform-api/blob/main/app/infra/common/exception_handler.py): `app/infra/common/exception_handler.py`
- [Security Middleware](https://github.com/thehimel/learning-platform-api/blob/main/app/infra/common/setup_security.py): `app/infra/common/setup_security.py`
- [Request Logging](https://github.com/thehimel/learning-platform-api/blob/main/app/infra/common/setup_request_logging.py): `app/infra/common/setup_request_logging.py`
- [Rate Limiter](https://github.com/thehimel/learning-platform-api/blob/main/app/infra/limiter/limiter.py): `app/infra/limiter/limiter.py`
- [Async DB Session](https://github.com/thehimel/learning-platform-api/blob/main/app/infra/database/database.py): `app/infra/database/database.py`

### Other components

- **API Client**
- **PostgreSQL**

## Connections

- API Client → FastAPI App: sends requests
- FastAPI App → API Router: includes routes
- API Router → Auth Router: includes routes
- API Router → User Router: includes routes
- API Router → Course Router: includes routes
- FastAPI App → Health Router: includes routes
- FastAPI App → Root Router: includes routes
- Auth Router → JWT Backend: dispatches auth
- User Router → User Manager: manages users
- User Manager → PostgreSQL: reads/writes users
- Course Router → Course Service: dispatches courses
- Course Service → Course Repository: executes domain logic
- Course Repository → Course Models: queries models
- Course Repository → PostgreSQL: reads/writes data
- Course Router → Rating Worker: schedules rating
- Rating Worker → Course Service: recomputes rating
- Health Router → Health Service: checks health
- Root Router → Root Service: gets greeting
- FastAPI App → Error Handler: registers handlers
- FastAPI App → Security Middleware: adds security
- FastAPI App → Request Logging: adds logging
- FastAPI App → Rate Limiter: configures limits
- Async DB Session → PostgreSQL: opens sessions
