# shashikantbadgujarpm/chat-app architecture

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

- Interactive diagram: https://gitdiagram.com/shashikantbadgujarpm/chat-app
- Repository: https://github.com/shashikantbadgujarpm/chat-app

## Overview

This is a real-time team chat application with a React client and FastAPI backend. The main workflow is sign-in, conversation selection, message submission, persistence, and delivery to connected members; separate workflows cover profiles, presence and typing, read cursors, and scheduled delivery. The backend is organized around domain modules with application services and infrastructure repositories, plus a realtime gateway. Some backend routes and wiring are unsampled, so the graph omits uncertain links rather than inferring call chains.

Main entry points: [`frontend/src/api/client.ts`](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/api/client.ts) (REST client), [`frontend/src/App.tsx`](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/App.tsx) (App and routes), [`backend/app/main.py`](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/main.py) (FastAPI app), [`frontend/src/ws/ChatSocket.ts`](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/ws/ChatSocket.ts) (WebSocket client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_app["App and routes<br/>[App.tsx]"]
  node_auth_ui["Auth UI<br/>[AuthContext.tsx]"]
  node_conversation_ui["Conversation views"]
  node_message_ui["Message pane<br/>[MessagePane.tsx]"]
  node_presence_ui["Presence UI<br/>[presence.ts]"]
  node_schedule_ui["Schedule views<br/>[ScheduledPanel.tsx]"]
  node_profile_ui["Profile and search<br/>[ProfilePages.tsx]"]
  node_api_client["REST client<br/>[client.ts]"]
  node_ws_client["WebSocket client<br/>[ChatSocket.ts]"]
end

subgraph group_identity["Identity and profiles"]
  node_identity_api["Identity API<br/>[routers.py]"]
  node_identity_service["Identity services<br/>[services.py]"]
  node_identity_store["Identity repositories<br/>[user_repository.py]"]
end

subgraph group_chat["Conversations and messaging"]
  node_conversation_api["Conversation API<br/>[router.py]"]
  node_conversation_service["Conversation service"]
  node_conversation_store["Conversation repository<br/>[repository.py]"]
  node_messaging_api["Messaging API<br/>[routers.py]"]
  node_messaging_service["Messaging service"]
  node_messaging_store["Message repository<br/>[repository.py]"]
end

subgraph group_realtime["Realtime delivery"]
  node_presence_service["Presence and typing"]
  node_gateway["WebSocket gateway<br/>[gateway.py]"]
  node_connections["Connection fan-out"]
  node_outbox["Outbox listener<br/>[outbox_listener.py]"]
end

subgraph group_scheduling["Scheduled messages"]
  node_scheduling_api["Scheduling API<br/>[router.py]"]
  node_scheduling_service["Scheduling service"]
  node_delivery_service["Scheduled delivery"]
  node_schedule_store["Scheduled repository<br/>[repository.py]"]
end

node_user(("Chat user"))
node_api["FastAPI app<br/>[main.py]"]
node_database[("PostgreSQL")]

node_user -->|"uses"| node_app
node_app -->|"routes"| node_auth_ui
node_app -->|"routes"| node_conversation_ui
node_app -->|"routes"| node_schedule_ui
node_app -->|"routes"| node_profile_ui
node_auth_ui -->|"requests"| node_api_client
node_conversation_ui -->|"requests"| node_api_client
node_message_ui -->|"requests"| node_api_client
node_presence_ui -->|"signals"| node_ws_client
node_message_ui -->|"receives events"| node_ws_client
node_schedule_ui -->|"requests"| node_api_client
node_profile_ui -->|"requests"| node_api_client
node_api_client -->|"HTTP requests"| node_api
node_ws_client -->|"opens socket"| node_gateway
node_api -->|"mounts routes"| node_identity_api
node_api -->|"mounts routes"| node_conversation_api
node_api -->|"mounts routes"| node_messaging_api
node_api -->|"mounts routes"| node_scheduling_api
node_identity_api -->|"invokes"| node_identity_service
node_identity_service -->|"reads and writes"| node_identity_store
node_identity_store -->|"persists identity"| node_database
node_conversation_api -->|"invokes"| node_conversation_service
node_conversation_service -->|"reads and writes"| node_conversation_store
node_conversation_store -->|"persists membership"| node_database
node_messaging_api -->|"invokes"| node_messaging_service
node_messaging_service -->|"reads and writes"| node_messaging_store
node_messaging_store -->|"persists messages"| node_database
node_gateway -->|"manages sockets"| node_connections
node_connections -->|"connection callbacks"| node_presence_service
node_outbox -->|"reads committed events"| node_database
node_outbox -->|"fans out events"| node_connections
node_scheduling_api -->|"invokes"| node_scheduling_service
node_scheduling_service -->|"reads and writes"| node_schedule_store
node_schedule_store -->|"persists schedules"| node_database
node_delivery_service -->|"claims due rows"| node_schedule_store
node_delivery_service -->|"creates delivered message"| node_messaging_service

click node_app "https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/App.tsx"
click node_auth_ui "https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/auth/AuthContext.tsx"
click node_conversation_ui "https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/conversations/ConversationPanel.tsx"
click node_message_ui "https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/messages/MessagePane.tsx"
click node_presence_ui "https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/presence/presence.ts"
click node_schedule_ui "https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/scheduled/ScheduledPanel.tsx"
click node_profile_ui "https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/users/ProfilePages.tsx"
click node_api_client "https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/api/client.ts"
click node_ws_client "https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/ws/ChatSocket.ts"
click node_api "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/main.py"
click node_identity_api "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/identity/api/routers.py"
click node_identity_service "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/identity/application/services.py"
click node_identity_store "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/identity/infrastructure/user_repository.py"
click node_conversation_api "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/conversations/api/router.py"
click node_conversation_service "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/conversations/application/conversation_service.py"
click node_conversation_store "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/conversations/infrastructure/repository.py"
click node_messaging_api "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/messaging/api/routers.py"
click node_messaging_service "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/messaging/application/messaging_service.py"
click node_messaging_store "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/messaging/infrastructure/repository.py"
click node_presence_service "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/presence/application/presence_service.py"
click node_gateway "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/realtime/gateway.py"
click node_connections "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/realtime/connection_manager.py"
click node_outbox "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/realtime/outbox_listener.py"
click node_scheduling_api "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/scheduling/api/router.py"
click node_scheduling_service "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/scheduling/application/scheduling_service.py"
click node_delivery_service "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/scheduling/application/delivery_service.py"
click node_schedule_store "https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/scheduling/infrastructure/repository.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_auth_ui,node_conversation_ui,node_message_ui,node_presence_ui,node_schedule_ui,node_profile_ui,node_api_client,node_ws_client,node_user toneBlue
class node_identity_api,node_identity_service,node_identity_store,node_database toneAmber
class node_conversation_api,node_conversation_service,node_conversation_store,node_messaging_api,node_messaging_service,node_messaging_store,node_api toneMint
class node_presence_service,node_gateway,node_connections,node_outbox toneRose
class node_scheduling_api,node_scheduling_service,node_delivery_service,node_schedule_store toneIndigo
```

## Components

### React client

- [App and routes](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Auth UI](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/auth/AuthContext.tsx): `frontend/src/features/auth/AuthContext.tsx`
- [Conversation views](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/conversations/ConversationPanel.tsx): `frontend/src/features/conversations/ConversationPanel.tsx`
- [Message pane](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/messages/MessagePane.tsx): `frontend/src/features/messages/MessagePane.tsx`
- [Presence UI](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/presence/presence.ts): `frontend/src/features/presence/presence.ts`
- [Schedule views](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/scheduled/ScheduledPanel.tsx): `frontend/src/features/scheduled/ScheduledPanel.tsx`
- [Profile and search](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/features/users/ProfilePages.tsx): `frontend/src/features/users/ProfilePages.tsx`
- [REST client](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [WebSocket client](https://github.com/shashikantbadgujarpm/chat-app/blob/main/frontend/src/ws/ChatSocket.ts): `frontend/src/ws/ChatSocket.ts`

### Identity and profiles

- [Identity API](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/identity/api/routers.py): `backend/app/modules/identity/api/routers.py`
- [Identity services](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/identity/application/services.py): `backend/app/modules/identity/application/services.py`
- [Identity repositories](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/identity/infrastructure/user_repository.py): `backend/app/modules/identity/infrastructure/user_repository.py`

### Conversations and messaging

- [Conversation API](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/conversations/api/router.py): `backend/app/modules/conversations/api/router.py`
- [Conversation service](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/conversations/application/conversation_service.py): `backend/app/modules/conversations/application/conversation_service.py`
- [Conversation repository](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/conversations/infrastructure/repository.py): `backend/app/modules/conversations/infrastructure/repository.py`
- [Messaging API](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/messaging/api/routers.py): `backend/app/modules/messaging/api/routers.py`
- [Messaging service](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/messaging/application/messaging_service.py): `backend/app/modules/messaging/application/messaging_service.py`
- [Message repository](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/messaging/infrastructure/repository.py): `backend/app/modules/messaging/infrastructure/repository.py`

### Realtime delivery

- [Presence and typing](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/presence/application/presence_service.py): `backend/app/modules/presence/application/presence_service.py`
- [WebSocket gateway](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/realtime/gateway.py): `backend/app/realtime/gateway.py`
- [Connection fan-out](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/realtime/connection_manager.py): `backend/app/realtime/connection_manager.py`
- [Outbox listener](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/realtime/outbox_listener.py): `backend/app/realtime/outbox_listener.py`

### Scheduled messages

- [Scheduling API](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/scheduling/api/router.py): `backend/app/modules/scheduling/api/router.py`
- [Scheduling service](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/scheduling/application/scheduling_service.py): `backend/app/modules/scheduling/application/scheduling_service.py`
- [Scheduled delivery](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/scheduling/application/delivery_service.py): `backend/app/modules/scheduling/application/delivery_service.py`
- [Scheduled repository](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/modules/scheduling/infrastructure/repository.py): `backend/app/modules/scheduling/infrastructure/repository.py`

### Other components

- **Chat user**
- [FastAPI app](https://github.com/shashikantbadgujarpm/chat-app/blob/main/backend/app/main.py): `backend/app/main.py`
- **PostgreSQL**

## Connections

- Chat user → App and routes: uses
- App and routes → Auth UI: routes
- App and routes → Conversation views: routes
- App and routes → Schedule views: routes
- App and routes → Profile and search: routes
- Auth UI → REST client: requests
- Conversation views → REST client: requests
- Message pane → REST client: requests
- Presence UI → WebSocket client: signals
- Message pane → WebSocket client: receives events
- Schedule views → REST client: requests
- Profile and search → REST client: requests
- REST client → FastAPI app: HTTP requests
- WebSocket client → WebSocket gateway: opens socket
- FastAPI app → Identity API: mounts routes
- FastAPI app → Conversation API: mounts routes
- FastAPI app → Messaging API: mounts routes
- FastAPI app → Scheduling API: mounts routes
- Identity API → Identity services: invokes
- Identity services → Identity repositories: reads and writes
- Identity repositories → PostgreSQL: persists identity
- Conversation API → Conversation service: invokes
- Conversation service → Conversation repository: reads and writes
- Conversation repository → PostgreSQL: persists membership
- Messaging API → Messaging service: invokes
- Messaging service → Message repository: reads and writes
- Message repository → PostgreSQL: persists messages
- WebSocket gateway → Connection fan-out: manages sockets
- Connection fan-out → Presence and typing: connection callbacks
- Outbox listener → PostgreSQL: reads committed events
- Outbox listener → Connection fan-out: fans out events
- Scheduling API → Scheduling service: invokes
- Scheduling service → Scheduled repository: reads and writes
- Scheduled repository → PostgreSQL: persists schedules
- Scheduled delivery → Scheduled repository: claims due rows
- Scheduled delivery → Messaging service: creates delivered message
