# revaldo007/real-time architecture

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

- Interactive diagram: https://gitdiagram.com/revaldo007/real-time
- Repository: https://github.com/revaldo007/real-time

## Overview

Rivo is a real-time chat product with a React client and FastAPI backend. Users authenticate, then access chats, manage groups and messages, and communicate over a WebSocket; the client also exposes profile and appearance settings. The graph follows the visible client routing and API calls into backend routers, services, and persisted domain models. Some routes and integrations are listed but not excerpted, so uncertain runtime connections are omitted.

Main entry points: [`backend/app/main.py`](https://github.com/revaldo007/real-time/blob/main/backend/app/main.py) (FastAPI application), [`frontend/src/services/api.js`](https://github.com/revaldo007/real-time/blob/main/frontend/src/services/api.js) (HTTP API client), [`backend/app/routers/auth.py`](https://github.com/revaldo007/real-time/blob/main/backend/app/routers/auth.py) (Auth routes), [`frontend/src/App.jsx`](https://github.com/revaldo007/real-time/blob/main/frontend/src/App.jsx) (Application routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Application routes<br/>[App.jsx]"]
  node_theme["Appearance settings<br/>[ThemeContext.jsx]"]
  node_api_client["HTTP API client<br/>[api.js]"]
end

subgraph group_identity["Identity and profile"]
  node_auth_ui["Auth state<br/>[AuthContext.jsx]"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_user_routes["User routes<br/>[users.py]"]
  node_auth_service["Authentication service<br/>[auth_service.py]"]
  node_otp_service["Email OTP service<br/>[otp_service.py]"]
end

subgraph group_messaging["Chat and messaging"]
  node_chat_ui["Chat state<br/>[ChatContext.jsx]"]
  node_chat_page["Chat interface<br/>[Chat.jsx]"]
  node_chat_routes["Chat routes<br/>[chats.py]"]
  node_group_routes["Group routes<br/>[groups.py]"]
  node_message_routes["Message routes<br/>[messages.py]"]
  node_chat_service["Chat service<br/>[chat_service.py]"]
  node_message_service["Message service<br/>[message_service.py]"]
  node_socket_manager["WebSocket manager<br/>[chat_socket.py]"]
end

subgraph group_backend["Backend API"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_media_routes["Media routes<br/>[media.py]"]
  node_schemas["Request and response schemas"]
end

subgraph group_data["Persistence"]
  node_models["Domain models"]
  node_database[("SQL database<br/>[connection.py]")]
end

node_user(("Chat user"))

node_user -->|"uses"| node_app
node_app -->|"provides"| node_auth_ui
node_app -->|"provides"| node_theme
node_app -->|"routes to"| node_chat_page
node_auth_ui -->|"requests"| node_api_client
node_chat_ui -->|"requests"| node_api_client
node_chat_page -->|"uses"| node_chat_ui
node_user -->|"authenticates"| node_auth_ui
node_api_client -->|"calls"| node_auth_routes
node_api_client -->|"calls"| node_user_routes
node_api_client -->|"calls"| node_chat_routes
node_api_client -->|"calls"| node_group_routes
node_api_client -->|"calls"| node_message_routes
node_api_client -->|"calls"| node_media_routes
node_api_app -->|"registers"| node_auth_routes
node_api_app -->|"registers"| node_user_routes
node_api_app -->|"registers"| node_chat_routes
node_api_app -->|"registers"| node_group_routes
node_api_app -->|"registers"| node_message_routes
node_api_app -->|"registers"| node_media_routes
node_auth_routes -->|"delegates"| node_auth_service
node_auth_routes -->|"requests OTP"| node_otp_service
node_chat_routes -->|"delegates"| node_chat_service
node_group_routes -->|"delegates"| node_chat_service
node_message_routes -->|"delegates"| node_message_service
node_api_app -->|"dispatches events"| node_socket_manager
node_auth_service -->|"queries users"| node_models
node_chat_service -->|"manages chats"| node_models
node_message_service -->|"manages messages"| node_models
node_auth_routes -->|"validates"| node_schemas
node_chat_routes -->|"validates"| node_schemas
node_message_routes -->|"validates"| node_schemas
node_database -->|"registers tables"| node_models
node_api_app -->|"opens sessions"| node_database

click node_app "https://github.com/revaldo007/real-time/blob/main/frontend/src/App.jsx"
click node_auth_ui "https://github.com/revaldo007/real-time/blob/main/frontend/src/context/AuthContext.jsx"
click node_theme "https://github.com/revaldo007/real-time/blob/main/frontend/src/context/ThemeContext.jsx"
click node_chat_ui "https://github.com/revaldo007/real-time/blob/main/frontend/src/context/ChatContext.jsx"
click node_chat_page "https://github.com/revaldo007/real-time/blob/main/frontend/src/pages/Chat.jsx"
click node_api_client "https://github.com/revaldo007/real-time/blob/main/frontend/src/services/api.js"
click node_api_app "https://github.com/revaldo007/real-time/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/revaldo007/real-time/blob/main/backend/app/routers/auth.py"
click node_user_routes "https://github.com/revaldo007/real-time/blob/main/backend/app/routers/users.py"
click node_chat_routes "https://github.com/revaldo007/real-time/blob/main/backend/app/routers/chats.py"
click node_group_routes "https://github.com/revaldo007/real-time/blob/main/backend/app/routers/groups.py"
click node_message_routes "https://github.com/revaldo007/real-time/blob/main/backend/app/routers/messages.py"
click node_media_routes "https://github.com/revaldo007/real-time/blob/main/backend/app/routers/media.py"
click node_auth_service "https://github.com/revaldo007/real-time/blob/main/backend/app/services/auth_service.py"
click node_otp_service "https://github.com/revaldo007/real-time/blob/main/backend/app/services/otp_service.py"
click node_chat_service "https://github.com/revaldo007/real-time/blob/main/backend/app/services/chat_service.py"
click node_message_service "https://github.com/revaldo007/real-time/blob/main/backend/app/services/message_service.py"
click node_socket_manager "https://github.com/revaldo007/real-time/blob/main/backend/app/websocket/chat_socket.py"
click node_schemas "https://github.com/revaldo007/real-time/tree/main/backend/app/schemas"
click node_models "https://github.com/revaldo007/real-time/tree/main/backend/app/models"
click node_database "https://github.com/revaldo007/real-time/blob/main/backend/app/database/connection.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_theme,node_api_client,node_user toneBlue
class node_auth_ui,node_auth_routes,node_user_routes,node_auth_service,node_otp_service toneAmber
class node_chat_ui,node_chat_page,node_chat_routes,node_group_routes,node_message_routes,node_chat_service,node_message_service,node_socket_manager toneMint
class node_api_app,node_media_routes,node_schemas toneRose
class node_models,node_database toneIndigo
```

## Components

### Web client

- [Application routes](https://github.com/revaldo007/real-time/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Appearance settings](https://github.com/revaldo007/real-time/blob/main/frontend/src/context/ThemeContext.jsx): `frontend/src/context/ThemeContext.jsx`
- [HTTP API client](https://github.com/revaldo007/real-time/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Identity and profile

- [Auth state](https://github.com/revaldo007/real-time/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Auth routes](https://github.com/revaldo007/real-time/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [User routes](https://github.com/revaldo007/real-time/blob/main/backend/app/routers/users.py): `backend/app/routers/users.py`
- [Authentication service](https://github.com/revaldo007/real-time/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [Email OTP service](https://github.com/revaldo007/real-time/blob/main/backend/app/services/otp_service.py): `backend/app/services/otp_service.py`

### Chat and messaging

- [Chat state](https://github.com/revaldo007/real-time/blob/main/frontend/src/context/ChatContext.jsx): `frontend/src/context/ChatContext.jsx`
- [Chat interface](https://github.com/revaldo007/real-time/blob/main/frontend/src/pages/Chat.jsx): `frontend/src/pages/Chat.jsx`
- [Chat routes](https://github.com/revaldo007/real-time/blob/main/backend/app/routers/chats.py): `backend/app/routers/chats.py`
- [Group routes](https://github.com/revaldo007/real-time/blob/main/backend/app/routers/groups.py): `backend/app/routers/groups.py`
- [Message routes](https://github.com/revaldo007/real-time/blob/main/backend/app/routers/messages.py): `backend/app/routers/messages.py`
- [Chat service](https://github.com/revaldo007/real-time/blob/main/backend/app/services/chat_service.py): `backend/app/services/chat_service.py`
- [Message service](https://github.com/revaldo007/real-time/blob/main/backend/app/services/message_service.py): `backend/app/services/message_service.py`
- [WebSocket manager](https://github.com/revaldo007/real-time/blob/main/backend/app/websocket/chat_socket.py): `backend/app/websocket/chat_socket.py`

### Backend API

- [FastAPI application](https://github.com/revaldo007/real-time/blob/main/backend/app/main.py): `backend/app/main.py`
- [Media routes](https://github.com/revaldo007/real-time/blob/main/backend/app/routers/media.py): `backend/app/routers/media.py`
- [Request and response schemas](https://github.com/revaldo007/real-time/tree/main/backend/app/schemas): `backend/app/schemas`

### Persistence

- [Domain models](https://github.com/revaldo007/real-time/tree/main/backend/app/models): `backend/app/models`
- [SQL database](https://github.com/revaldo007/real-time/blob/main/backend/app/database/connection.py): `backend/app/database/connection.py`

### Other components

- **Chat user**

## Connections

- Chat user → Application routes: uses
- Application routes → Auth state: provides (evidence: `frontend/src/App.jsx`)
- Application routes → Appearance settings: provides (evidence: `frontend/src/App.jsx`)
- Application routes → Chat interface: routes to (evidence: `frontend/src/App.jsx`)
- Auth state → HTTP API client: requests (evidence: `frontend/src/context/AuthContext.jsx`)
- Chat state → HTTP API client: requests (evidence: `frontend/src/context/ChatContext.jsx`)
- Chat interface → Chat state: uses (evidence: `frontend/src/pages/Chat.jsx`)
- Chat user → Auth state: authenticates
- HTTP API client → Auth routes: calls (evidence: `frontend/src/services/api.js`)
- HTTP API client → User routes: calls (evidence: `frontend/src/services/api.js`)
- HTTP API client → Chat routes: calls (evidence: `frontend/src/services/api.js`)
- HTTP API client → Group routes: calls (evidence: `frontend/src/services/api.js`)
- HTTP API client → Message routes: calls (evidence: `frontend/src/services/api.js`)
- HTTP API client → Media routes: calls (evidence: `frontend/src/services/api.js`)
- FastAPI application → Auth routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → User routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Chat routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Group routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Message routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Media routes: registers (evidence: `backend/app/main.py`)
- Auth routes → Authentication service: delegates (evidence: `backend/app/routers/auth.py`)
- Auth routes → Email OTP service: requests OTP (evidence: `backend/app/routers/auth.py`)
- Chat routes → Chat service: delegates (evidence: `backend/app/routers/chats.py`)
- Group routes → Chat service: delegates (evidence: `backend/app/routers/groups.py`)
- Message routes → Message service: delegates (evidence: `backend/app/routers/messages.py`)
- FastAPI application → WebSocket manager: dispatches events (evidence: `backend/app/main.py`)
- Authentication service → Domain models: queries users (evidence: `backend/app/services/auth_service.py`)
- Chat service → Domain models: manages chats (evidence: `backend/app/services/chat_service.py`)
- Message service → Domain models: manages messages (evidence: `backend/app/services/message_service.py`)
- Auth routes → Request and response schemas: validates (evidence: `backend/app/routers/auth.py`)
- Chat routes → Request and response schemas: validates (evidence: `backend/app/routers/chats.py`)
- Message routes → Request and response schemas: validates (evidence: `backend/app/routers/messages.py`)
- SQL database → Domain models: registers tables (evidence: `backend/app/database/connection.py`)
- FastAPI application → SQL database: opens sessions (evidence: `backend/app/main.py`)
