# latikamadankar/lexoai-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/latikamadankar/lexoai-chatbot
- Repository: https://github.com/latikamadankar/lexoai-chatbot

## Overview

LexoAI is a browser-based conversational chat app backed by an Express API. Users submit prompts, the API requests a reply from OpenRouter and saves the exchange in MongoDB; users can also browse, reopen, and delete saved threads. The React app shares prompt, reply, and thread state through context, while separate chat and sidebar views handle conversation and history. Markdown rendering and code highlighting are visible UI capabilities. The README is empty, so this map relies on the shown source; it does not assume additional product features.

Main entry points: [`Backend/routes/chat.js`](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Backend/routes/chat.js) (Chat API), [`Frontend/src/MyContext.jsx`](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/MyContext.jsx) (Shared context), [`Frontend/src/ChatWindow.jsx`](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/ChatWindow.jsx) (Chat window), [`Frontend/src/Sidebar.jsx`](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/Sidebar.jsx) (Thread sidebar)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat interface"]
  node_app_entry["React entry<br/>[main.jsx]"]
  node_app["App state<br/>[App.jsx]"]
  node_context["Shared context<br/>[MyContext.jsx]"]
  node_window["Chat window<br/>[ChatWindow.jsx]"]
  node_chat_view["Chat renderer<br/>[Chat.jsx]"]
  node_sidebar["Thread sidebar<br/>[Sidebar.jsx]"]
end

subgraph group_backend["API and orchestration"]
  node_server["HTTP server<br/>[server.js]"]
  node_routes["Chat API<br/>[chat.js]"]
end

subgraph group_persistence["Thread persistence"]
  node_thread_model["Thread model<br/>[Thread.js]"]
  node_mongo[("MongoDB")]
end

subgraph group_integrations["External services"]
  node_ai_client["Reply client<br/>[openai.js]"]
  node_openrouter["OpenRouter"]
end

node_user(("User"))

node_user -->|"sends prompts"| node_window
node_user -->|"manages threads"| node_sidebar
node_app_entry -->|"renders"| node_app
node_app -->|"provides state"| node_context
node_context -->|"shares state"| node_window
node_context -->|"shares state"| node_sidebar
node_context -->|"shares state"| node_chat_view
node_window -->|"renders"| node_chat_view
node_window -->|"posts prompts"| node_routes
node_sidebar -->|"loads history"| node_routes
node_server -->|"mounts API"| node_routes
node_server -->|"connects"| node_mongo
node_routes -->|"reads and writes"| node_thread_model
node_routes -->|"requests reply"| node_ai_client
node_ai_client -->|"requests completion"| node_openrouter

click node_app_entry "https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/main.jsx"
click node_app "https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/App.jsx"
click node_context "https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/MyContext.jsx"
click node_window "https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/ChatWindow.jsx"
click node_chat_view "https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/Chat.jsx"
click node_sidebar "https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/Sidebar.jsx"
click node_server "https://github.com/latikamadankar/lexoai-chatbot/blob/main/Backend/server.js"
click node_routes "https://github.com/latikamadankar/lexoai-chatbot/blob/main/Backend/routes/chat.js"
click node_thread_model "https://github.com/latikamadankar/lexoai-chatbot/blob/main/Backend/models/Thread.js"
click node_ai_client "https://github.com/latikamadankar/lexoai-chatbot/blob/main/Backend/utils/openai.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_app_entry,node_app,node_context,node_window,node_chat_view,node_sidebar,node_user toneBlue
class node_server,node_routes toneAmber
class node_thread_model,node_mongo toneMint
class node_ai_client,node_openrouter toneRose
```

## Components

### Chat interface

- [React entry](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/main.jsx): `Frontend/src/main.jsx`
- [App state](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`
- [Shared context](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/MyContext.jsx): `Frontend/src/MyContext.jsx`
- [Chat window](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/ChatWindow.jsx): `Frontend/src/ChatWindow.jsx`
- [Chat renderer](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/Chat.jsx): `Frontend/src/Chat.jsx`
- [Thread sidebar](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Frontend/src/Sidebar.jsx): `Frontend/src/Sidebar.jsx`

### API and orchestration

- [HTTP server](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Backend/server.js): `Backend/server.js`
- [Chat API](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Backend/routes/chat.js): `Backend/routes/chat.js`

### Thread persistence

- [Thread model](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Backend/models/Thread.js): `Backend/models/Thread.js`
- **MongoDB**

### External services

- [Reply client](https://github.com/latikamadankar/lexoai-chatbot/blob/main/Backend/utils/openai.js): `Backend/utils/openai.js`
- **OpenRouter**

### Other components

- **User**

## Connections

- User → Chat window: sends prompts (evidence: `Frontend/src/ChatWindow.jsx`)
- User → Thread sidebar: manages threads (evidence: `Frontend/src/Sidebar.jsx`)
- React entry → App state: renders (evidence: `Frontend/src/main.jsx`)
- App state → Shared context: provides state (evidence: `Frontend/src/App.jsx`)
- Shared context → Chat window: shares state (evidence: `Frontend/src/ChatWindow.jsx`)
- Shared context → Thread sidebar: shares state (evidence: `Frontend/src/Sidebar.jsx`)
- Shared context → Chat renderer: shares state (evidence: `Frontend/src/Chat.jsx`)
- Chat window → Chat renderer: renders (evidence: `Frontend/src/ChatWindow.jsx`)
- Chat window → Chat API: posts prompts (evidence: `Frontend/src/ChatWindow.jsx`)
- Thread sidebar → Chat API: loads history (evidence: `Frontend/src/Sidebar.jsx`)
- HTTP server → Chat API: mounts API (evidence: `Backend/server.js`)
- HTTP server → MongoDB: connects (evidence: `Backend/server.js`)
- Chat API → Thread model: reads and writes (evidence: `Backend/routes/chat.js`)
- Chat API → Reply client: requests reply (evidence: `Backend/routes/chat.js`)
- Reply client → OpenRouter: requests completion (evidence: `Backend/utils/openai.js`)
