# akhzari-itshield/socialapp-serverfull architecture

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

- Interactive diagram: https://gitdiagram.com/akhzari-itshield/socialapp-serverfull
- Repository: https://github.com/akhzari-itshield/socialapp-serverfull

## Overview

SocialApp Server is a FastAPI social-messaging backend. A client requests an OTP, verifies it to obtain a JWT, then uses authenticated APIs for profiles, chats, messages, files, and folders; WebSockets support live messaging, presence, and call signaling. Admin APIs and a Jinja-based web panel provide user, chat, and system management. The graph includes documented capabilities whose router implementations were not sampled; those links are documented or left unasserted. Evidence for unsampled modules is limited to the source index and README.

Main entry points: [`database.py`](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/database.py) (DB sessions), [`main.py`](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/main.py) (FastAPI app), [`routers/auth_router.py`](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/auth_router.py) (OTP endpoints), [`auth.py`](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/auth.py) (JWT and user auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_main["FastAPI app<br/>[main.py]"]
  node_settings["Settings<br/>[config.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
  node_database["DB sessions<br/>[database.py]"]
  node_models["Domain records<br/>[models.py]"]
  node_dbstore[("SQL database")]
end

subgraph group_identity["Identity and access"]
  node_authroutes["OTP endpoints<br/>[auth_router.py]"]
  node_authcore["JWT and user auth<br/>[auth.py]"]
  node_users["User profiles<br/>[users_router.py]"]
end

subgraph group_messaging["Messaging"]
  node_chats["Chats and membership<br/>[chats_router.py]"]
  node_messages["Messages<br/>[messages_router.py]"]
  node_folders["Chat folders<br/>[folders_router.py]"]
end

subgraph group_realtime["Realtime and calls"]
  node_calls["Call sessions<br/>[calls_router.py]"]
  node_wsroutes["WebSocket routes<br/>[ws_router.py]"]
  node_wsmanager["Connection manager<br/>[ws_manager.py]"]
end

subgraph group_operations["Files and management"]
  node_files["Files and media<br/>[files_router.py]"]
  node_admin["Admin API<br/>[admin_router.py]"]
  node_panel["Web admin panel<br/>[panel_router.py]"]
  node_templates["Panel templates"]
end

node_client(("Clients"))
node_sms(("SMS provider"))

node_client -->|"sends requests"| node_main
node_main -->|"registers"| node_authroutes
node_main -->|"registers"| node_users
node_main -->|"registers"| node_chats
node_main -->|"registers"| node_messages
node_main -->|"registers"| node_files
node_main -->|"registers"| node_calls
node_main -->|"registers"| node_wsroutes
node_main -->|"registers"| node_admin
node_main -->|"registers"| node_panel
node_main -->|"registers"| node_folders
node_main -->|"creates tables"| node_database
node_database -->|"reads config"| node_settings
node_database -->|"connects"| node_dbstore
node_models -->|"uses base"| node_database
node_authroutes -->|"generates token"| node_authcore
node_authroutes -->|"queries records"| node_database
node_authroutes -->|"reads OTP expiry"| node_settings
node_authroutes -->|"validates input"| node_schemas
node_authroutes -.->|"would send OTP"| node_sms
node_users -->|"requires user auth"| node_authcore
node_users -->|"queries records"| node_database
node_users -->|"reads upload config"| node_settings
node_chats -->|"requires user auth"| node_authcore
node_chats -->|"queries records"| node_database
node_chats -->|"checks presence"| node_wsmanager
node_messages -->|"requires user auth"| node_authcore
node_messages -->|"stores and reads"| node_database
node_messages -->|"dispatches events"| node_wsmanager
node_folders -->|"queries records"| node_database
node_folders -->|"requires user auth"| node_authcore
node_files -->|"stores metadata"| node_database
node_files -->|"reads upload config"| node_settings
node_calls -->|"records sessions"| node_database
node_calls -->|"requires user auth"| node_authcore
node_wsroutes -->|"manages connections"| node_wsmanager
node_wsroutes -->|"queries records"| node_database
node_wsroutes -.->|"signals WebRTC"| node_client
node_admin -->|"queries records"| node_database
node_admin -->|"reads config"| node_settings
node_admin -->|"broadcasts messages"| node_wsmanager
node_panel -->|"queries records"| node_database
node_panel -.->|"renders pages"| node_templates
node_client -.->|"uses admin UI"| node_panel

click node_main "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/main.py"
click node_settings "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/config.py"
click node_schemas "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/schemas.py"
click node_database "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/database.py"
click node_models "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/models.py"
click node_authroutes "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/auth_router.py"
click node_authcore "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/auth.py"
click node_users "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/users_router.py"
click node_chats "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/chats_router.py"
click node_messages "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/messages_router.py"
click node_folders "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/folders_router.py"
click node_files "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/files_router.py"
click node_calls "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/calls_router.py"
click node_wsroutes "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/ws_router.py"
click node_wsmanager "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/ws_manager.py"
click node_admin "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/admin_router.py"
click node_panel "https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/panel_router.py"
click node_templates "https://github.com/akhzari-itshield/socialapp-serverfull/tree/main/templates"

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_main,node_settings,node_schemas,node_database,node_models,node_dbstore,node_client toneBlue
class node_authroutes,node_authcore,node_users toneAmber
class node_chats,node_messages,node_folders toneMint
class node_calls,node_wsroutes,node_wsmanager toneRose
class node_files,node_admin,node_panel,node_templates,node_sms toneIndigo
```

## Components

### API entry

- [FastAPI app](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/main.py): `main.py`
- [Settings](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/config.py): `config.py`
- [API schemas](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/schemas.py): `schemas.py`
- [DB sessions](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/database.py): `database.py`
- [Domain records](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/models.py): `models.py`
- **SQL database**

### Identity and access

- [OTP endpoints](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/auth_router.py): `routers/auth_router.py`
- [JWT and user auth](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/auth.py): `auth.py`
- [User profiles](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/users_router.py): `routers/users_router.py`

### Messaging

- [Chats and membership](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/chats_router.py): `routers/chats_router.py`
- [Messages](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/messages_router.py): `routers/messages_router.py`
- [Chat folders](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/folders_router.py): `routers/folders_router.py`

### Realtime and calls

- [Call sessions](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/calls_router.py): `routers/calls_router.py`
- [WebSocket routes](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/ws_router.py): `routers/ws_router.py`
- [Connection manager](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/ws_manager.py): `ws_manager.py`

### Files and management

- [Files and media](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/files_router.py): `routers/files_router.py`
- [Admin API](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/admin_router.py): `routers/admin_router.py`
- [Web admin panel](https://github.com/akhzari-itshield/socialapp-serverfull/blob/main/routers/panel_router.py): `routers/panel_router.py`
- [Panel templates](https://github.com/akhzari-itshield/socialapp-serverfull/tree/main/templates): `templates`

### Other components

- **Clients**
- **SMS provider**

## Connections

- Clients → FastAPI app: sends requests (evidence: `readme.md`)
- FastAPI app → OTP endpoints: registers (evidence: `main.py`)
- FastAPI app → User profiles: registers (evidence: `main.py`)
- FastAPI app → Chats and membership: registers (evidence: `main.py`)
- FastAPI app → Messages: registers (evidence: `main.py`)
- FastAPI app → Files and media: registers (evidence: `main.py`)
- FastAPI app → Call sessions: registers (evidence: `main.py`)
- FastAPI app → WebSocket routes: registers (evidence: `main.py`)
- FastAPI app → Admin API: registers (evidence: `main.py`)
- FastAPI app → Web admin panel: registers (evidence: `main.py`)
- FastAPI app → Chat folders: registers (evidence: `main.py`)
- FastAPI app → DB sessions: creates tables (evidence: `main.py`)
- DB sessions → Settings: reads config (evidence: `database.py`)
- DB sessions → SQL database: connects (evidence: `database.py`)
- Domain records → DB sessions: uses base (evidence: `models.py`)
- OTP endpoints → JWT and user auth: generates token (evidence: `routers/auth_router.py`)
- OTP endpoints → DB sessions: queries records (evidence: `routers/auth_router.py`)
- OTP endpoints → Settings: reads OTP expiry (evidence: `routers/auth_router.py`)
- OTP endpoints → API schemas: validates input (evidence: `routers/auth_router.py`)
- OTP endpoints → SMS provider: would send OTP (evidence: `routers/auth_router.py`)
- User profiles → JWT and user auth: requires user auth (evidence: `routers/users_router.py`)
- User profiles → DB sessions: queries records (evidence: `routers/users_router.py`)
- User profiles → Settings: reads upload config (evidence: `routers/users_router.py`)
- Chats and membership → JWT and user auth: requires user auth (evidence: `routers/chats_router.py`)
- Chats and membership → DB sessions: queries records (evidence: `routers/chats_router.py`)
- Chats and membership → Connection manager: checks presence (evidence: `routers/chats_router.py`)
- Messages → JWT and user auth: requires user auth (evidence: `routers/messages_router.py`)
- Messages → DB sessions: stores and reads (evidence: `routers/messages_router.py`)
- Messages → Connection manager: dispatches events (evidence: `routers/messages_router.py`)
- Chat folders → DB sessions: queries records (evidence: `routers/folders_router.py`)
- Chat folders → JWT and user auth: requires user auth (evidence: `routers/folders_router.py`)
- Files and media → DB sessions: stores metadata (evidence: `routers/files_router.py`)
- Files and media → Settings: reads upload config (evidence: `routers/files_router.py`)
- Call sessions → DB sessions: records sessions (evidence: `routers/calls_router.py`)
- Call sessions → JWT and user auth: requires user auth (evidence: `routers/calls_router.py`)
- WebSocket routes → Connection manager: manages connections (evidence: `routers/ws_router.py`)
- WebSocket routes → DB sessions: queries records (evidence: `routers/ws_router.py`)
- WebSocket routes → Clients: signals WebRTC (evidence: `readme.md`)
- Admin API → DB sessions: queries records (evidence: `routers/admin_router.py`)
- Admin API → Settings: reads config (evidence: `routers/admin_router.py`)
- Admin API → Connection manager: broadcasts messages (evidence: `routers/admin_router.py`)
- Web admin panel → DB sessions: queries records (evidence: `routers/panel_router.py`)
- Web admin panel → Panel templates: renders pages (evidence: `readme.md`)
- Clients → Web admin panel: uses admin UI (evidence: `readme.md`)
