# miracodeai/mira architecture

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

- Interactive diagram: https://gitdiagram.com/miracodeai/mira
- Repository: https://github.com/miracodeai/mira

## Overview

Mira is a self-hosted AI code-review service. A code-host webhook dispatches pull-request events to shared handlers, which run the review engine and post findings through a platform provider. Separate workflows index repositories, scan dependencies for vulnerabilities, and expose review, repository, and organization signals through the dashboard. The README documents these capabilities; some implementation details—especially security scanning and dashboard persistence—were not sampled, so those links are shown only where documented or supported by the source index.

Main entry points: [`src/mira/index/indexer.py`](https://github.com/miracodeai/mira/blob/main/src/mira/index/indexer.py) (Repository indexer), [`src/mira/core/engine.py`](https://github.com/miracodeai/mira/blob/main/src/mira/core/engine.py) (Review engine), [`src/mira/platforms/handlers.py`](https://github.com/miracodeai/mira/blob/main/src/mira/platforms/handlers.py) (Shared handlers), [`src/mira/dashboard/api.py`](https://github.com/miracodeai/mira/blob/main/src/mira/dashboard/api.py) (Dashboard API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_review["Review workflow"]
  node_engine["Review engine<br/>[engine.py]"]
  node_review_context["Review context<br/>[context.py]"]
  node_llm["LLM providers<br/>[base.py]"]
  node_feedback["Learning loop<br/>[feedback.py]"]
  node_config["Configuration<br/>[config.py]"]
end

subgraph group_index["Code intelligence"]
  node_repo_fetch["Repository fetch<br/>[fetch.py]"]
  node_index_handlers["Index handlers<br/>[index_handlers.py]"]
  node_indexer["Repository indexer<br/>[indexer.py]"]
  node_relationships["Code relationships<br/>[relationships.py]"]
  node_index_store[("Code index store<br/>[store.py]")]
  node_security["Vulnerability scanning<br/>[poller.py]"]
end

subgraph group_platforms["Host integrations"]
  node_webhook_entry["Webhook handlers<br/>[webhook.py]"]
  node_shared_handlers["Shared handlers<br/>[handlers.py]"]
  node_provider["Host providers<br/>[github.py]"]
end

subgraph group_dashboard["Dashboard and data"]
  node_dashboard_ui["Dashboard UI<br/>[App.tsx]"]
  node_dashboard_api["Dashboard API<br/>[api.py]"]
  node_dashboard_db[("Dashboard data<br/>[db.py]")]
end

subgraph group_integrations["External services"]
  node_outbound["Outbound notifications"]
end

node_developer(("Engineer"))
node_codehost(("Code host"))
node_osv(("OSV.dev"))
node_notification_targets(("Slack, Teams, JSON"))

node_codehost -->|"sends events"| node_webhook_entry
node_webhook_entry -->|"dispatches reviews"| node_shared_handlers
node_shared_handlers -->|"runs review"| node_engine
node_shared_handlers -->|"uses provider"| node_provider
node_engine -->|"builds context"| node_review_context
node_engine -->|"requests analysis"| node_llm
node_engine -->|"reads index"| node_index_store
node_shared_handlers -->|"synthesizes rules"| node_feedback
node_shared_handlers -->|"dispatches events"| node_outbound
node_provider -->|"posts review"| node_codehost
node_webhook_entry -->|"routes push indexing"| node_index_handlers
node_index_handlers -->|"indexes changes"| node_indexer
node_index_handlers -->|"supplies fetcher"| node_repo_fetch
node_indexer -->|"fetches repository files"| node_repo_fetch
node_indexer -->|"writes index"| node_index_store
node_indexer -->|"summarizes files"| node_llm
node_index_store -.->|"stores dependencies"| node_relationships
node_developer -->|"views signals"| node_dashboard_ui
node_dashboard_ui -.->|"requests dashboard data"| node_dashboard_api
node_dashboard_api -->|"reads dashboard data"| node_dashboard_db
node_dashboard_api -->|"starts indexing"| node_indexer
node_dashboard_api -->|"queries code index"| node_index_store
node_dashboard_api -->|"queries relationships"| node_relationships
node_security -->|"polls advisories"| node_osv
node_security -.->|"checks dependencies"| node_index_store
node_outbound -->|"delivers events"| node_notification_targets
node_engine -->|"uses settings"| node_config
node_indexer -->|"uses settings"| node_config

click node_webhook_entry "https://github.com/miracodeai/mira/blob/main/src/mira/platforms/github/webhook.py"
click node_shared_handlers "https://github.com/miracodeai/mira/blob/main/src/mira/platforms/handlers.py"
click node_provider "https://github.com/miracodeai/mira/blob/main/src/mira/providers/github.py"
click node_engine "https://github.com/miracodeai/mira/blob/main/src/mira/core/engine.py"
click node_review_context "https://github.com/miracodeai/mira/blob/main/src/mira/core/context.py"
click node_llm "https://github.com/miracodeai/mira/blob/main/src/mira/llm/base.py"
click node_feedback "https://github.com/miracodeai/mira/blob/main/src/mira/analysis/feedback.py"
click node_config "https://github.com/miracodeai/mira/blob/main/src/mira/config.py"
click node_repo_fetch "https://github.com/miracodeai/mira/blob/main/src/mira/platforms/fetch.py"
click node_index_handlers "https://github.com/miracodeai/mira/blob/main/src/mira/platforms/index_handlers.py"
click node_indexer "https://github.com/miracodeai/mira/blob/main/src/mira/index/indexer.py"
click node_relationships "https://github.com/miracodeai/mira/blob/main/src/mira/index/relationships.py"
click node_index_store "https://github.com/miracodeai/mira/blob/main/src/mira/index/store.py"
click node_security "https://github.com/miracodeai/mira/blob/main/src/mira/security/poller.py"
click node_dashboard_ui "https://github.com/miracodeai/mira/blob/main/ui/mira/src/App.tsx"
click node_dashboard_api "https://github.com/miracodeai/mira/blob/main/src/mira/dashboard/api.py"
click node_dashboard_db "https://github.com/miracodeai/mira/blob/main/src/mira/dashboard/db.py"
click node_outbound "https://github.com/miracodeai/mira/blob/main/src/mira/outbound_webhooks.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_engine,node_review_context,node_llm,node_feedback,node_config toneBlue
class node_repo_fetch,node_index_handlers,node_indexer,node_relationships,node_index_store,node_security toneAmber
class node_webhook_entry,node_shared_handlers,node_provider toneMint
class node_dashboard_ui,node_dashboard_api,node_dashboard_db toneRose
class node_outbound,node_developer,node_codehost,node_osv,node_notification_targets toneIndigo
```

## Components

### Review workflow

- [Review engine](https://github.com/miracodeai/mira/blob/main/src/mira/core/engine.py): `src/mira/core/engine.py`
- [Review context](https://github.com/miracodeai/mira/blob/main/src/mira/core/context.py): `src/mira/core/context.py`
- [LLM providers](https://github.com/miracodeai/mira/blob/main/src/mira/llm/base.py): `src/mira/llm/base.py`
- [Learning loop](https://github.com/miracodeai/mira/blob/main/src/mira/analysis/feedback.py): `src/mira/analysis/feedback.py`
- [Configuration](https://github.com/miracodeai/mira/blob/main/src/mira/config.py): `src/mira/config.py`

### Code intelligence

- [Repository fetch](https://github.com/miracodeai/mira/blob/main/src/mira/platforms/fetch.py): `src/mira/platforms/fetch.py`
- [Index handlers](https://github.com/miracodeai/mira/blob/main/src/mira/platforms/index_handlers.py): `src/mira/platforms/index_handlers.py`
- [Repository indexer](https://github.com/miracodeai/mira/blob/main/src/mira/index/indexer.py): `src/mira/index/indexer.py`
- [Code relationships](https://github.com/miracodeai/mira/blob/main/src/mira/index/relationships.py): `src/mira/index/relationships.py`
- [Code index store](https://github.com/miracodeai/mira/blob/main/src/mira/index/store.py): `src/mira/index/store.py`
- [Vulnerability scanning](https://github.com/miracodeai/mira/blob/main/src/mira/security/poller.py): `src/mira/security/poller.py`

### Host integrations

- [Webhook handlers](https://github.com/miracodeai/mira/blob/main/src/mira/platforms/github/webhook.py): `src/mira/platforms/github/webhook.py`
- [Shared handlers](https://github.com/miracodeai/mira/blob/main/src/mira/platforms/handlers.py): `src/mira/platforms/handlers.py`
- [Host providers](https://github.com/miracodeai/mira/blob/main/src/mira/providers/github.py): `src/mira/providers/github.py`

### Dashboard and data

- [Dashboard UI](https://github.com/miracodeai/mira/blob/main/ui/mira/src/App.tsx): `ui/mira/src/App.tsx`
- [Dashboard API](https://github.com/miracodeai/mira/blob/main/src/mira/dashboard/api.py): `src/mira/dashboard/api.py`
- [Dashboard data](https://github.com/miracodeai/mira/blob/main/src/mira/dashboard/db.py): `src/mira/dashboard/db.py`

### External services

- [Outbound notifications](https://github.com/miracodeai/mira/blob/main/src/mira/outbound_webhooks.py): `src/mira/outbound_webhooks.py`

### Other components

- **Engineer**
- **Code host**
- **OSV.dev**
- **Slack, Teams, JSON**

## Connections

- Code host → Webhook handlers: sends events (evidence: `src/mira/platforms/github/webhook.py`)
- Webhook handlers → Shared handlers: dispatches reviews (evidence: `src/mira/platforms/github/webhook.py`)
- Shared handlers → Review engine: runs review (evidence: `src/mira/platforms/handlers.py`)
- Shared handlers → Host providers: uses provider (evidence: `src/mira/platforms/handlers.py`)
- Review engine → Review context: builds context (evidence: `src/mira/core/engine.py`)
- Review engine → LLM providers: requests analysis (evidence: `src/mira/core/engine.py`)
- Review engine → Code index store: reads index (evidence: `src/mira/core/engine.py`)
- Shared handlers → Learning loop: synthesizes rules (evidence: `src/mira/platforms/handlers.py`)
- Shared handlers → Outbound notifications: dispatches events (evidence: `src/mira/platforms/handlers.py`)
- Host providers → Code host: posts review
- Webhook handlers → Index handlers: routes push indexing (evidence: `src/mira/platforms/github/webhook.py`)
- Index handlers → Repository indexer: indexes changes (evidence: `src/mira/platforms/index_handlers.py`)
- Index handlers → Repository fetch: supplies fetcher (evidence: `src/mira/platforms/index_handlers.py`)
- Repository indexer → Repository fetch: fetches repository files (evidence: `src/mira/index/indexer.py`)
- Repository indexer → Code index store: writes index (evidence: `src/mira/index/indexer.py`)
- Repository indexer → LLM providers: summarizes files (evidence: `src/mira/index/indexer.py`)
- Code index store → Code relationships: stores dependencies
- Engineer → Dashboard UI: views signals (evidence: `README.md`)
- Dashboard UI → Dashboard API: requests dashboard data
- Dashboard API → Dashboard data: reads dashboard data (evidence: `src/mira/dashboard/api.py`)
- Dashboard API → Repository indexer: starts indexing (evidence: `src/mira/dashboard/api.py`)
- Dashboard API → Code index store: queries code index (evidence: `src/mira/dashboard/api.py`)
- Dashboard API → Code relationships: queries relationships (evidence: `src/mira/dashboard/api.py`)
- Vulnerability scanning → OSV.dev: polls advisories (evidence: `README.md`)
- Vulnerability scanning → Code index store: checks dependencies
- Outbound notifications → Slack, Teams, JSON: delivers events (evidence: `src/mira/outbound_webhooks.py`)
- Review engine → Configuration: uses settings (evidence: `src/mira/core/engine.py`)
- Repository indexer → Configuration: uses settings (evidence: `src/mira/index/indexer.py`)
