# saisankar778/nexoff architecture

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

- Interactive diagram: https://gitdiagram.com/saisankar778/nexoff
- Repository: https://github.com/saisankar778/nexoff

## Overview

NEX_OFF is an Electron desktop chatbot combining offline local answers, online Groq responses, and PDF question answering. The documented workflow starts at the desktop UI, routes chat through either local model execution or the Flask backend, and returns an answer; PDF handling adds extraction, chunking, and retrieval. Source excerpts show both direct Electron-to-Python execution and a renderer-to-Flask path, so both are represented. PDF UI and speech details are limited to README descriptions because their implementation was not sampled.

Main entry points: [`offline/main.js`](https://github.com/saisankar778/nexoff/blob/main/offline/main.js) (Electron window), [`offline/app.py`](https://github.com/saisankar778/nexoff/blob/main/offline/app.py) (Flask API), [`chat_with_pdf/pdf_chat_feature/pdf_chat.js`](https://github.com/saisankar778/nexoff/blob/main/chat_with_pdf/pdf_chat_feature/pdf_chat.js) (PDF chat UI), [`offline/rag_engine.py`](https://github.com/saisankar778/nexoff/blob/main/offline/rag_engine.py) (Sentence retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop experience"]
  node_electron["Electron window<br/>[main.js]"]
  node_chat_ui["Chat renderer<br/>[renderer.js]"]
  node_pdf_ui["PDF chat UI<br/>[pdf_chat.js]"]
end

subgraph group_chat["Chat and identity"]
  node_auth["Authentication<br/>[auth.js]"]
  node_local_chat["Local assistant<br/>[llm_model.py]"]
  node_sentence_rag["Sentence retrieval<br/>[rag_engine.py]"]
  node_online_chat["Groq assistant<br/>[gro.py]"]
end

subgraph group_documents["Document intelligence"]
  node_pdf_upload["PDF upload and extraction<br/>[app.py]"]
  node_pdf_chunker["PDF section chunking"]
  node_pdf_embeddings["Embedding retrieval<br/>[rag_handler.py]"]
  node_pdf_render["PDF rendering<br/>[viewer.js]"]
end

subgraph group_backend["Backend services"]
  node_api["Flask API<br/>[app.py]"]
  node_knowledge["Knowledge base<br/>[knowledge_base.py]"]
  node_history[("Chat history store<br/>[database.py]")]
end

node_user(("User"))
node_groq_service{{"Groq API"}}

node_user -->|"uses"| node_electron
node_electron -.->|"loads UI"| node_chat_ui
node_electron -->|"authenticates"| node_auth
node_electron -->|"spawns model"| node_local_chat
node_local_chat -->|"queries"| node_sentence_rag
node_electron -->|"spawns model"| node_online_chat
node_online_chat -->|"requests completion"| node_groq_service
node_chat_ui -->|"posts chat"| node_api
node_api -->|"saves and reads"| node_history
node_api -->|"gets response"| node_sentence_rag
node_api -.->|"online chat"| node_groq_service
node_user -->|"asks PDF questions"| node_pdf_ui
node_pdf_ui -.->|"uploads PDF"| node_pdf_upload
node_pdf_upload -.->|"processes locally"| node_pdf_chunker
node_pdf_chunker -.->|"provides chunks"| node_pdf_embeddings
node_pdf_embeddings -.->|"returns matches"| node_pdf_ui
node_user -.->|"views document"| node_pdf_render
node_knowledge -->|"supplies knowledge"| node_sentence_rag

click node_electron "https://github.com/saisankar778/nexoff/blob/main/offline/main.js"
click node_chat_ui "https://github.com/saisankar778/nexoff/blob/main/offline/renderer.js"
click node_pdf_ui "https://github.com/saisankar778/nexoff/blob/main/chat_with_pdf/pdf_chat_feature/pdf_chat.js"
click node_auth "https://github.com/saisankar778/nexoff/blob/main/offline/auth.js"
click node_local_chat "https://github.com/saisankar778/nexoff/blob/main/offline/llm_model.py"
click node_sentence_rag "https://github.com/saisankar778/nexoff/blob/main/offline/rag_engine.py"
click node_online_chat "https://github.com/saisankar778/nexoff/blob/main/offline/gro.py"
click node_pdf_upload "https://github.com/saisankar778/nexoff/blob/main/offline/app.py"
click node_pdf_chunker "https://github.com/saisankar778/nexoff/blob/main/chat_with_pdf/pdf_chat_feature/semantic_chunker.py"
click node_pdf_embeddings "https://github.com/saisankar778/nexoff/blob/main/chat_with_pdf/pdf_chat_feature/rag_handler.py"
click node_pdf_render "https://github.com/saisankar778/nexoff/blob/main/lib/pdfjs/web/viewer.js"
click node_api "https://github.com/saisankar778/nexoff/blob/main/offline/app.py"
click node_knowledge "https://github.com/saisankar778/nexoff/blob/main/offline/knowledge_base.py"
click node_history "https://github.com/saisankar778/nexoff/blob/main/offline/database.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_electron,node_chat_ui,node_pdf_ui,node_user toneBlue
class node_auth,node_local_chat,node_sentence_rag,node_online_chat toneAmber
class node_pdf_upload,node_pdf_chunker,node_pdf_embeddings,node_pdf_render,node_groq_service toneMint
class node_api,node_knowledge,node_history toneRose
```

## Components

### Desktop experience

- [Electron window](https://github.com/saisankar778/nexoff/blob/main/offline/main.js): `offline/main.js`
- [Chat renderer](https://github.com/saisankar778/nexoff/blob/main/offline/renderer.js): `offline/renderer.js`
- [PDF chat UI](https://github.com/saisankar778/nexoff/blob/main/chat_with_pdf/pdf_chat_feature/pdf_chat.js): `chat_with_pdf/pdf_chat_feature/pdf_chat.js`

### Chat and identity

- [Authentication](https://github.com/saisankar778/nexoff/blob/main/offline/auth.js): `offline/auth.js`
- [Local assistant](https://github.com/saisankar778/nexoff/blob/main/offline/llm_model.py): `offline/llm_model.py`
- [Sentence retrieval](https://github.com/saisankar778/nexoff/blob/main/offline/rag_engine.py): `offline/rag_engine.py`
- [Groq assistant](https://github.com/saisankar778/nexoff/blob/main/offline/gro.py): `offline/gro.py`

### Document intelligence

- [PDF upload and extraction](https://github.com/saisankar778/nexoff/blob/main/offline/app.py): `offline/app.py`
- [PDF section chunking](https://github.com/saisankar778/nexoff/blob/main/chat_with_pdf/pdf_chat_feature/semantic_chunker.py): `chat_with_pdf/pdf_chat_feature/semantic_chunker.py`
- [Embedding retrieval](https://github.com/saisankar778/nexoff/blob/main/chat_with_pdf/pdf_chat_feature/rag_handler.py): `chat_with_pdf/pdf_chat_feature/rag_handler.py`
- [PDF rendering](https://github.com/saisankar778/nexoff/blob/main/lib/pdfjs/web/viewer.js): `lib/pdfjs/web/viewer.js`

### Backend services

- [Flask API](https://github.com/saisankar778/nexoff/blob/main/offline/app.py): `offline/app.py`
- [Knowledge base](https://github.com/saisankar778/nexoff/blob/main/offline/knowledge_base.py): `offline/knowledge_base.py`
- [Chat history store](https://github.com/saisankar778/nexoff/blob/main/offline/database.py): `offline/database.py`

### Other components

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

## Connections

- User → Electron window: uses (evidence: `README.md`)
- Electron window → Chat renderer: loads UI
- Electron window → Authentication: authenticates (evidence: `offline/main.js`)
- Electron window → Local assistant: spawns model (evidence: `offline/main.js`)
- Local assistant → Sentence retrieval: queries (evidence: `offline/llm_model.py`)
- Electron window → Groq assistant: spawns model (evidence: `offline/main.js`)
- Groq assistant → Groq API: requests completion (evidence: `offline/gro.py`)
- Chat renderer → Flask API: posts chat (evidence: `offline/renderer.js`)
- Flask API → Chat history store: saves and reads (evidence: `offline/app.py`)
- Flask API → Sentence retrieval: gets response (evidence: `offline/app.py`)
- Flask API → Groq API: online chat (evidence: `README.md`)
- User → PDF chat UI: asks PDF questions (evidence: `README.md`)
- PDF chat UI → PDF upload and extraction: uploads PDF (evidence: `README.md`)
- PDF upload and extraction → PDF section chunking: processes locally (evidence: `README.md`)
- PDF section chunking → Embedding retrieval: provides chunks (evidence: `README.md`)
- Embedding retrieval → PDF chat UI: returns matches (evidence: `README.md`)
- User → PDF rendering: views document (evidence: `README.md`)
- Knowledge base → Sentence retrieval: supplies knowledge (evidence: `offline/knowledge_base.py`)
