# nomihabib36/cortexai---multiagent-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/nomihabib36/cortexai---multiagent-chatbot
- Repository: https://github.com/nomihabib36/cortexai---multiagent-chatbot

## Overview

CortexAI is a multi-agent chatbot with a React client and gateway-backed authentication, chat history, billing, and AI-agent services. The main interaction runs from the user through the frontend and gateway to the agent controller, which saves the prompt, invokes the agent graph, and persists the response through chat. The tree shows specialist agents and payment capabilities, but the graph implementation and most frontend feature modules were not sampled; uncertain dispatch and client-to-endpoint wiring are therefore omitted.

Main entry points: [`Backend/gateway/index.js`](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/gateway/index.js) (API gateway), [`Backend/services/billing/controller/billing.controller.js`](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/billing/controller/billing.controller.js) (Billing controller), [`Backend/services/auth/controllers/auth.controller.js`](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/auth/controllers/auth.controller.js) (Auth controller), [`Backend/services/chat/controllers/chat.controller.js`](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/chat/controllers/chat.controller.js) (Chat controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_home["Chat UI<br/>[Home.jsx]"]
  node_app["App bootstrap<br/>[App.jsx]"]
  node_clientfeatures["Client API features"]
end

subgraph group_gateway["Gateway"]
  node_gatewayapp["API gateway<br/>[index.js]"]
  node_authmiddleware["Session guard<br/>[auth.middleware.js]"]
end

subgraph group_identity["Identity"]
  node_authcontroller["Auth controller<br/>[auth.controller.js]"]
  node_users[("User records<br/>[user.model.js]")]
  node_redis[("Session cache<br/>[redis.js]")]
end

subgraph group_chat["Chat history"]
  node_chatcontroller["Chat controller<br/>[chat.controller.js]"]
  node_conversations[("Conversations")]
  node_messages[("Messages<br/>[message.model.js]")]
end

subgraph group_agents["AI agents"]
  node_agentcontroller["Agent controller"]
  node_agentgraph["Agent graph<br/>[graph.js]"]
  node_agentrouting["Agent routing<br/>[router.js]"]
  node_specialists["Specialist agents"]
  node_pdfvector["PDF retrieval<br/>[pdfRag.agent.js]"]
  node_vectorstore[("Vector store<br/>[vectorDb.js]")]
end

subgraph group_billing["Billing"]
  node_billingcontroller["Billing controller"]
  node_payments[("Payment records<br/>[billing.model.js]")]
end

node_user(("User"))
node_llm["LLM providers"]
node_safepay["Safepay"]
node_gatewayactor(("Browser redirect"))

node_user -->|"uses"| node_home
node_app -->|"renders"| node_home
node_home -->|"uses"| node_clientfeatures
node_gatewayapp -->|"guards routes"| node_authmiddleware
node_gatewayapp -->|"proxies auth"| node_authcontroller
node_gatewayapp -->|"proxies chat"| node_chatcontroller
node_gatewayapp -->|"proxies agent"| node_agentcontroller
node_gatewayapp -->|"proxies billing"| node_billingcontroller
node_authmiddleware -->|"reads session"| node_redis
node_authcontroller -->|"reads/writes"| node_users
node_authcontroller -->|"stores session"| node_redis
node_chatcontroller -->|"reads/writes"| node_conversations
node_chatcontroller -->|"reads/writes"| node_messages
node_agentcontroller -->|"saves messages"| node_chatcontroller
node_agentcontroller -->|"invokes"| node_agentgraph
node_agentrouting -->|"requests model"| node_llm
node_pdfvector -->|"searches"| node_vectorstore
node_pdfvector -->|"requests model"| node_llm
node_billingcontroller -->|"creates/verifies"| node_safepay
node_billingcontroller -->|"reads/writes"| node_payments
node_billingcontroller -->|"updates plan"| node_authcontroller
node_gatewayactor -->|"redirects"| node_home

click node_home "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Frontend/src/pages/Home.jsx"
click node_app "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Frontend/src/App.jsx"
click node_clientfeatures "https://github.com/nomihabib36/cortexai---multiagent-chatbot/tree/main/Frontend/src/features"
click node_gatewayapp "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/gateway/index.js"
click node_authmiddleware "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/gateway/middleware/auth.middleware.js"
click node_authcontroller "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/auth/controllers/auth.controller.js"
click node_users "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/auth/models/user.model.js"
click node_redis "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/shared/redis/redis.js"
click node_chatcontroller "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/chat/controllers/chat.controller.js"
click node_conversations "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/chat/models/conversation.model.js"
click node_messages "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/chat/models/message.model.js"
click node_agentcontroller "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/agent/controllers/agent.controller.js"
click node_agentgraph "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/agent/graph/graph.js"
click node_agentrouting "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/agent/graph/router.js"
click node_specialists "https://github.com/nomihabib36/cortexai---multiagent-chatbot/tree/main/Backend/services/agent/agents"
click node_pdfvector "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/agent/agents/pdfRag.agent.js"
click node_vectorstore "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/agent/config/vectorDb.js"
click node_billingcontroller "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/billing/controller/billing.controller.js"
click node_payments "https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/billing/models/billing.model.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_home,node_app,node_clientfeatures,node_user,node_gatewayactor toneBlue
class node_gatewayapp,node_authmiddleware toneAmber
class node_authcontroller,node_users,node_redis toneMint
class node_chatcontroller,node_conversations,node_messages toneRose
class node_agentcontroller,node_agentgraph,node_agentrouting,node_specialists,node_pdfvector,node_vectorstore,node_llm,node_safepay toneIndigo
class node_billingcontroller,node_payments toneTeal
```

## Components

### Web client

- [Chat UI](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Frontend/src/pages/Home.jsx): `Frontend/src/pages/Home.jsx`
- [App bootstrap](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`
- [Client API features](https://github.com/nomihabib36/cortexai---multiagent-chatbot/tree/main/Frontend/src/features): `Frontend/src/features`

### Gateway

- [API gateway](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/gateway/index.js): `Backend/gateway/index.js`
- [Session guard](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/gateway/middleware/auth.middleware.js): `Backend/gateway/middleware/auth.middleware.js`

### Identity

- [Auth controller](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/auth/controllers/auth.controller.js): `Backend/services/auth/controllers/auth.controller.js`
- [User records](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/auth/models/user.model.js): `Backend/services/auth/models/user.model.js`
- [Session cache](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/shared/redis/redis.js): `Backend/shared/redis/redis.js`

### Chat history

- [Chat controller](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/chat/controllers/chat.controller.js): `Backend/services/chat/controllers/chat.controller.js`
- [Conversations](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/chat/models/conversation.model.js): `Backend/services/chat/models/conversation.model.js`
- [Messages](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/chat/models/message.model.js): `Backend/services/chat/models/message.model.js`

### AI agents

- [Agent controller](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/agent/controllers/agent.controller.js): `Backend/services/agent/controllers/agent.controller.js`
- [Agent graph](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/agent/graph/graph.js): `Backend/services/agent/graph/graph.js`
- [Agent routing](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/agent/graph/router.js): `Backend/services/agent/graph/router.js`
- [Specialist agents](https://github.com/nomihabib36/cortexai---multiagent-chatbot/tree/main/Backend/services/agent/agents): `Backend/services/agent/agents`
- [PDF retrieval](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/agent/agents/pdfRag.agent.js): `Backend/services/agent/agents/pdfRag.agent.js`
- [Vector store](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/agent/config/vectorDb.js): `Backend/services/agent/config/vectorDb.js`

### Billing

- [Billing controller](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/billing/controller/billing.controller.js): `Backend/services/billing/controller/billing.controller.js`
- [Payment records](https://github.com/nomihabib36/cortexai---multiagent-chatbot/blob/main/Backend/services/billing/models/billing.model.js): `Backend/services/billing/models/billing.model.js`

### Other components

- **User**
- **LLM providers**
- **Safepay**
- **Browser redirect**

## Connections

- User → Chat UI: uses
- App bootstrap → Chat UI: renders
- Chat UI → Client API features: uses
- API gateway → Session guard: guards routes
- API gateway → Auth controller: proxies auth
- API gateway → Chat controller: proxies chat
- API gateway → Agent controller: proxies agent
- API gateway → Billing controller: proxies billing
- Session guard → Session cache: reads session
- Auth controller → User records: reads/writes
- Auth controller → Session cache: stores session
- Chat controller → Conversations: reads/writes
- Chat controller → Messages: reads/writes
- Agent controller → Chat controller: saves messages
- Agent controller → Agent graph: invokes
- Agent routing → LLM providers: requests model
- PDF retrieval → Vector store: searches
- PDF retrieval → LLM providers: requests model
- Billing controller → Safepay: creates/verifies
- Billing controller → Payment records: reads/writes
- Billing controller → Auth controller: updates plan
- Browser redirect → Chat UI: redirects
