# 4dith/jarvis architecture

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

- Interactive diagram: https://gitdiagram.com/4dith/jarvis
- Repository: https://github.com/4dith/jarvis

## Overview

JARVIS is a modular voice-and-gesture assistant with a Pygame desktop interface and a reusable FastAPI backend. The documented request flow captures speech, classifies intent and extracts parameters, then runs a backend skill or returns intent data for a client-side skill; responses are spoken aloud. The map includes the documented skill areas and experimental clients. Backend routing and the web-answer pipeline are visible in excerpts; some frontend and experimental-client behavior is represented only where the README documents it.

Main entry points: [`backend/server.py`](https://github.com/4dith/jarvis/blob/main/backend/server.py) (FastAPI Request Handler), [`backend/core/handler.py`](https://github.com/4dith/jarvis/blob/main/backend/core/handler.py) (Web Answer Handler), [`pygame_frontend/client.py`](https://github.com/4dith/jarvis/blob/main/pygame_frontend/client.py) (Backend Client), [`pygame_frontend/ui.py`](https://github.com/4dith/jarvis/blob/main/pygame_frontend/ui.py) (Pygame Interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Desktop Interaction"]
  node_pygame_ui["Pygame Interface<br/>[ui.py]"]
  node_gesture["Gesture Tracking<br/>[hand_cursor.py]"]
  node_vision["Gesture Detection<br/>[vision.py]"]
  node_speech_capture["Speech Input<br/>[speech.py]"]
  node_client["Backend Client<br/>[client.py]"]
  node_speech_output["Speech Output<br/>[textToSpeech.py]"]
end

subgraph group_backend["Request Backend"]
  node_server["FastAPI Request Handler<br/>[server.py]"]
  node_classifier["Intent and Parameters<br/>[classifier.py]"]
end

subgraph group_skills["Assistant Skills"]
  node_weather["Weather Skill<br/>[weather.py]"]
  node_club_qa["Club Knowledge Q&amp;A<br/>[llm.py]"]
  node_quick_math["Quick Math<br/>[classifier.py]"]
  node_jokes["Jokes<br/>[classifier.py]"]
  node_music["Music Playback"]
end

subgraph group_webqa["Web Question Answering"]
  node_web_handler["Web Answer Handler<br/>[handler.py]"]
  node_search["Web Search<br/>[search.py]"]
  node_fetcher["Page Fetching<br/>[fetcher.py]"]
  node_reranker["Result Reranking<br/>[rerank.py]"]
  node_summarizer["Answer Summarization<br/>[summarize.py]"]
end

subgraph group_experiments["Experimental Clients"]
  node_browser_agent["Browser Agent Actions<br/>[actions.py]"]
  node_discord["Discord Client<br/>[bot.py]"]
end

node_user(("User"))
node_ollama["Ollama Service"]
node_weather_service["Weather Service"]

node_user -->|"interacts"| node_pygame_ui
node_user -->|"speaks to"| node_speech_capture
node_pygame_ui -->|"updates cursor"| node_gesture
node_pygame_ui -->|"detects gesture"| node_vision
node_pygame_ui -->|"listens through"| node_speech_capture
node_speech_capture -.->|"sends request"| node_client
node_client -->|"posts text"| node_server
node_server -->|"classifies and extracts"| node_classifier
node_server -->|"routes weather"| node_weather
node_server -->|"routes club Q&amp;A"| node_club_qa
node_server -->|"routes general question"| node_web_handler
node_server -.->|"returns intent and parameters"| node_client
node_client -->|"plays song"| node_music
node_client -->|"speaks response"| node_speech_output
node_server -.->|"requests forecast"| node_weather_service
node_club_qa -->|"requests completion"| node_ollama
node_web_handler -->|"searches query"| node_search
node_web_handler -->|"reranks snippets"| node_reranker
node_web_handler -->|"fetches pages"| node_fetcher
node_web_handler -->|"summarizes text"| node_summarizer
node_browser_agent -.->|"opens browser actions"| node_user
node_discord -.->|"uses backend"| node_server

click node_pygame_ui "https://github.com/4dith/jarvis/blob/main/pygame_frontend/ui.py"
click node_gesture "https://github.com/4dith/jarvis/blob/main/pygame_frontend/hand_cursor.py"
click node_vision "https://github.com/4dith/jarvis/blob/main/pygame_frontend/vision.py"
click node_speech_capture "https://github.com/4dith/jarvis/blob/main/pygame_frontend/speech.py"
click node_client "https://github.com/4dith/jarvis/blob/main/pygame_frontend/client.py"
click node_speech_output "https://github.com/4dith/jarvis/blob/main/pygame_frontend/textToSpeech.py"
click node_server "https://github.com/4dith/jarvis/blob/main/backend/server.py"
click node_classifier "https://github.com/4dith/jarvis/blob/main/backend/classifier.py"
click node_weather "https://github.com/4dith/jarvis/blob/main/backend/weather.py"
click node_club_qa "https://github.com/4dith/jarvis/blob/main/backend/llm.py"
click node_quick_math "https://github.com/4dith/jarvis/blob/main/backend/classifier.py"
click node_jokes "https://github.com/4dith/jarvis/blob/main/backend/classifier.py"
click node_music "https://github.com/4dith/jarvis/blob/main/pygame_frontend/clientFunctionalities.py"
click node_web_handler "https://github.com/4dith/jarvis/blob/main/backend/core/handler.py"
click node_search "https://github.com/4dith/jarvis/blob/main/backend/core/search.py"
click node_fetcher "https://github.com/4dith/jarvis/blob/main/backend/core/fetcher.py"
click node_reranker "https://github.com/4dith/jarvis/blob/main/backend/core/rerank.py"
click node_summarizer "https://github.com/4dith/jarvis/blob/main/backend/core/summarize.py"
click node_browser_agent "https://github.com/4dith/jarvis/blob/main/AI_Browser_Agent/actions.py"
click node_discord "https://github.com/4dith/jarvis/blob/main/discord-bot/bot.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_pygame_ui,node_gesture,node_vision,node_speech_capture,node_client,node_speech_output,node_user toneBlue
class node_server,node_classifier toneAmber
class node_weather,node_club_qa,node_quick_math,node_jokes,node_music toneMint
class node_web_handler,node_search,node_fetcher,node_reranker,node_summarizer toneRose
class node_browser_agent,node_discord,node_ollama,node_weather_service toneIndigo
```

## Components

### Desktop Interaction

- [Pygame Interface](https://github.com/4dith/jarvis/blob/main/pygame_frontend/ui.py): `pygame_frontend/ui.py`
- [Gesture Tracking](https://github.com/4dith/jarvis/blob/main/pygame_frontend/hand_cursor.py): `pygame_frontend/hand_cursor.py`
- [Gesture Detection](https://github.com/4dith/jarvis/blob/main/pygame_frontend/vision.py): `pygame_frontend/vision.py`
- [Speech Input](https://github.com/4dith/jarvis/blob/main/pygame_frontend/speech.py): `pygame_frontend/speech.py`
- [Backend Client](https://github.com/4dith/jarvis/blob/main/pygame_frontend/client.py): `pygame_frontend/client.py`
- [Speech Output](https://github.com/4dith/jarvis/blob/main/pygame_frontend/textToSpeech.py): `pygame_frontend/textToSpeech.py`

### Request Backend

- [FastAPI Request Handler](https://github.com/4dith/jarvis/blob/main/backend/server.py): `backend/server.py`
- [Intent and Parameters](https://github.com/4dith/jarvis/blob/main/backend/classifier.py): `backend/classifier.py`

### Assistant Skills

- [Weather Skill](https://github.com/4dith/jarvis/blob/main/backend/weather.py): `backend/weather.py`
- [Club Knowledge Q&A](https://github.com/4dith/jarvis/blob/main/backend/llm.py): `backend/llm.py`
- [Quick Math](https://github.com/4dith/jarvis/blob/main/backend/classifier.py): `backend/classifier.py`
- [Jokes](https://github.com/4dith/jarvis/blob/main/backend/classifier.py): `backend/classifier.py`
- [Music Playback](https://github.com/4dith/jarvis/blob/main/pygame_frontend/clientFunctionalities.py): `pygame_frontend/clientFunctionalities.py`

### Web Question Answering

- [Web Answer Handler](https://github.com/4dith/jarvis/blob/main/backend/core/handler.py): `backend/core/handler.py`
- [Web Search](https://github.com/4dith/jarvis/blob/main/backend/core/search.py): `backend/core/search.py`
- [Page Fetching](https://github.com/4dith/jarvis/blob/main/backend/core/fetcher.py): `backend/core/fetcher.py`
- [Result Reranking](https://github.com/4dith/jarvis/blob/main/backend/core/rerank.py): `backend/core/rerank.py`
- [Answer Summarization](https://github.com/4dith/jarvis/blob/main/backend/core/summarize.py): `backend/core/summarize.py`

### Experimental Clients

- [Browser Agent Actions](https://github.com/4dith/jarvis/blob/main/AI_Browser_Agent/actions.py): `AI_Browser_Agent/actions.py`
- [Discord Client](https://github.com/4dith/jarvis/blob/main/discord-bot/bot.py): `discord-bot/bot.py`

### Other components

- **User**
- **Ollama Service**
- **Weather Service**

## Connections

- User → Pygame Interface: interacts (evidence: `README.md`)
- User → Speech Input: speaks to (evidence: `README.md`)
- Pygame Interface → Gesture Tracking: updates cursor (evidence: `pygame_frontend/ui.py`)
- Pygame Interface → Gesture Detection: detects gesture (evidence: `pygame_frontend/ui.py`)
- Pygame Interface → Speech Input: listens through (evidence: `pygame_frontend/ui.py`)
- Speech Input → Backend Client: sends request
- Backend Client → FastAPI Request Handler: posts text (evidence: `pygame_frontend/client.py`)
- FastAPI Request Handler → Intent and Parameters: classifies and extracts (evidence: `backend/server.py`)
- FastAPI Request Handler → Weather Skill: routes weather (evidence: `backend/server.py`)
- FastAPI Request Handler → Club Knowledge Q&A: routes club Q&A (evidence: `backend/server.py`)
- FastAPI Request Handler → Web Answer Handler: routes general question (evidence: `backend/server.py`)
- FastAPI Request Handler → Backend Client: returns intent and parameters (evidence: `README.md`)
- Backend Client → Music Playback: plays song (evidence: `pygame_frontend/client.py`)
- Backend Client → Speech Output: speaks response (evidence: `pygame_frontend/client.py`)
- FastAPI Request Handler → Weather Service: requests forecast
- Club Knowledge Q&A → Ollama Service: requests completion (evidence: `backend/llm.py`)
- Web Answer Handler → Web Search: searches query (evidence: `backend/core/handler.py`)
- Web Answer Handler → Result Reranking: reranks snippets (evidence: `backend/core/handler.py`)
- Web Answer Handler → Page Fetching: fetches pages (evidence: `backend/core/handler.py`)
- Web Answer Handler → Answer Summarization: summarizes text (evidence: `backend/core/handler.py`)
- Browser Agent Actions → User: opens browser actions
- Discord Client → FastAPI Request Handler: uses backend (evidence: `README.md`)
