# davfilsdev/zenithai-backend architecture

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

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

## Overview

Zenith AI is a Django REST API for account management and persistent AI conversations. Users register or obtain JWTs, then manage conversations or submit a message; the chat endpoint creates or finds the conversation, saves the user message, and uses Gemini to generate a reply. The README also documents profile, conversation CRUD, and OpenAPI/Swagger/ReDoc capabilities. Edges follow shown imports and route declarations or documented API behavior; database persistence and settings wiring are not fully visible in the excerpts.

Main entry points: [`chat/views.py`](https://github.com/davfilsdev/zenithai-backend/blob/main/chat/views.py) (Conversation and chat API), [`chat/models.py`](https://github.com/davfilsdev/zenithai-backend/blob/main/chat/models.py) (Conversation and message data), [`chat/services.py`](https://github.com/davfilsdev/zenithai-backend/blob/main/chat/services.py) (Gemini service), [`users/urls.py`](https://github.com/davfilsdev/zenithai-backend/blob/main/users/urls.py) (User routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_user_routes["User routes<br/>[urls.py]"]
  node_chat_routes["Chat routes<br/>[urls.py]"]
  node_schema_docs["API schema and docs<br/>[urls.py]"]
end

subgraph group_accounts["Accounts"]
  node_account_api["Registration, tokens, profile<br/>[views.py]"]
  node_account_serializers["Account serializers<br/>[serializers.py]"]
  node_user_data[("User and profile data<br/>[models.py]")]
end

subgraph group_chat["Conversations and chat"]
  node_chat_api["Conversation and chat API<br/>[views.py]"]
  node_chat_serializers["Conversation and message serializers<br/>[serializers.py]"]
  node_chat_data[("Conversation and message data<br/>[models.py]")]
end

subgraph group_runtime["Runtime services"]
  node_gemini_service["Gemini service<br/>[services.py]"]
  node_settings["Django settings<br/>[settings.py]"]
end

node_frontend(("Frontend client"))
node_gemini{{"Google Gemini"}}
node_postgres[("PostgreSQL")]

node_frontend -->|"calls auth API"| node_user_routes
node_frontend -->|"calls chat API"| node_chat_routes
node_user_routes -->|"routes to"| node_account_api
node_chat_routes -->|"routes to"| node_chat_api
node_account_api -->|"uses"| node_account_serializers
node_chat_api -->|"uses"| node_chat_serializers
node_chat_api -->|"reads and writes"| node_chat_data
node_chat_api -->|"requests generation"| node_gemini_service
node_gemini_service -->|"generates content"| node_gemini
node_chat_data -->|"references user"| node_user_data
node_chat_data -.-> node_postgres
node_user_data -.-> node_postgres
node_settings -.->|"configures key and model"| node_gemini_service
node_frontend -->|"views API docs"| node_schema_docs

click node_user_routes "https://github.com/davfilsdev/zenithai-backend/blob/main/users/urls.py"
click node_chat_routes "https://github.com/davfilsdev/zenithai-backend/blob/main/chat/urls.py"
click node_schema_docs "https://github.com/davfilsdev/zenithai-backend/blob/main/backend/urls.py"
click node_account_api "https://github.com/davfilsdev/zenithai-backend/blob/main/users/views.py"
click node_account_serializers "https://github.com/davfilsdev/zenithai-backend/blob/main/users/serializers.py"
click node_user_data "https://github.com/davfilsdev/zenithai-backend/blob/main/users/models.py"
click node_chat_api "https://github.com/davfilsdev/zenithai-backend/blob/main/chat/views.py"
click node_chat_serializers "https://github.com/davfilsdev/zenithai-backend/blob/main/chat/serializers.py"
click node_chat_data "https://github.com/davfilsdev/zenithai-backend/blob/main/chat/models.py"
click node_gemini_service "https://github.com/davfilsdev/zenithai-backend/blob/main/chat/services.py"
click node_settings "https://github.com/davfilsdev/zenithai-backend/blob/main/backend/settings.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_user_routes,node_chat_routes,node_schema_docs,node_frontend toneBlue
class node_account_api,node_account_serializers,node_user_data,node_postgres toneAmber
class node_chat_api,node_chat_serializers,node_chat_data toneMint
class node_gemini_service,node_settings toneRose
class node_gemini toneIndigo
```

## Components

### API routing

- [User routes](https://github.com/davfilsdev/zenithai-backend/blob/main/users/urls.py): `users/urls.py`
- [Chat routes](https://github.com/davfilsdev/zenithai-backend/blob/main/chat/urls.py): `chat/urls.py`
- [API schema and docs](https://github.com/davfilsdev/zenithai-backend/blob/main/backend/urls.py): `backend/urls.py`

### Accounts

- [Registration, tokens, profile](https://github.com/davfilsdev/zenithai-backend/blob/main/users/views.py): `users/views.py`
- [Account serializers](https://github.com/davfilsdev/zenithai-backend/blob/main/users/serializers.py): `users/serializers.py`
- [User and profile data](https://github.com/davfilsdev/zenithai-backend/blob/main/users/models.py): `users/models.py`

### Conversations and chat

- [Conversation and chat API](https://github.com/davfilsdev/zenithai-backend/blob/main/chat/views.py): `chat/views.py`
- [Conversation and message serializers](https://github.com/davfilsdev/zenithai-backend/blob/main/chat/serializers.py): `chat/serializers.py`
- [Conversation and message data](https://github.com/davfilsdev/zenithai-backend/blob/main/chat/models.py): `chat/models.py`

### Runtime services

- [Gemini service](https://github.com/davfilsdev/zenithai-backend/blob/main/chat/services.py): `chat/services.py`
- [Django settings](https://github.com/davfilsdev/zenithai-backend/blob/main/backend/settings.py): `backend/settings.py`

### Other components

- **Frontend client**
- **Google Gemini**
- **PostgreSQL**

## Connections

- Frontend client → User routes: calls auth API (evidence: `README.md`)
- Frontend client → Chat routes: calls chat API (evidence: `README.md`)
- User routes → Registration, tokens, profile: routes to (evidence: `users/urls.py`)
- Chat routes → Conversation and chat API: routes to (evidence: `chat/urls.py`)
- Registration, tokens, profile → Account serializers: uses (evidence: `users/views.py`)
- Conversation and chat API → Conversation and message serializers: uses (evidence: `chat/views.py`)
- Conversation and chat API → Conversation and message data: reads and writes (evidence: `chat/views.py`)
- Conversation and chat API → Gemini service: requests generation (evidence: `chat/views.py`)
- Gemini service → Google Gemini: generates content (evidence: `chat/services.py`)
- Conversation and message data → User and profile data: references user (evidence: `chat/models.py`)
- Conversation and message data → PostgreSQL
- User and profile data → PostgreSQL
- Django settings → Gemini service: configures key and model
- Frontend client → API schema and docs: views API docs (evidence: `README.md`)
