# brickstercodes/e3.ai architecture

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

- Interactive diagram: https://gitdiagram.com/brickstercodes/e3.ai
- Repository: https://github.com/brickstercodes/e3.ai

## Overview

E3.ai is an educational, character-based history chatbot. A learner sends messages through the browser chat, which exchanges them with a FastAPI WebSocket endpoint; the backend streams responses generated by a Together-hosted Llama model while maintaining conversation history. The prompt covers character enactment, historical-topic narration, and fun facts. When a learner stops or requests a quiz, the backend sends quiz questions and a score. The repository also contains home, login, and signup pages, but their behavior and connections are not shown in the sampled source.

Main entry points: [`backend.py`](https://github.com/brickstercodes/e3.ai/blob/main/backend.py) (Conversation handling), [`chat.js`](https://github.com/brickstercodes/e3.ai/blob/main/chat.js) (Chat interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_home["Home page<br/>[index.html]"]
  node_login["Login page<br/>[login.html]"]
  node_signup["Signup page<br/>[signup.html]"]
  node_chat_ui["Chat interface<br/>[chat.js]"]
  node_chat_page["Chat page<br/>[chat.html]"]
end

subgraph group_chat["Chat and learning"]
  node_websocket["Chat WebSocket<br/>[backend.py]"]
  node_conversation["Conversation handling<br/>[backend.py]"]
  node_learning_prompt["Learning prompt<br/>[backend.py]"]
  node_quiz["Quiz generation<br/>[backend.py]"]
end

subgraph group_ai["Language model"]
  node_together_llm["Together LLM"]
end

node_learner(("Learner"))

node_learner -->|"sends messages"| node_chat_ui
node_chat_ui -->|"sends messages"| node_websocket
node_websocket -->|"handles messages"| node_conversation
node_conversation -->|"formats prompt"| node_learning_prompt
node_conversation -->|"streams responses"| node_together_llm
node_conversation -->|"generates quiz"| node_quiz

click node_home "https://github.com/brickstercodes/e3.ai/blob/main/index.html"
click node_login "https://github.com/brickstercodes/e3.ai/blob/main/login.html"
click node_signup "https://github.com/brickstercodes/e3.ai/blob/main/signup.html"
click node_chat_ui "https://github.com/brickstercodes/e3.ai/blob/main/chat.js"
click node_chat_page "https://github.com/brickstercodes/e3.ai/blob/main/chat.html"
click node_websocket "https://github.com/brickstercodes/e3.ai/blob/main/backend.py"
click node_conversation "https://github.com/brickstercodes/e3.ai/blob/main/backend.py"
click node_learning_prompt "https://github.com/brickstercodes/e3.ai/blob/main/backend.py"
click node_quiz "https://github.com/brickstercodes/e3.ai/blob/main/backend.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_home,node_login,node_signup,node_chat_ui,node_chat_page toneBlue
class node_websocket,node_conversation,node_learning_prompt,node_quiz toneAmber
class node_together_llm toneMint
class node_learner toneIndigo
```

## Components

### Web experience

- [Home page](https://github.com/brickstercodes/e3.ai/blob/main/index.html): `index.html`
- [Login page](https://github.com/brickstercodes/e3.ai/blob/main/login.html): `login.html`
- [Signup page](https://github.com/brickstercodes/e3.ai/blob/main/signup.html): `signup.html`
- [Chat interface](https://github.com/brickstercodes/e3.ai/blob/main/chat.js): `chat.js`
- [Chat page](https://github.com/brickstercodes/e3.ai/blob/main/chat.html): `chat.html`

### Chat and learning

- [Chat WebSocket](https://github.com/brickstercodes/e3.ai/blob/main/backend.py): `backend.py`
- [Conversation handling](https://github.com/brickstercodes/e3.ai/blob/main/backend.py): `backend.py`
- [Learning prompt](https://github.com/brickstercodes/e3.ai/blob/main/backend.py): `backend.py`
- [Quiz generation](https://github.com/brickstercodes/e3.ai/blob/main/backend.py): `backend.py`

### Language model

- **Together LLM**

### Other components

- **Learner**

## Connections

- Learner → Chat interface: sends messages (evidence: `chat.js`)
- Chat interface → Chat WebSocket: sends messages (evidence: `chat.js`)
- Chat WebSocket → Conversation handling: handles messages (evidence: `backend.py`)
- Conversation handling → Learning prompt: formats prompt (evidence: `backend.py`)
- Conversation handling → Together LLM: streams responses (evidence: `backend.py`)
- Conversation handling → Quiz generation: generates quiz (evidence: `backend.py`)
