# shivanshpawar/aira-ai architecture

> Architecture diagram of the GitHub repository shivanshpawar/aira-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shivanshpawar/aira-ai
- Repository: https://github.com/shivanshpawar/aira-ai

## Overview

Aira AI is a full-stack conversational AI application. A user enters through the React client, restores or establishes a session, manages chats, and sends messages; the server persists chat and message state while generating responses through a selected LLM, optionally processing attachments, and returning streamed events over SSE. The client also supports account/profile workflows, archived chats, settings, and rendered message content. The README documents MongoDB, ImageKit/local storage, and Gemini/Groq integrations; several internal implementation links are not visible in the sampled source and are therefore omitted.

Main entry points: [`server/src/app.js`](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/app.js) (Express API), [`server/src/modules/ai/ai.service.js`](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/ai/ai.service.js) (AI orchestration), [`client/src/services/api/apiSlice.js`](https://github.com/shivanshpawar/aira-ai/blob/main/client/src/services/api/apiSlice.js) (API client), [`client/src/app/router.jsx`](https://github.com/shivanshpawar/aira-ai/blob/main/client/src/app/router.jsx) (Route and layouts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["React client<br/>[main.jsx]"]
  node_router["Route and layouts<br/>[router.jsx]"]
  node_auth_ui["Auth and profile<br/>[AuthPage.jsx]"]
  node_session["Session restore"]
  node_chat_ui["Chat workspace"]
  node_message_ui["Message timeline"]
  node_stream_client["SSE stream client<br/>[useChatStream.js]"]
  node_api_client["API client<br/>[apiSlice.js]"]
end

subgraph group_api["API domains"]
  node_express["Express API<br/>[app.js]"]
  node_auth_domain["Authentication<br/>[auth.service.js]"]
  node_users["User accounts<br/>[user.controller.js]"]
  node_chats["Chat lifecycle<br/>[chat.controller.js]"]
  node_messages["Message workflow"]
  node_files["Attachment upload<br/>[file.controller.js]"]
end

subgraph group_ai["AI generation"]
  node_ai_service["AI orchestration<br/>[ai.service.js]"]
  node_summary["Context summary<br/>[summary.service.js]"]
  node_providers{{"Gemini and Groq"}}
end

subgraph group_integrations["Persistence and integrations"]
  node_mongo[("MongoDB<br/>[db.js]")]
  node_storage["File storage<br/>[storage.service.js]"]
  node_imagekit{{"ImageKit"}}
  node_local_storage["Local storage<br/>[local.provider.js]"]
end

node_user(("User"))

node_user -->|"uses"| node_web
node_web -->|"renders"| node_router
node_router -->|"routes to"| node_auth_ui
node_router -->|"routes to"| node_chat_ui
node_session -->|"requests session"| node_api_client
node_stream_client -->|"uses"| node_api_client
node_chat_ui -.->|"presents messages"| node_message_ui
node_api_client -->|"REST and SSE"| node_express
node_express -->|"mounts routes"| node_auth_domain
node_express -->|"mounts routes"| node_users
node_express -->|"mounts routes"| node_chats
node_express -->|"mounts routes"| node_messages
node_express -->|"mounts routes"| node_files
node_messages -.->|"generates replies"| node_ai_service
node_ai_service -.->|"summarizes context"| node_summary
node_ai_service -->|"requests generation"| node_providers
node_express -->|"reads and writes"| node_mongo
node_files -.->|"uploads file"| node_storage
node_storage -->|"stores files"| node_imagekit
node_storage -.->|"supports provider"| node_local_storage
node_providers -->|"returns response"| node_ai_service
node_express -->|"returns JSON and SSE"| node_api_client

click node_web "https://github.com/shivanshpawar/aira-ai/blob/main/client/src/main.jsx"
click node_router "https://github.com/shivanshpawar/aira-ai/blob/main/client/src/app/router.jsx"
click node_auth_ui "https://github.com/shivanshpawar/aira-ai/blob/main/client/src/features/auth/pages/AuthPage.jsx"
click node_session "https://github.com/shivanshpawar/aira-ai/blob/main/client/src/features/auth/useSessionRestore.js"
click node_chat_ui "https://github.com/shivanshpawar/aira-ai/blob/main/client/src/features/chats/pages/ChatWorkspacePage.jsx"
click node_message_ui "https://github.com/shivanshpawar/aira-ai/blob/main/client/src/features/messages/components/MessageTimeline.jsx"
click node_stream_client "https://github.com/shivanshpawar/aira-ai/blob/main/client/src/features/messages/hooks/useChatStream.js"
click node_api_client "https://github.com/shivanshpawar/aira-ai/blob/main/client/src/services/api/apiSlice.js"
click node_express "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/app.js"
click node_auth_domain "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/auth/auth.service.js"
click node_users "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/users/user.controller.js"
click node_chats "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/chat/chat.controller.js"
click node_messages "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/messages/message.controller.js"
click node_files "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/files/file.controller.js"
click node_ai_service "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/ai/ai.service.js"
click node_summary "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/ai/services/summary.service.js"
click node_providers "https://github.com/shivanshpawar/aira-ai/tree/main/server/src/modules/ai/providers"
click node_mongo "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/config/db.js"
click node_storage "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/services/storage/storage.service.js"
click node_local_storage "https://github.com/shivanshpawar/aira-ai/blob/main/server/src/services/storage/providers/local.provider.js"

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_web,node_router,node_auth_ui,node_session,node_chat_ui,node_message_ui,node_stream_client,node_api_client,node_user toneBlue
class node_express,node_auth_domain,node_users,node_chats,node_messages,node_files toneAmber
class node_ai_service,node_summary,node_providers toneMint
class node_mongo,node_storage,node_imagekit,node_local_storage toneRose
```

## Components

### Web client

- [React client](https://github.com/shivanshpawar/aira-ai/blob/main/client/src/main.jsx): `client/src/main.jsx`
- [Route and layouts](https://github.com/shivanshpawar/aira-ai/blob/main/client/src/app/router.jsx): `client/src/app/router.jsx`
- [Auth and profile](https://github.com/shivanshpawar/aira-ai/blob/main/client/src/features/auth/pages/AuthPage.jsx): `client/src/features/auth/pages/AuthPage.jsx`
- [Session restore](https://github.com/shivanshpawar/aira-ai/blob/main/client/src/features/auth/useSessionRestore.js): `client/src/features/auth/useSessionRestore.js`
- [Chat workspace](https://github.com/shivanshpawar/aira-ai/blob/main/client/src/features/chats/pages/ChatWorkspacePage.jsx): `client/src/features/chats/pages/ChatWorkspacePage.jsx`
- [Message timeline](https://github.com/shivanshpawar/aira-ai/blob/main/client/src/features/messages/components/MessageTimeline.jsx): `client/src/features/messages/components/MessageTimeline.jsx`
- [SSE stream client](https://github.com/shivanshpawar/aira-ai/blob/main/client/src/features/messages/hooks/useChatStream.js): `client/src/features/messages/hooks/useChatStream.js`
- [API client](https://github.com/shivanshpawar/aira-ai/blob/main/client/src/services/api/apiSlice.js): `client/src/services/api/apiSlice.js`

### API domains

- [Express API](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/app.js): `server/src/app.js`
- [Authentication](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/auth/auth.service.js): `server/src/modules/auth/auth.service.js`
- [User accounts](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/users/user.controller.js): `server/src/modules/users/user.controller.js`
- [Chat lifecycle](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/chat/chat.controller.js): `server/src/modules/chat/chat.controller.js`
- [Message workflow](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/messages/message.controller.js): `server/src/modules/messages/message.controller.js`
- [Attachment upload](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/files/file.controller.js): `server/src/modules/files/file.controller.js`

### AI generation

- [AI orchestration](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/ai/ai.service.js): `server/src/modules/ai/ai.service.js`
- [Context summary](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/modules/ai/services/summary.service.js): `server/src/modules/ai/services/summary.service.js`
- [Gemini and Groq](https://github.com/shivanshpawar/aira-ai/tree/main/server/src/modules/ai/providers): `server/src/modules/ai/providers`

### Persistence and integrations

- [MongoDB](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/config/db.js): `server/src/config/db.js`
- [File storage](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/services/storage/storage.service.js): `server/src/services/storage/storage.service.js`
- **ImageKit**
- [Local storage](https://github.com/shivanshpawar/aira-ai/blob/main/server/src/services/storage/providers/local.provider.js): `server/src/services/storage/providers/local.provider.js`

### Other components

- **User**

## Connections

- User → React client: uses (evidence: `README.md`)
- React client → Route and layouts: renders (evidence: `client/src/main.jsx`)
- Route and layouts → Auth and profile: routes to (evidence: `client/src/app/router.jsx`)
- Route and layouts → Chat workspace: routes to (evidence: `client/src/app/router.jsx`)
- Session restore → API client: requests session (evidence: `client/src/features/auth/useSessionRestore.js`)
- SSE stream client → API client: uses (evidence: `client/src/features/messages/hooks/useChatStream.js`)
- Chat workspace → Message timeline: presents messages
- API client → Express API: REST and SSE (evidence: `README.md`)
- Express API → Authentication: mounts routes (evidence: `server/src/app.js`)
- Express API → User accounts: mounts routes (evidence: `server/src/app.js`)
- Express API → Chat lifecycle: mounts routes (evidence: `server/src/app.js`)
- Express API → Message workflow: mounts routes (evidence: `server/src/app.js`)
- Express API → Attachment upload: mounts routes (evidence: `server/src/app.js`)
- Message workflow → AI orchestration: generates replies
- AI orchestration → Context summary: summarizes context
- AI orchestration → Gemini and Groq: requests generation (evidence: `README.md`)
- Express API → MongoDB: reads and writes (evidence: `README.md`)
- Attachment upload → File storage: uploads file
- File storage → ImageKit: stores files (evidence: `README.md`)
- File storage → Local storage: supports provider (evidence: `server/src/services/storage/storage.service.js`)
- Gemini and Groq → AI orchestration: returns response (evidence: `README.md`)
- Express API → API client: returns JSON and SSE (evidence: `README.md`)
