# sajjadhaider1016-dot/bzu-ai-assistant architecture

> Architecture diagram of the GitHub repository sajjadhaider1016-dot/bzu-ai-assistant, 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/sajjadhaider1016-dot/bzu-ai-assistant
- Repository: https://github.com/sajjadhaider1016-dot/bzu-ai-assistant

## Overview

This is a BZU-focused AI chatbot with account access, conversational answers, university-knowledge retrieval, file upload, and persistent user/conversation data. The main workflow runs from the browser chat interface through the Express server to knowledge retrieval and an AI completion, then returns an answer to the browser. Authentication and uploaded-document handling are separate server capabilities. Source excerpts confirm the search implementation and portions of server behavior, but do not establish all route mounting, middleware, or integration wiring; uncertain connections are omitted.

Main entry points: [`server.js`](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/server.js) (Express server), [`lib/prisma.js`](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/lib/prisma.js) (Prisma client), [`public/CHATBOT.html`](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/public/CHATBOT.html) (Chat interface), [`public/script.js`](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/public/script.js) (Chat behavior)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat client"]
  node_web["Chat interface<br/>[CHATBOT.html]"]
  node_browser["Chat behavior<br/>[script.js]"]
end

subgraph group_app["Assistant service"]
  node_server["Express server<br/>[server.js]"]
end

subgraph group_knowledge["BZU knowledge"]
  node_search["Knowledge search<br/>[searchService.js]"]
  node_knowledge_data["Knowledge records<br/>[knowledge.json]"]
  node_prospectuses["Prospectus PDFs"]
  node_pdf_search["PDF search<br/>[pdfSearch.js]"]
end

subgraph group_identity["Identity"]
  node_auth["Auth routes<br/>[authRoutes.js]"]
end

subgraph group_storage["Persistence"]
  node_prisma["Prisma client<br/>[prisma.js]"]
  node_database[("SQLite database<br/>[schema.prisma]")]
  node_memory["User memory files<br/>[memoryService.js]"]
  node_uploads[("Uploaded files")]
end

node_visitor(("Visitor"))
node_groq(("Groq AI"))

node_visitor -->|"uses"| node_web
node_web -->|"loads"| node_browser
node_browser -->|"sends chat"| node_server
node_server -->|"requests completion"| node_groq
node_groq -->|"returns answer"| node_server
node_server -->|"searches knowledge"| node_search
node_search -->|"reads records"| node_knowledge_data
node_server -->|"reads and writes"| node_prisma
node_auth -->|"reads and writes"| node_prisma
node_prisma -->|"queries"| node_database
node_server -->|"saves memory"| node_memory
node_server -->|"stores uploads"| node_uploads
node_pdf_search -->|"searches PDFs"| node_prospectuses

click node_web "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/public/CHATBOT.html"
click node_browser "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/public/script.js"
click node_server "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/server.js"
click node_search "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/searchService.js"
click node_knowledge_data "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/knowledge/knowledge.json"
click node_prospectuses "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/knowledge/prospectus_2024.pdf"
click node_pdf_search "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/pdfSearch.js"
click node_auth "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/authRoutes.js"
click node_prisma "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/lib/prisma.js"
click node_database "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/prisma/schema.prisma"
click node_memory "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/memoryService.js"
click node_uploads "https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/tree/main/uploads"

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_browser toneBlue
class node_server toneAmber
class node_search,node_knowledge_data,node_prospectuses,node_pdf_search toneMint
class node_auth toneRose
class node_prisma,node_database,node_memory,node_uploads,node_visitor,node_groq toneIndigo
```

## Components

### Chat client

- [Chat interface](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/public/CHATBOT.html): `public/CHATBOT.html`
- [Chat behavior](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/public/script.js): `public/script.js`

### Assistant service

- [Express server](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/server.js): `server.js`

### BZU knowledge

- [Knowledge search](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/searchService.js): `searchService.js`
- [Knowledge records](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/knowledge/knowledge.json): `knowledge/knowledge.json`
- [Prospectus PDFs](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/knowledge/prospectus_2024.pdf): `knowledge/prospectus_2024.pdf`
- [PDF search](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/pdfSearch.js): `pdfSearch.js`

### Identity

- [Auth routes](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/authRoutes.js): `authRoutes.js`

### Persistence

- [Prisma client](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/lib/prisma.js): `lib/prisma.js`
- [SQLite database](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- [User memory files](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/blob/main/memoryService.js): `memoryService.js`
- [Uploaded files](https://github.com/sajjadhaider1016-dot/bzu-ai-assistant/tree/main/uploads): `uploads`

### Other components

- **Visitor**
- **Groq AI**

## Connections

- Visitor → Chat interface: uses
- Chat interface → Chat behavior: loads
- Chat behavior → Express server: sends chat
- Express server → Groq AI: requests completion
- Groq AI → Express server: returns answer
- Express server → Knowledge search: searches knowledge
- Knowledge search → Knowledge records: reads records
- Express server → Prisma client: reads and writes
- Auth routes → Prisma client: reads and writes
- Prisma client → SQLite database: queries
- Express server → User memory files: saves memory
- Express server → Uploaded files: stores uploads
- PDF search → Prospectus PDFs: searches PDFs
