# santhosh-ek2007-zen/sanchat architecture

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

- Interactive diagram: https://gitdiagram.com/santhosh-ek2007-zen/sanchat
- Repository: https://github.com/santhosh-ek2007-zen/sanchat

## Overview

SanChat is a Django backend for authenticated chat: REST endpoints register users, issue/manage JWTs, and create or retrieve conversations and messages. Its WebSocket path currently authenticates a connection and confirms it; the sampled consumer does not yet implement message exchange. The map separates REST, identity, chat data, and WebSocket handling. It reflects the documented roadmap while distinguishing implemented REST behavior from in-progress real-time messaging; unsampled configuration and storage wiring are not inferred.

Main entry points: [`backend/config/chats/views.py`](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/views.py) (Chat Views), [`backend/config/chats/serializers.py`](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/serializers.py) (Chat Serializers), [`backend/config/users/urls.py`](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/users/urls.py) (User Routes), [`backend/config/users/views.py`](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/users/views.py) (Identity Views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity"]
  node_user_routes["User Routes<br/>[urls.py]"]
  node_user_views["Identity Views<br/>[views.py]"]
  node_register_serializer["Registration Serializer<br/>[serializers.py]"]
  node_jwt_service["JWT Provider"]
  node_user_model["User Model<br/>[models.py]"]
end

subgraph group_rest["REST API"]
  node_chat_routes["Chat Routes<br/>[urls.py]"]
  node_chat_views["Chat Views<br/>[views.py]"]
  node_chat_serializers["Chat Serializers<br/>[serializers.py]"]
end

subgraph group_chatdata["Chat Data"]
  node_conversation_model["Conversation Model<br/>[models.py]"]
  node_message_model["Message Model<br/>[models.py]"]
  node_database[("Relational Database")]
end

subgraph group_websocket["WebSocket"]
  node_asgi["ASGI Application<br/>[asgi.py]"]
  node_ws_auth["JWT Socket Auth<br/>[middleware.py]"]
  node_ws_routes["Socket Routes<br/>[routing.py]"]
  node_consumer["Chat Consumer<br/>[consumers.py]"]
end

node_client(("Chat Client"))
node_restclient(("REST Client"))
node_wsclient(("WebSocket Client"))

node_client -->|"uses"| node_restclient
node_restclient -->|"requests"| node_user_routes
node_restclient -->|"requests"| node_chat_routes
node_user_routes -->|"routes to"| node_user_views
node_user_views -->|"validates registration"| node_register_serializer
node_register_serializer -->|"creates"| node_user_model
node_user_views -->|"issues and revokes"| node_jwt_service
node_user_routes -->|"routes token requests"| node_jwt_service
node_chat_routes -->|"routes to"| node_chat_views
node_chat_views -->|"serializes"| node_chat_serializers
node_chat_views -->|"queries and saves"| node_conversation_model
node_chat_views -->|"queries and saves"| node_message_model
node_chat_serializers -->|"represents"| node_conversation_model
node_chat_serializers -->|"represents"| node_message_model
node_chat_serializers -->|"serializes participants"| node_user_model
node_conversation_model -.->|"persists"| node_database
node_message_model -.->|"persists"| node_database
node_client -.->|"connects"| node_wsclient
node_wsclient -->|"opens socket"| node_asgi
node_asgi -->|"wraps WebSocket"| node_ws_auth
node_asgi -->|"routes WebSocket"| node_ws_routes
node_ws_auth -->|"resolves token user"| node_user_model
node_ws_routes -->|"dispatches to"| node_consumer

click node_user_routes "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/users/urls.py"
click node_user_views "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/users/views.py"
click node_register_serializer "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/users/serializers.py"
click node_user_model "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/users/models.py"
click node_chat_routes "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/urls.py"
click node_chat_views "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/views.py"
click node_chat_serializers "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/serializers.py"
click node_conversation_model "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/models.py"
click node_message_model "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/models.py"
click node_asgi "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/config/asgi.py"
click node_ws_auth "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/middleware.py"
click node_ws_routes "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/routing.py"
click node_consumer "https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/consumers.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_user_views,node_register_serializer,node_jwt_service,node_user_model,node_client,node_restclient,node_wsclient toneBlue
class node_chat_routes,node_chat_views,node_chat_serializers toneAmber
class node_conversation_model,node_message_model,node_database toneMint
class node_asgi,node_ws_auth,node_ws_routes,node_consumer toneRose
```

## Components

### Identity

- [User Routes](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/users/urls.py): `backend/config/users/urls.py`
- [Identity Views](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/users/views.py): `backend/config/users/views.py`
- [Registration Serializer](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/users/serializers.py): `backend/config/users/serializers.py`
- **JWT Provider**
- [User Model](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/users/models.py): `backend/config/users/models.py`

### REST API

- [Chat Routes](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/urls.py): `backend/config/chats/urls.py`
- [Chat Views](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/views.py): `backend/config/chats/views.py`
- [Chat Serializers](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/serializers.py): `backend/config/chats/serializers.py`

### Chat Data

- [Conversation Model](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/models.py): `backend/config/chats/models.py`
- [Message Model](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/models.py): `backend/config/chats/models.py`
- **Relational Database**

### WebSocket

- [ASGI Application](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/config/asgi.py): `backend/config/config/asgi.py`
- [JWT Socket Auth](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/middleware.py): `backend/config/chats/middleware.py`
- [Socket Routes](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/routing.py): `backend/config/chats/routing.py`
- [Chat Consumer](https://github.com/santhosh-ek2007-zen/sanchat/blob/main/backend/config/chats/consumers.py): `backend/config/chats/consumers.py`

### Other components

- **Chat Client**
- **REST Client**
- **WebSocket Client**

## Connections

- Chat Client → REST Client: uses (evidence: `README.md`)
- REST Client → User Routes: requests (evidence: `README.md`)
- REST Client → Chat Routes: requests (evidence: `README.md`)
- User Routes → Identity Views: routes to (evidence: `backend/config/users/urls.py`)
- Identity Views → Registration Serializer: validates registration (evidence: `backend/config/users/views.py`)
- Registration Serializer → User Model: creates (evidence: `backend/config/users/serializers.py`)
- Identity Views → JWT Provider: issues and revokes (evidence: `backend/config/users/views.py`)
- User Routes → JWT Provider: routes token requests (evidence: `backend/config/users/urls.py`)
- Chat Routes → Chat Views: routes to (evidence: `backend/config/chats/urls.py`)
- Chat Views → Chat Serializers: serializes (evidence: `backend/config/chats/views.py`)
- Chat Views → Conversation Model: queries and saves (evidence: `backend/config/chats/views.py`)
- Chat Views → Message Model: queries and saves (evidence: `backend/config/chats/views.py`)
- Chat Serializers → Conversation Model: represents (evidence: `backend/config/chats/serializers.py`)
- Chat Serializers → Message Model: represents (evidence: `backend/config/chats/serializers.py`)
- Chat Serializers → User Model: serializes participants (evidence: `backend/config/chats/serializers.py`)
- Conversation Model → Relational Database: persists
- Message Model → Relational Database: persists
- Chat Client → WebSocket Client: connects
- WebSocket Client → ASGI Application: opens socket (evidence: `backend/config/config/asgi.py`)
- ASGI Application → JWT Socket Auth: wraps WebSocket (evidence: `backend/config/config/asgi.py`)
- ASGI Application → Socket Routes: routes WebSocket (evidence: `backend/config/config/asgi.py`)
- JWT Socket Auth → User Model: resolves token user (evidence: `backend/config/chats/middleware.py`)
- Socket Routes → Chat Consumer: dispatches to (evidence: `backend/config/chats/routing.py`)
