# w1ldmaster/backend_part_spa architecture

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

- Interactive diagram: https://gitdiagram.com/w1ldmaster/backend_part_spa
- Repository: https://github.com/w1ldmaster/backend_part_spa

## Overview

This is a FastAPI/PostgreSQL social-network API. Its main workflow serves post, follow-feed, profile, group, and comment requests through routers, services, and repositories to persistent data, with schemas shaping API responses. Authentication is a separate JWT/user-management branch. The README documents additional account and social features; unsampled wiring is included only where documentation or indexed references support it. Edges reflect shown calls or documented layers; the excerpt does not expose the database driver’s runtime connections.

Main entry points: [`FastApiProject/app/routers/posts_django.py`](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/routers/posts_django.py) (Post and social routes), [`FastApiProject/app/routers/auth_users.py`](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/routers/auth_users.py) (Auth and user routes), [`FastApiProject/app/services/post.py`](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/services/post.py) (Post service), [`FastApiProject/app/services/user.py`](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/services/user.py) (User service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_posts_router["Post and social routes<br/>[posts_django.py]"]
  node_auth_router["Auth and user routes<br/>[auth_users.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
  node_app_entry["API application<br/>[main.py]"]
end

subgraph group_domain["Social features"]
  node_post_service["Post service<br/>[post.py]"]
  node_user_service["User service<br/>[user.py]"]
  node_group_service["Group service<br/>[group.py]"]
end

subgraph group_auth["Identity and auth"]
  node_jwt_auth["JWT authentication<br/>[auth.py]"]
  node_dependencies["Service wiring<br/>[dependencies.py]"]
  node_domain_errors["Domain errors<br/>[exceptions.py]"]
  node_error_handler["Error translation<br/>[utility.py]"]
end

subgraph group_persistence["Persistence"]
  node_post_repo["Post repository<br/>[post.py]"]
  node_user_repo["User repository<br/>[user.py]"]
  node_group_repo["Group repository<br/>[group.py]"]
  node_models["ORM models<br/>[models.py]"]
  node_database["Async sessions<br/>[database.py]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -->|"sends requests"| node_posts_router
node_client -->|"authenticates"| node_auth_router
node_app_entry -->|"registers routes"| node_posts_router
node_app_entry -->|"registers routes"| node_auth_router
node_posts_router -->|"calls"| node_post_service
node_posts_router -->|"calls"| node_user_service
node_posts_router -->|"calls"| node_group_service
node_auth_router -->|"calls"| node_user_service
node_posts_router -->|"validates and formats"| node_schemas
node_auth_router -->|"uses schemas"| node_schemas
node_posts_router -->|"requires active user"| node_jwt_auth
node_auth_router -->|"registers auth flows"| node_jwt_auth
node_post_service -->|"calls"| node_post_repo
node_post_service -->|"looks up group"| node_group_repo
node_user_service -->|"calls"| node_user_repo
node_group_service -->|"calls"| node_group_repo
node_post_service -->|"raises"| node_domain_errors
node_user_service -->|"raises"| node_domain_errors
node_posts_router -->|"translates errors"| node_error_handler
node_auth_router -->|"translates errors"| node_error_handler
node_dependencies -->|"gets session"| node_database
node_dependencies -->|"constructs"| node_post_service
node_dependencies -->|"constructs"| node_user_service
node_dependencies -->|"constructs"| node_group_service
node_post_repo -->|"queries"| node_models
node_user_repo -->|"queries"| node_models
node_group_repo -->|"queries"| node_models
node_models -->|"uses declarative base"| node_database
node_jwt_auth -->|"gets sessions"| node_database
node_jwt_auth -->|"authenticates users"| node_models
node_database -->|"connects via async SQLAlchemy"| node_postgres

click node_posts_router "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/routers/posts_django.py"
click node_auth_router "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/routers/auth_users.py"
click node_schemas "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/schemas.py"
click node_post_service "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/services/post.py"
click node_user_service "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/services/user.py"
click node_group_service "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/services/group.py"
click node_post_repo "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/repositories/post.py"
click node_user_repo "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/repositories/user.py"
click node_group_repo "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/repositories/group.py"
click node_models "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/models.py"
click node_database "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/database.py"
click node_jwt_auth "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/core/auth.py"
click node_dependencies "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/dependencies.py"
click node_domain_errors "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/exceptions.py"
click node_error_handler "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/core/utility.py"
click node_app_entry "https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/main.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_posts_router,node_auth_router,node_schemas,node_app_entry,node_client toneBlue
class node_post_service,node_user_service,node_group_service,node_postgres toneAmber
class node_jwt_auth,node_dependencies,node_domain_errors,node_error_handler toneMint
class node_post_repo,node_user_repo,node_group_repo,node_models,node_database toneRose
```

## Components

### HTTP API

- [Post and social routes](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/routers/posts_django.py): `FastApiProject/app/routers/posts_django.py`
- [Auth and user routes](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/routers/auth_users.py): `FastApiProject/app/routers/auth_users.py`
- [API schemas](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/schemas.py): `FastApiProject/app/schemas.py`
- [API application](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/main.py): `FastApiProject/app/main.py`

### Social features

- [Post service](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/services/post.py): `FastApiProject/app/services/post.py`
- [User service](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/services/user.py): `FastApiProject/app/services/user.py`
- [Group service](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/services/group.py): `FastApiProject/app/services/group.py`

### Identity and auth

- [JWT authentication](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/core/auth.py): `FastApiProject/app/core/auth.py`
- [Service wiring](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/dependencies.py): `FastApiProject/app/dependencies.py`
- [Domain errors](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/exceptions.py): `FastApiProject/app/exceptions.py`
- [Error translation](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/core/utility.py): `FastApiProject/app/core/utility.py`

### Persistence

- [Post repository](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/repositories/post.py): `FastApiProject/app/repositories/post.py`
- [User repository](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/repositories/user.py): `FastApiProject/app/repositories/user.py`
- [Group repository](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/repositories/group.py): `FastApiProject/app/repositories/group.py`
- [ORM models](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/models.py): `FastApiProject/app/models.py`
- [Async sessions](https://github.com/w1ldmaster/backend_part_spa/blob/master/FastApiProject/app/database.py): `FastApiProject/app/database.py`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- API client → Post and social routes: sends requests (evidence: `README.md`)
- API client → Auth and user routes: authenticates (evidence: `README.md`)
- API application → Post and social routes: registers routes (evidence: `FastApiProject/app/main.py`)
- API application → Auth and user routes: registers routes (evidence: `FastApiProject/app/main.py`)
- Post and social routes → Post service: calls (evidence: `FastApiProject/app/routers/posts_django.py`)
- Post and social routes → User service: calls (evidence: `FastApiProject/app/routers/posts_django.py`)
- Post and social routes → Group service: calls (evidence: `FastApiProject/app/routers/posts_django.py`)
- Auth and user routes → User service: calls (evidence: `FastApiProject/app/routers/auth_users.py`)
- Post and social routes → API schemas: validates and formats (evidence: `FastApiProject/app/routers/posts_django.py`)
- Auth and user routes → API schemas: uses schemas (evidence: `FastApiProject/app/routers/auth_users.py`)
- Post and social routes → JWT authentication: requires active user (evidence: `FastApiProject/app/routers/posts_django.py`)
- Auth and user routes → JWT authentication: registers auth flows (evidence: `FastApiProject/app/routers/auth_users.py`)
- Post service → Post repository: calls (evidence: `FastApiProject/app/services/post.py`)
- Post service → Group repository: looks up group (evidence: `FastApiProject/app/services/post.py`)
- User service → User repository: calls (evidence: `FastApiProject/app/services/user.py`)
- Group service → Group repository: calls (evidence: `FastApiProject/app/services/group.py`)
- Post service → Domain errors: raises (evidence: `FastApiProject/app/services/post.py`)
- User service → Domain errors: raises (evidence: `FastApiProject/app/services/user.py`)
- Post and social routes → Error translation: translates errors (evidence: `FastApiProject/app/routers/posts_django.py`)
- Auth and user routes → Error translation: translates errors (evidence: `FastApiProject/app/routers/auth_users.py`)
- Service wiring → Async sessions: gets session (evidence: `FastApiProject/app/dependencies.py`)
- Service wiring → Post service: constructs (evidence: `FastApiProject/app/dependencies.py`)
- Service wiring → User service: constructs (evidence: `FastApiProject/app/dependencies.py`)
- Service wiring → Group service: constructs (evidence: `FastApiProject/app/dependencies.py`)
- Post repository → ORM models: queries (evidence: `FastApiProject/app/repositories/post.py`)
- User repository → ORM models: queries (evidence: `FastApiProject/app/repositories/user.py`)
- Group repository → ORM models: queries (evidence: `FastApiProject/app/repositories/group.py`)
- ORM models → Async sessions: uses declarative base (evidence: `FastApiProject/app/models.py`)
- JWT authentication → Async sessions: gets sessions (evidence: `FastApiProject/app/core/auth.py`)
- JWT authentication → ORM models: authenticates users (evidence: `FastApiProject/app/core/auth.py`)
- Async sessions → PostgreSQL: connects via async SQLAlchemy (evidence: `README.md`)
