# youssef-fd/offline-ai-agent architecture

> Architecture diagram of the GitHub repository youssef-fd/offline-ai-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/youssef-fd/offline-ai-agent
- Repository: https://github.com/youssef-fd/offline-ai-agent

## Overview

This repository presents an offline developer assistant, but the checked-in runtime shown here is mainly a browser chat UI and Express proxy; the n8n workflow is referenced by the README but its implementation is not present in the tree. The evidenced path is browser input and text-file reading, through Express to the local n8n webhook, then back as a response. The README describes broader local-model, intent-routing, and code-editing stages, but their implementation and connections cannot be verified from the available files.

Main entry points: [`AI_Interface/public/app.js`](https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/public/app.js) (Chat and uploads), [`AI_Interface/server.js`](https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/server.js) (Express API), [`AI_Interface/public/index.html`](https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/public/index.html) (Web page), [`AI_Interface/sql/schema.sql`](https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/sql/schema.sql) (Postgres history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat interface"]
  node_chat["Chat and uploads<br/>[app.js]"]
  node_static["Web page<br/>[index.html]"]
end

subgraph group_server["Web server"]
  node_express["Express API<br/>[server.js]"]
end

subgraph group_automation["AI workflow"]
  node_n8n{{"n8n workflows"}}
  node_ollama["Local model"]
  node_fileops["Code file workflows"]
  node_intent["Intent routing"]
end

subgraph group_persistence["Session history"]
  node_postgres[("Postgres history<br/>[schema.sql]")]
end

node_developer(("Developer"))

node_developer -->|"uses"| node_chat
node_chat -->|"posts chat"| node_express
node_chat -->|"loads history"| node_express
node_static -.->|"loads script"| node_chat
node_express -->|"forwards request"| node_n8n
node_n8n -.->|"runs inference"| node_ollama
node_n8n -.->|"routes intent"| node_intent
node_n8n -.->|"handles files"| node_fileops
node_express -->|"queries history"| node_postgres

click node_chat "https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/public/app.js"
click node_static "https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/public/index.html"
click node_express "https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/server.js"
click node_postgres "https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/sql/schema.sql"

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_chat,node_static toneBlue
class node_express toneAmber
class node_n8n,node_ollama,node_fileops,node_intent toneMint
class node_postgres toneRose
class node_developer toneIndigo
```

## Components

### Chat interface

- [Chat and uploads](https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/public/app.js): `AI_Interface/public/app.js`
- [Web page](https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/public/index.html): `AI_Interface/public/index.html`

### Web server

- [Express API](https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/server.js): `AI_Interface/server.js`

### AI workflow

- **n8n workflows**
- **Local model**
- **Code file workflows**
- **Intent routing**

### Session history

- [Postgres history](https://github.com/youssef-fd/offline-ai-agent/blob/main/AI_Interface/sql/schema.sql): `AI_Interface/sql/schema.sql`

### Other components

- **Developer**

## Connections

- Developer → Chat and uploads: uses (evidence: `README.md`)
- Chat and uploads → Express API: posts chat (evidence: `AI_Interface/public/app.js`)
- Chat and uploads → Express API: loads history (evidence: `AI_Interface/public/app.js`)
- Web page → Chat and uploads: loads script
- Express API → n8n workflows: forwards request (evidence: `AI_Interface/server.js`)
- n8n workflows → Local model: runs inference (evidence: `README.md`)
- n8n workflows → Intent routing: routes intent (evidence: `README.md`)
- n8n workflows → Code file workflows: handles files (evidence: `README.md`)
- Express API → Postgres history: queries history (evidence: `AI_Interface/server.js`)
