# achyantsh/herobrine-ai architecture

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

- Interactive diagram: https://gitdiagram.com/achyantsh/herobrine-ai
- Repository: https://github.com/achyantsh/herobrine-ai

## Overview

HeroBrine AI turns text, images, PDFs, voice recordings, and Discord messages into user-scoped commitments, then presents them for management in a web dashboard, calendar, and analytics. The central flow is capture → extraction and validation → persistence → product views. The graph also includes authentication, Discord account linking, and reminders. Backend relationships are grounded in sampled code and the source index; frontend product capabilities and some cross-service links are documented in the README, so those links reflect its architecture rather than inspected frontend call sites.

Main entry points: [`frontend/app`](https://github.com/achyantsh/herobrine-ai/tree/master/frontend/app) (Web application), [`backend/app/main.py`](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/main.py) (FastAPI routes), [`backend/app/services/ai_ingestion_service.py`](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/services/ai_ingestion_service.py) (AI ingestion orchestration), [`discord_bot/handlers/message_handler.py`](https://github.com/achyantsh/herobrine-ai/blob/master/discord_bot/handlers/message_handler.py) (Message and attachment handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web product"]
  node_webapp["Web application"]
  node_commitment_views["Commitment views<br/>[page.tsx]"]
  node_calendar["Calendar<br/>[page.tsx]"]
  node_analytics["Analytics<br/>[page.tsx]"]
  node_dashboard["Dashboard and reminders<br/>[page.tsx]"]
  node_upload["AI upload planner<br/>[UploadDialog.tsx]"]
end

subgraph group_identity["Identity and linking"]
  node_supabase_auth["Supabase auth"]
  node_auth_guard["Session handling<br/>[AuthProvider.tsx]"]
  node_jwt_auth["JWT verification<br/>[dependencies.py]"]
  node_discord_link["Discord account linking<br/>[route.ts]"]
  node_profiles[("Supabase profiles")]
end

subgraph group_discord["Discord capture"]
  node_bot["Discord bot<br/>[bot.py]"]
  node_message_handler["Message and attachment handler<br/>[message_handler.py]"]
  node_bot_api["Backend HTTP client<br/>[herobrine_api.py]"]
end

subgraph group_ingest["Ingestion and AI"]
  node_ai_ingestion["AI ingestion orchestration"]
  node_parsers["Image, PDF, voice parsers"]
  node_text_ai["Text extraction and prompts<br/>[extractor.py]"]
  node_vision_ai["Image understanding"]
  node_mapping["Commitment mapping<br/>[mapper.py]"]
end

subgraph group_commitments["Commitment backend"]
  node_api_entry["FastAPI routes<br/>[main.py]"]
  node_api_auth["Internal API protection<br/>[internal_api.py]"]
  node_commitment_service["Commitment rules"]
  node_repository["Commitment repository"]
  node_commitment_store[("PostgreSQL commitments<br/>[commitment.py]")]
end

node_user(("User"))
node_discord_user(("Discord user"))
node_gemini["Google Gemini"]

node_user -->|"uses"| node_webapp
node_user -->|"mentions"| node_bot
node_webapp -->|"authenticates"| node_supabase_auth
node_webapp -->|"calls API"| node_api_entry
node_webapp -.->|"presents"| node_commitment_views
node_webapp -.->|"presents"| node_calendar
node_webapp -.->|"presents"| node_analytics
node_webapp -.->|"presents"| node_dashboard
node_webapp -.->|"captures input"| node_upload
node_auth_guard -->|"uses session"| node_supabase_auth
node_webapp -->|"starts linking"| node_discord_link
node_discord_link -->|"updates link"| node_profiles
node_bot -->|"registers handler"| node_message_handler
node_message_handler -->|"resolves account"| node_profiles
node_message_handler -->|"sends input"| node_bot_api
node_bot_api -->|"posts ingestion"| node_api_entry
node_api_entry -->|"protects internal routes"| node_api_auth
node_api_entry -->|"authenticates users"| node_jwt_auth
node_api_entry -->|"routes ingestion"| node_ai_ingestion
node_api_entry -->|"routes management"| node_commitment_service
node_api_entry -->|"routes Discord input"| node_ai_ingestion
node_ai_ingestion -->|"parses files"| node_parsers
node_ai_ingestion -->|"extracts text input"| node_text_ai
node_ai_ingestion -->|"processes images"| node_vision_ai
node_text_ai -->|"generates extraction"| node_gemini
node_vision_ai -->|"analyzes images"| node_gemini
node_ai_ingestion -->|"maps results"| node_mapping
node_ai_ingestion -->|"persists extracted"| node_commitment_service
node_commitment_service -->|"delegates persistence"| node_repository
node_repository -->|"reads and writes"| node_commitment_store
node_commitment_store -->|"serves commitment data"| node_api_entry

click node_webapp "https://github.com/achyantsh/herobrine-ai/tree/master/frontend/app"
click node_commitment_views "https://github.com/achyantsh/herobrine-ai/blob/master/frontend/app/commitments/page.tsx"
click node_calendar "https://github.com/achyantsh/herobrine-ai/blob/master/frontend/app/calendar/page.tsx"
click node_analytics "https://github.com/achyantsh/herobrine-ai/blob/master/frontend/app/analytics/page.tsx"
click node_dashboard "https://github.com/achyantsh/herobrine-ai/blob/master/frontend/app/dashboard/page.tsx"
click node_upload "https://github.com/achyantsh/herobrine-ai/blob/master/frontend/components/upload/UploadDialog.tsx"
click node_auth_guard "https://github.com/achyantsh/herobrine-ai/blob/master/frontend/components/auth/AuthProvider.tsx"
click node_jwt_auth "https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/auth/dependencies.py"
click node_discord_link "https://github.com/achyantsh/herobrine-ai/blob/master/frontend/app/api/discord/callback/route.ts"
click node_bot "https://github.com/achyantsh/herobrine-ai/blob/master/discord_bot/bot.py"
click node_message_handler "https://github.com/achyantsh/herobrine-ai/blob/master/discord_bot/handlers/message_handler.py"
click node_bot_api "https://github.com/achyantsh/herobrine-ai/blob/master/discord_bot/services/herobrine_api.py"
click node_api_entry "https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/main.py"
click node_api_auth "https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/auth/internal_api.py"
click node_ai_ingestion "https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/services/ai_ingestion_service.py"
click node_parsers "https://github.com/achyantsh/herobrine-ai/tree/master/backend/app/parsers"
click node_text_ai "https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/ai/extractor.py"
click node_vision_ai "https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/services/gemini_vision_service.py"
click node_mapping "https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/ai/mapper.py"
click node_commitment_service "https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/services/commitment_service.py"
click node_repository "https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/repositories/commitment_repository.py"
click node_commitment_store "https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/models/commitment.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_webapp,node_commitment_views,node_calendar,node_analytics,node_dashboard,node_upload,node_user,node_discord_user toneBlue
class node_supabase_auth,node_auth_guard,node_jwt_auth,node_discord_link,node_profiles toneAmber
class node_bot,node_message_handler,node_bot_api toneMint
class node_ai_ingestion,node_parsers,node_text_ai,node_vision_ai,node_mapping toneRose
class node_api_entry,node_api_auth,node_commitment_service,node_repository,node_commitment_store,node_gemini toneIndigo
```

## Components

### Web product

- [Web application](https://github.com/achyantsh/herobrine-ai/tree/master/frontend/app): `frontend/app`
- [Commitment views](https://github.com/achyantsh/herobrine-ai/blob/master/frontend/app/commitments/page.tsx): `frontend/app/commitments/page.tsx`
- [Calendar](https://github.com/achyantsh/herobrine-ai/blob/master/frontend/app/calendar/page.tsx): `frontend/app/calendar/page.tsx`
- [Analytics](https://github.com/achyantsh/herobrine-ai/blob/master/frontend/app/analytics/page.tsx): `frontend/app/analytics/page.tsx`
- [Dashboard and reminders](https://github.com/achyantsh/herobrine-ai/blob/master/frontend/app/dashboard/page.tsx): `frontend/app/dashboard/page.tsx`
- [AI upload planner](https://github.com/achyantsh/herobrine-ai/blob/master/frontend/components/upload/UploadDialog.tsx): `frontend/components/upload/UploadDialog.tsx`

### Identity and linking

- **Supabase auth**
- [Session handling](https://github.com/achyantsh/herobrine-ai/blob/master/frontend/components/auth/AuthProvider.tsx): `frontend/components/auth/AuthProvider.tsx`
- [JWT verification](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/auth/dependencies.py): `backend/app/auth/dependencies.py`
- [Discord account linking](https://github.com/achyantsh/herobrine-ai/blob/master/frontend/app/api/discord/callback/route.ts): `frontend/app/api/discord/callback/route.ts`
- **Supabase profiles**

### Discord capture

- [Discord bot](https://github.com/achyantsh/herobrine-ai/blob/master/discord_bot/bot.py): `discord_bot/bot.py`
- [Message and attachment handler](https://github.com/achyantsh/herobrine-ai/blob/master/discord_bot/handlers/message_handler.py): `discord_bot/handlers/message_handler.py`
- [Backend HTTP client](https://github.com/achyantsh/herobrine-ai/blob/master/discord_bot/services/herobrine_api.py): `discord_bot/services/herobrine_api.py`

### Ingestion and AI

- [AI ingestion orchestration](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/services/ai_ingestion_service.py): `backend/app/services/ai_ingestion_service.py`
- [Image, PDF, voice parsers](https://github.com/achyantsh/herobrine-ai/tree/master/backend/app/parsers): `backend/app/parsers`
- [Text extraction and prompts](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/ai/extractor.py): `backend/app/ai/extractor.py`
- [Image understanding](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/services/gemini_vision_service.py): `backend/app/services/gemini_vision_service.py`
- [Commitment mapping](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/ai/mapper.py): `backend/app/ai/mapper.py`

### Commitment backend

- [FastAPI routes](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/main.py): `backend/app/main.py`
- [Internal API protection](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/auth/internal_api.py): `backend/app/auth/internal_api.py`
- [Commitment rules](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/services/commitment_service.py): `backend/app/services/commitment_service.py`
- [Commitment repository](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/repositories/commitment_repository.py): `backend/app/repositories/commitment_repository.py`
- [PostgreSQL commitments](https://github.com/achyantsh/herobrine-ai/blob/master/backend/app/models/commitment.py): `backend/app/models/commitment.py`

### Other components

- **User**
- **Discord user**
- **Google Gemini**

## Connections

- User → Web application: uses
- User → Discord bot: mentions
- Web application → Supabase auth: authenticates
- Web application → FastAPI routes: calls API
- Web application → Commitment views: presents
- Web application → Calendar: presents
- Web application → Analytics: presents
- Web application → Dashboard and reminders: presents
- Web application → AI upload planner: captures input
- Session handling → Supabase auth: uses session
- Web application → Discord account linking: starts linking
- Discord account linking → Supabase profiles: updates link
- Discord bot → Message and attachment handler: registers handler (evidence: `discord_bot/bot.py`)
- Message and attachment handler → Supabase profiles: resolves account
- Message and attachment handler → Backend HTTP client: sends input (evidence: `discord_bot/handlers/message_handler.py`)
- Backend HTTP client → FastAPI routes: posts ingestion (evidence: `discord_bot/services/herobrine_api.py`)
- FastAPI routes → Internal API protection: protects internal routes
- FastAPI routes → JWT verification: authenticates users (evidence: `backend/app/main.py`)
- FastAPI routes → AI ingestion orchestration: routes ingestion
- FastAPI routes → Commitment rules: routes management
- FastAPI routes → AI ingestion orchestration: routes Discord input
- AI ingestion orchestration → Image, PDF, voice parsers: parses files (evidence: `backend/app/services/ai_ingestion_service.py`)
- AI ingestion orchestration → Text extraction and prompts: extracts text input (evidence: `backend/app/services/ai_ingestion_service.py`)
- AI ingestion orchestration → Image understanding: processes images (evidence: `backend/app/services/ai_ingestion_service.py`)
- Text extraction and prompts → Google Gemini: generates extraction
- Image understanding → Google Gemini: analyzes images (evidence: `backend/app/services/gemini_vision_service.py`)
- AI ingestion orchestration → Commitment mapping: maps results (evidence: `backend/app/services/ai_ingestion_service.py`)
- AI ingestion orchestration → Commitment rules: persists extracted (evidence: `backend/app/services/ai_ingestion_service.py`)
- Commitment rules → Commitment repository: delegates persistence (evidence: `backend/app/services/commitment_service.py`)
- Commitment repository → PostgreSQL commitments: reads and writes (evidence: `backend/app/repositories/commitment_repository.py`)
- PostgreSQL commitments → FastAPI routes: serves commitment data
