# datcan-esc/ragitay architecture

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

- Interactive diagram: https://gitdiagram.com/datcan-esc/ragitay
- Repository: https://github.com/datcan-esc/ragitay

## Overview

RAGITAY is a legal-decision retrieval and analysis application. Its user workflow is natural-language search, hybrid retrieval of relevant passages, decision-level results, and—when requested—decision detail, a summary, or question-answering grounded in the selected decision. The ingestion subsystem discovers and normalizes source decisions and prepares searchable chunks and embeddings. Backend call edges are supported by excerpts or the source index; frontend/API and some ingestion/storage links rely on README statements because the relevant implementation was not sampled.

Main entry points: [`backend/app/routers/search.py`](https://github.com/datcan-esc/ragitay/blob/main/backend/app/routers/search.py) (Search API), [`backend/app/repositories/search_repository.py`](https://github.com/datcan-esc/ragitay/blob/main/backend/app/repositories/search_repository.py) (Chunk retrieval), [`backend/app/services/search_service.py`](https://github.com/datcan-esc/ragitay/blob/main/backend/app/services/search_service.py) (Hybrid retrieval), [`frontend/components/search-demo.tsx`](https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo.tsx) (Search workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Search interface"]
  node_search_ui["Search workspace<br/>[search-demo.tsx]"]
  node_filters["Search filters<br/>[filters-modal.tsx]"]
  node_results["Decision results<br/>[results-list.tsx]"]
  node_decision_detail_ui["Decision detail<br/>[detail-panel.tsx]"]
  node_decision_chat_ui["Decision Q&amp;A"]
end

subgraph group_backend["Retrieval and APIs"]
  node_search_api["Search API<br/>[search.py]"]
  node_search_service["Hybrid retrieval<br/>[search_service.py]"]
  node_embedding_service["Query embeddings"]
  node_search_repository["Chunk retrieval"]
  node_summary_service["AI summaries<br/>[summary_service.py]"]
  node_chat_service["Decision answers"]
  node_app["API application<br/>[main.py]"]
end

subgraph group_ingestion["Decision ingestion"]
  node_discovery["Source discovery<br/>[pipeline.py]"]
  node_source_client["Source client<br/>[yargitay_client.py]"]
  node_parser["Decision parser<br/>[parser.py]"]
  node_chunking["Passage chunking<br/>[chunking.py]"]
  node_ingest_embeddings["Passage embeddings<br/>[embeddings.py]"]
  node_ingest_database["Import database<br/>[database.py]"]
end

subgraph group_storage["Decision storage"]
  node_postgres[("PostgreSQL + pgvector")]
end

node_user(("Legal researcher"))
node_decision_source(("Decision source"))
node_llm_provider["LLM providers"]

node_user -->|"searches"| node_search_ui
node_search_ui -->|"sets filters"| node_filters
node_search_ui -->|"requests search"| node_search_api
node_search_api -->|"dispatches"| node_search_service
node_search_service -->|"embeds query"| node_embedding_service
node_search_service -->|"retrieves chunks"| node_search_repository
node_search_repository -->|"queries"| node_postgres
node_search_api -->|"dispatches summary"| node_summary_service
node_search_api -->|"dispatches Q&amp;A"| node_chat_service
node_search_service -->|"returns results"| node_results
node_results -->|"opens decision"| node_decision_detail_ui
node_decision_detail_ui -->|"requests detail"| node_search_api
node_decision_detail_ui -->|"offers Q&amp;A"| node_decision_chat_ui
node_decision_chat_ui -->|"asks question"| node_search_api
node_summary_service -->|"loads decision"| node_search_repository
node_chat_service -->|"loads decision"| node_search_repository
node_summary_service -.->|"generates summary"| node_llm_provider
node_chat_service -.->|"generates answer"| node_llm_provider
node_app -->|"registers routes"| node_search_api
node_decision_source -.->|"provides decisions"| node_source_client
node_discovery -->|"fetches records"| node_source_client
node_discovery -->|"parses records"| node_parser
node_parser -.->|"prepares passages"| node_chunking
node_chunking -.->|"embeds passages"| node_ingest_embeddings
node_ingest_embeddings -.->|"provides vectors"| node_ingest_database
node_ingest_database -.->|"imports decisions"| node_postgres
node_postgres -->|"stores searchable data"| node_search_repository

click node_search_ui "https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo.tsx"
click node_filters "https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo/filters-modal.tsx"
click node_results "https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo/results-list.tsx"
click node_decision_detail_ui "https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo/detail-panel.tsx"
click node_decision_chat_ui "https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo/decision-chat-panel.tsx"
click node_search_api "https://github.com/datcan-esc/ragitay/blob/main/backend/app/routers/search.py"
click node_search_service "https://github.com/datcan-esc/ragitay/blob/main/backend/app/services/search_service.py"
click node_embedding_service "https://github.com/datcan-esc/ragitay/blob/main/backend/app/services/embedding_service.py"
click node_search_repository "https://github.com/datcan-esc/ragitay/blob/main/backend/app/repositories/search_repository.py"
click node_summary_service "https://github.com/datcan-esc/ragitay/blob/main/backend/app/services/summary_service.py"
click node_chat_service "https://github.com/datcan-esc/ragitay/blob/main/backend/app/services/decision_chat_service.py"
click node_app "https://github.com/datcan-esc/ragitay/blob/main/backend/app/main.py"
click node_discovery "https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/pipeline.py"
click node_source_client "https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/yargitay_client.py"
click node_parser "https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/parser.py"
click node_chunking "https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/chunking.py"
click node_ingest_embeddings "https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/embeddings.py"
click node_ingest_database "https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/database.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_search_ui,node_filters,node_results,node_decision_detail_ui,node_decision_chat_ui toneBlue
class node_search_api,node_search_service,node_embedding_service,node_search_repository,node_summary_service,node_chat_service,node_app toneAmber
class node_discovery,node_source_client,node_parser,node_chunking,node_ingest_embeddings,node_ingest_database toneMint
class node_postgres toneRose
class node_user,node_decision_source,node_llm_provider toneIndigo
```

## Components

### Search interface

- [Search workspace](https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo.tsx): `frontend/components/search-demo.tsx`
- [Search filters](https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo/filters-modal.tsx): `frontend/components/search-demo/filters-modal.tsx`
- [Decision results](https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo/results-list.tsx): `frontend/components/search-demo/results-list.tsx`
- [Decision detail](https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo/detail-panel.tsx): `frontend/components/search-demo/detail-panel.tsx`
- [Decision Q&A](https://github.com/datcan-esc/ragitay/blob/main/frontend/components/search-demo/decision-chat-panel.tsx): `frontend/components/search-demo/decision-chat-panel.tsx`

### Retrieval and APIs

- [Search API](https://github.com/datcan-esc/ragitay/blob/main/backend/app/routers/search.py): `backend/app/routers/search.py`
- [Hybrid retrieval](https://github.com/datcan-esc/ragitay/blob/main/backend/app/services/search_service.py): `backend/app/services/search_service.py`
- [Query embeddings](https://github.com/datcan-esc/ragitay/blob/main/backend/app/services/embedding_service.py): `backend/app/services/embedding_service.py`
- [Chunk retrieval](https://github.com/datcan-esc/ragitay/blob/main/backend/app/repositories/search_repository.py): `backend/app/repositories/search_repository.py`
- [AI summaries](https://github.com/datcan-esc/ragitay/blob/main/backend/app/services/summary_service.py): `backend/app/services/summary_service.py`
- [Decision answers](https://github.com/datcan-esc/ragitay/blob/main/backend/app/services/decision_chat_service.py): `backend/app/services/decision_chat_service.py`
- [API application](https://github.com/datcan-esc/ragitay/blob/main/backend/app/main.py): `backend/app/main.py`

### Decision ingestion

- [Source discovery](https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/pipeline.py): `ingestion/src/ragitay/pipeline.py`
- [Source client](https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/yargitay_client.py): `ingestion/src/ragitay/yargitay_client.py`
- [Decision parser](https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/parser.py): `ingestion/src/ragitay/parser.py`
- [Passage chunking](https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/chunking.py): `ingestion/src/ragitay/chunking.py`
- [Passage embeddings](https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/embeddings.py): `ingestion/src/ragitay/embeddings.py`
- [Import database](https://github.com/datcan-esc/ragitay/blob/main/ingestion/src/ragitay/database.py): `ingestion/src/ragitay/database.py`

### Decision storage

- **PostgreSQL + pgvector**

### Other components

- **Legal researcher**
- **Decision source**
- **LLM providers**

## Connections

- Legal researcher → Search workspace: searches
- Search workspace → Search filters: sets filters
- Search workspace → Search API: requests search
- Search API → Hybrid retrieval: dispatches (evidence: `backend/app/routers/search.py`)
- Hybrid retrieval → Query embeddings: embeds query (evidence: `backend/app/services/search_service.py`)
- Hybrid retrieval → Chunk retrieval: retrieves chunks (evidence: `backend/app/services/search_service.py`)
- Chunk retrieval → PostgreSQL + pgvector: queries (evidence: `backend/app/repositories/search_repository.py`)
- Search API → AI summaries: dispatches summary (evidence: `backend/app/routers/search.py`)
- Search API → Decision answers: dispatches Q&A (evidence: `backend/app/routers/search.py`)
- Hybrid retrieval → Decision results: returns results
- Decision results → Decision detail: opens decision
- Decision detail → Search API: requests detail
- Decision detail → Decision Q&A: offers Q&A (evidence: `frontend/components/search-demo/detail-panel.tsx`)
- Decision Q&A → Search API: asks question
- AI summaries → Chunk retrieval: loads decision (evidence: `backend/app/services/summary_service.py`)
- Decision answers → Chunk retrieval: loads decision (evidence: `backend/app/services/decision_chat_service.py`)
- AI summaries → LLM providers: generates summary
- Decision answers → LLM providers: generates answer
- API application → Search API: registers routes (evidence: `backend/app/main.py`)
- Decision source → Source client: provides decisions
- Source discovery → Source client: fetches records (evidence: `ingestion/src/ragitay/pipeline.py`)
- Source discovery → Decision parser: parses records (evidence: `ingestion/src/ragitay/pipeline.py`)
- Decision parser → Passage chunking: prepares passages
- Passage chunking → Passage embeddings: embeds passages
- Passage embeddings → Import database: provides vectors
- Import database → PostgreSQL + pgvector: imports decisions
- PostgreSQL + pgvector → Chunk retrieval: stores searchable data (evidence: `backend/app/repositories/search_repository.py`)
