# raushan291/messaging-platform architecture

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

- Interactive diagram: https://gitdiagram.com/raushan291/messaging-platform
- Repository: https://github.com/raushan291/messaging-platform

## Overview

Messaging-platform provides account registration and token-based authentication alongside conversations, persistent messages, WebSocket chat, and message search/indexing. Users enter through the frontend; auth and messaging are separate backend services. Messaging publishes message events to Kafka, whose consumer broadcasts them to connected clients and indexes them for search. The excerpts show these backend paths, but not detailed frontend component wiring or the search-query implementation, so those links are limited. Redis and Elasticsearch roles are documented or referenced, but some integration details are unsampled.

Main entry points: [`backend/services/auth-service/app/api/v1/auth_routes.py`](https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/api/v1/auth_routes.py) (Auth routes), [`backend/services/auth-service/app/services/auth_service.py`](https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/services/auth_service.py) (Auth operations), [`backend/services/messaging-service/app/core/kafka.py`](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/core/kafka.py) (Kafka events), [`backend/services/messaging-service/app/main.py`](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/main.py) (Messaging app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_frontend["Web app<br/>[page.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_ws_client["WebSocket client<br/>[websocket.ts]"]
end

subgraph group_auth["Authentication"]
  node_auth_routes["Auth routes<br/>[auth_routes.py]"]
  node_auth_service["Auth operations<br/>[auth_service.py]"]
  node_auth_users["User repository<br/>[user_repo.py]"]
  node_auth_tokens["Refresh-token repository"]
  node_auth_security["Password security<br/>[security.py]"]
  node_auth_jwt["JWT handling<br/>[jwt.py]"]
end

subgraph group_messaging["Messaging"]
  node_messaging_entry["Messaging app<br/>[main.py]"]
  node_conversation_routes["Conversations"]
  node_message_routes["Message HTTP API<br/>[message_routes.py]"]
  node_websocket_routes["WebSocket chat<br/>[ws_routes.py]"]
  node_websocket_manager["Room broadcasts"]
  node_search_routes["Search API<br/>[search_routes.py]"]
  node_search_indexer["Message indexer<br/>[search_service.py]"]
end

subgraph group_infra["Data and events"]
  node_auth_store[("Auth database<br/>[session.py]")]
  node_messaging_store[("Messaging database<br/>[session.py]")]
  node_kafka["Kafka events<br/>[kafka.py]"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis")]
  node_kafka_service["Kafka broker"]
  node_elasticsearch[("Elasticsearch")]
end

node_user(("User"))

node_user -->|"uses"| node_frontend
node_frontend -.->|"requests"| node_api_client
node_frontend -.->|"opens chat"| node_ws_client
node_api_client -.->|"calls auth API"| node_auth_routes
node_api_client -.->|"calls messaging API"| node_conversation_routes
node_ws_client -.->|"connects"| node_websocket_routes
node_auth_routes -->|"invokes"| node_auth_service
node_auth_routes -->|"revokes tokens"| node_auth_tokens
node_auth_routes -->|"looks up users"| node_auth_users
node_auth_service -->|"looks up"| node_auth_users
node_auth_service -->|"stores tokens"| node_auth_tokens
node_auth_service -->|"hashes passwords"| node_auth_security
node_auth_service -->|"creates tokens"| node_auth_jwt
node_auth_routes -->|"opens sessions"| node_auth_store
node_auth_store -.->|"connects"| node_postgres
node_messaging_entry -->|"mounts routes"| node_conversation_routes
node_messaging_entry -->|"mounts routes"| node_message_routes
node_messaging_entry -->|"mounts routes"| node_websocket_routes
node_conversation_routes -->|"reads and writes"| node_messaging_store
node_message_routes -->|"reads and writes"| node_messaging_store
node_websocket_routes -->|"writes messages"| node_messaging_store
node_message_routes -->|"publishes events"| node_kafka
node_websocket_routes -->|"publishes events"| node_kafka
node_kafka -->|"broadcasts events"| node_websocket_manager
node_kafka -->|"indexes events"| node_search_indexer
node_search_routes -.->|"queries search"| node_search_indexer
node_messaging_store -.->|"connects"| node_postgres
node_messaging_entry -->|"connects"| node_redis
node_kafka -->|"connects"| node_kafka_service
node_search_indexer -->|"indexes documents"| node_elasticsearch

click node_frontend "https://github.com/raushan291/messaging-platform/blob/main/frontend/app/chat/page.tsx"
click node_api_client "https://github.com/raushan291/messaging-platform/blob/main/frontend/lib/api.ts"
click node_ws_client "https://github.com/raushan291/messaging-platform/blob/main/frontend/lib/websocket.ts"
click node_auth_routes "https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/api/v1/auth_routes.py"
click node_auth_service "https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/services/auth_service.py"
click node_auth_users "https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/repositories/user_repo.py"
click node_auth_tokens "https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/repositories/refresh_token_repo.py"
click node_auth_security "https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/core/security.py"
click node_auth_jwt "https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/core/jwt.py"
click node_auth_store "https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/db/session.py"
click node_messaging_entry "https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/main.py"
click node_conversation_routes "https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/api/v1/conversation_routes.py"
click node_message_routes "https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/api/v1/message_routes.py"
click node_websocket_routes "https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/api/v1/ws_routes.py"
click node_websocket_manager "https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/services/websocket_manager.py"
click node_search_routes "https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/api/v1/search_routes.py"
click node_search_indexer "https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/services/search_service.py"
click node_messaging_store "https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/db/session.py"
click node_kafka "https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/core/kafka.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_frontend,node_api_client,node_ws_client,node_user toneBlue
class node_auth_routes,node_auth_service,node_auth_users,node_auth_tokens,node_auth_security,node_auth_jwt toneAmber
class node_messaging_entry,node_conversation_routes,node_message_routes,node_websocket_routes,node_websocket_manager,node_search_routes,node_search_indexer toneMint
class node_auth_store,node_messaging_store,node_kafka,node_postgres,node_redis,node_kafka_service,node_elasticsearch toneRose
```

## Components

### Web client

- [Web app](https://github.com/raushan291/messaging-platform/blob/main/frontend/app/chat/page.tsx): `frontend/app/chat/page.tsx`
- [API client](https://github.com/raushan291/messaging-platform/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`
- [WebSocket client](https://github.com/raushan291/messaging-platform/blob/main/frontend/lib/websocket.ts): `frontend/lib/websocket.ts`

### Authentication

- [Auth routes](https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/api/v1/auth_routes.py): `backend/services/auth-service/app/api/v1/auth_routes.py`
- [Auth operations](https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/services/auth_service.py): `backend/services/auth-service/app/services/auth_service.py`
- [User repository](https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/repositories/user_repo.py): `backend/services/auth-service/app/repositories/user_repo.py`
- [Refresh-token repository](https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/repositories/refresh_token_repo.py): `backend/services/auth-service/app/repositories/refresh_token_repo.py`
- [Password security](https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/core/security.py): `backend/services/auth-service/app/core/security.py`
- [JWT handling](https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/core/jwt.py): `backend/services/auth-service/app/core/jwt.py`

### Messaging

- [Messaging app](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/main.py): `backend/services/messaging-service/app/main.py`
- [Conversations](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/api/v1/conversation_routes.py): `backend/services/messaging-service/app/api/v1/conversation_routes.py`
- [Message HTTP API](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/api/v1/message_routes.py): `backend/services/messaging-service/app/api/v1/message_routes.py`
- [WebSocket chat](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/api/v1/ws_routes.py): `backend/services/messaging-service/app/api/v1/ws_routes.py`
- [Room broadcasts](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/services/websocket_manager.py): `backend/services/messaging-service/app/services/websocket_manager.py`
- [Search API](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/api/v1/search_routes.py): `backend/services/messaging-service/app/api/v1/search_routes.py`
- [Message indexer](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/services/search_service.py): `backend/services/messaging-service/app/services/search_service.py`

### Data and events

- [Auth database](https://github.com/raushan291/messaging-platform/blob/main/backend/services/auth-service/app/db/session.py): `backend/services/auth-service/app/db/session.py`
- [Messaging database](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/db/session.py): `backend/services/messaging-service/app/db/session.py`
- [Kafka events](https://github.com/raushan291/messaging-platform/blob/main/backend/services/messaging-service/app/core/kafka.py): `backend/services/messaging-service/app/core/kafka.py`
- **PostgreSQL**
- **Redis**
- **Kafka broker**
- **Elasticsearch**

### Other components

- **User**

## Connections

- User → Web app: uses (evidence: `README.md`)
- Web app → API client: requests
- Web app → WebSocket client: opens chat
- API client → Auth routes: calls auth API (evidence: `README.md`)
- API client → Conversations: calls messaging API (evidence: `README.md`)
- WebSocket client → WebSocket chat: connects (evidence: `README.md`)
- Auth routes → Auth operations: invokes (evidence: `backend/services/auth-service/app/api/v1/auth_routes.py`)
- Auth routes → Refresh-token repository: revokes tokens (evidence: `backend/services/auth-service/app/api/v1/auth_routes.py`)
- Auth routes → User repository: looks up users (evidence: `backend/services/auth-service/app/api/v1/auth_routes.py`)
- Auth operations → User repository: looks up (evidence: `backend/services/auth-service/app/services/auth_service.py`)
- Auth operations → Refresh-token repository: stores tokens (evidence: `backend/services/auth-service/app/services/auth_service.py`)
- Auth operations → Password security: hashes passwords (evidence: `backend/services/auth-service/app/services/auth_service.py`)
- Auth operations → JWT handling: creates tokens (evidence: `backend/services/auth-service/app/services/auth_service.py`)
- Auth routes → Auth database: opens sessions (evidence: `backend/services/auth-service/app/api/v1/auth_routes.py`)
- Auth database → PostgreSQL: connects (evidence: `backend/services/auth-service/app/db/session.py`)
- Messaging app → Conversations: mounts routes (evidence: `backend/services/messaging-service/app/main.py`)
- Messaging app → Message HTTP API: mounts routes
- Messaging app → WebSocket chat: mounts routes (evidence: `backend/services/messaging-service/app/main.py`)
- Conversations → Messaging database: reads and writes (evidence: `backend/services/messaging-service/app/api/v1/conversation_routes.py`)
- Message HTTP API → Messaging database: reads and writes (evidence: `backend/services/messaging-service/app/api/v1/message_routes.py`)
- WebSocket chat → Messaging database: writes messages (evidence: `backend/services/messaging-service/app/api/v1/ws_routes.py`)
- Message HTTP API → Kafka events: publishes events (evidence: `backend/services/messaging-service/app/api/v1/message_routes.py`)
- WebSocket chat → Kafka events: publishes events (evidence: `backend/services/messaging-service/app/api/v1/ws_routes.py`)
- Kafka events → Room broadcasts: broadcasts events (evidence: `backend/services/messaging-service/app/core/kafka.py`)
- Kafka events → Message indexer: indexes events (evidence: `backend/services/messaging-service/app/core/kafka.py`)
- Search API → Message indexer: queries search
- Messaging database → PostgreSQL: connects (evidence: `README.md`)
- Messaging app → Redis: connects (evidence: `backend/services/messaging-service/app/main.py`)
- Kafka events → Kafka broker: connects (evidence: `backend/services/messaging-service/app/core/kafka.py`)
- Message indexer → Elasticsearch: indexes documents (evidence: `backend/services/messaging-service/app/services/search_service.py`)
