# anujsaroj7518-ops/sigmagpt architecture

> Architecture diagram of the GitHub repository anujsaroj7518-ops/sigmagpt, 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/anujsaroj7518-ops/sigmagpt
- Repository: https://github.com/anujsaroj7518-ops/sigmagpt

## Overview

SigmaGPT is a React chat interface backed by an Express API, MongoDB thread history, and Groq-hosted chat completions. The main workflow is user prompt → API chat handler → AI reply and persisted messages → rendered conversation; users can also create, switch, list, and delete threads. The README additionally describes Markdown, message actions, scrolling, and profile/plan/logout options. Source confirms the rendering and UI affordances, but does not show working account, settings, plan, or logout services; unsampled wiring is omitted.

Main entry points: [`Frontend/src/ChatWindow.jsx`](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/ChatWindow.jsx) (Chat window), [`Backend/routes/chat.js`](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Backend/routes/chat.js) (Chat routes), [`Frontend/src/App.jsx`](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/App.jsx) (App state), [`Frontend/src/Sidebar.jsx`](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/Sidebar.jsx) (Thread sidebar)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Chat interface"]
  node_main["React mount<br/>[main.jsx]"]
  node_app["App state<br/>[App.jsx]"]
  node_context["Shared context<br/>[MyContext.jsx]"]
  node_sidebar["Thread sidebar<br/>[Sidebar.jsx]"]
  node_window["Chat window<br/>[ChatWindow.jsx]"]
  node_chat["Chat display<br/>[Chat.jsx]"]
end

subgraph group_api["Chat API"]
  node_server["Express server<br/>[server.js]"]
  node_routes["Chat routes<br/>[chat.js]"]
end

subgraph group_data["History and AI"]
  node_thread["Thread model<br/>[Thread.js]"]
  node_mongo[("MongoDB")]
  node_openai["Completion client<br/>[openai.js]"]
end

node_user(("User"))
node_groq["Groq API"]

node_user -->|"enters prompts"| node_window
node_main -->|"mounts"| node_app
node_app -->|"renders"| node_sidebar
node_app -->|"renders"| node_window
node_app -->|"provides state"| node_context
node_sidebar -->|"reads and updates"| node_context
node_window -->|"reads and updates"| node_context
node_window -->|"renders"| node_chat
node_window -->|"posts prompt"| node_routes
node_sidebar -->|"loads and deletes threads"| node_routes
node_server -->|"mounts API"| node_routes
node_server -->|"connects"| node_mongo
node_routes -->|"queries and saves"| node_thread
node_thread -->|"persists documents"| node_mongo
node_routes -->|"requests completion"| node_openai
node_openai -->|"sends completion request"| node_groq

click node_main "https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/main.jsx"
click node_app "https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/App.jsx"
click node_context "https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/MyContext.jsx"
click node_sidebar "https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/Sidebar.jsx"
click node_window "https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/ChatWindow.jsx"
click node_chat "https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/Chat.jsx"
click node_server "https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Backend/server.js"
click node_routes "https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Backend/routes/chat.js"
click node_thread "https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Backend/models/Thread.js"
click node_openai "https://github.com/anujsaroj7518-ops/sigmagpt/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_main,node_app,node_context,node_sidebar,node_window,node_chat,node_user toneBlue
class node_server,node_routes toneAmber
class node_thread,node_mongo,node_openai,node_groq toneMint
```

## Components

### Chat interface

- [React mount](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/main.jsx): `Frontend/src/main.jsx`
- [App state](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`
- [Shared context](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/MyContext.jsx): `Frontend/src/MyContext.jsx`
- [Thread sidebar](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/Sidebar.jsx): `Frontend/src/Sidebar.jsx`
- [Chat window](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/ChatWindow.jsx): `Frontend/src/ChatWindow.jsx`
- [Chat display](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Frontend/src/Chat.jsx): `Frontend/src/Chat.jsx`

### Chat API

- [Express server](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Backend/server.js): `Backend/server.js`
- [Chat routes](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Backend/routes/chat.js): `Backend/routes/chat.js`

### History and AI

- [Thread model](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Backend/models/Thread.js): `Backend/models/Thread.js`
- **MongoDB**
- [Completion client](https://github.com/anujsaroj7518-ops/sigmagpt/blob/main/Backend/utils/openai.js): `Backend/utils/openai.js`

### Other components

- **User**
- **Groq API**

## Connections

- User → Chat window: enters prompts
- React mount → App state: mounts
- App state → Thread sidebar: renders
- App state → Chat window: renders
- App state → Shared context: provides state
- Thread sidebar → Shared context: reads and updates
- Chat window → Shared context: reads and updates
- Chat window → Chat display: renders
- Chat window → Chat routes: posts prompt
- Thread sidebar → Chat routes: loads and deletes threads
- Express server → Chat routes: mounts API
- Express server → MongoDB: connects
- Chat routes → Thread model: queries and saves
- Thread model → MongoDB: persists documents
- Chat routes → Completion client: requests completion
- Completion client → Groq API: sends completion request
