# dualsynapse/jdih-bp2mi-qdrant-rag architecture

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

- Interactive diagram: https://gitdiagram.com/dualsynapse/jdih-bp2mi-qdrant-rag
- Repository: https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag

## Overview

This repository ingests Indonesian legal documents into tiered Qdrant collections. Its main workflow loads and filters category metadata, fetches each PDF, converts and chunks its text, builds contextual content, then embeds and upserts points. The graph also shows hierarchy classification and collection routing as separate domain stages. Edges reflect calls visible in the excerpts or workflow explicitly documented in the README; the sampled source does not show a separate runtime consumer for the stored vectors.

Main entry points: [`rag_ingestion/main.py`](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/main.py) (Pipeline orchestrator), [`rag_ingestion/pipeline/upserter.py`](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/upserter.py) (Batch upserter), [`rag_ingestion/config.py`](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/config.py) (Pipeline configuration), [`rag_ingestion/pipeline/loader.py`](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/loader.py) (Metadata loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Ingestion control"]
  node_config["Pipeline configuration<br/>[config.py]"]
  node_orchestrator["Pipeline orchestrator<br/>[main.py]"]
  node_loader["Metadata loader<br/>[loader.py]"]
end

subgraph group_processing["Document processing"]
  node_fetcher["PDF fetcher<br/>[fetcher.py]"]
  node_converter["PDF converter<br/>[converter.py]"]
  node_chunker["Article chunker<br/>[chunker.py]"]
  node_context["Context builder<br/>[context_builder.py]"]
end

subgraph group_classification["Legal classification"]
  node_hierarchy["Authority hierarchy<br/>[hierarchy.py]"]
  node_router["Collection router"]
end

subgraph group_storage["Embedding and storage"]
  node_embedder["Local embedder<br/>[embedder.py]"]
  node_upserter["Batch upserter<br/>[upserter.py]"]
  node_qdrant[("Qdrant collections")]
end

node_operator(("Pipeline operator"))
node_metadata["Category metadata"]

node_operator -->|"runs pipeline"| node_orchestrator
node_metadata -->|"provides JSON"| node_loader
node_orchestrator -->|"loads documents"| node_loader
node_loader -->|"reads limits"| node_config
node_orchestrator -->|"classifies category"| node_hierarchy
node_orchestrator -->|"fetches PDF"| node_fetcher
node_fetcher -->|"reads timeout"| node_config
node_orchestrator -->|"converts PDF"| node_converter
node_orchestrator -->|"chunks Markdown"| node_chunker
node_orchestrator -->|"builds content"| node_context
node_orchestrator -->|"submits chunks"| node_upserter
node_upserter -->|"embeds content"| node_embedder
node_embedder -->|"reads model"| node_config
node_upserter -->|"selects collection"| node_router
node_upserter -->|"upserts points"| node_qdrant
node_upserter -->|"reads credentials and collections"| node_config
node_router -->|"reads collection names"| node_config

click node_config "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/config.py"
click node_orchestrator "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/main.py"
click node_loader "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/loader.py"
click node_hierarchy "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/utils/hierarchy.py"
click node_fetcher "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/fetcher.py"
click node_converter "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/converter.py"
click node_chunker "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/chunker.py"
click node_context "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/context_builder.py"
click node_embedder "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/embedder.py"
click node_router "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/utils/collection_router.py"
click node_upserter "https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/upserter.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_config,node_orchestrator,node_loader toneBlue
class node_fetcher,node_converter,node_chunker,node_context toneAmber
class node_hierarchy,node_router toneMint
class node_embedder,node_upserter,node_qdrant toneRose
class node_operator,node_metadata toneIndigo
```

## Components

### Ingestion control

- [Pipeline configuration](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/config.py): `rag_ingestion/config.py`
- [Pipeline orchestrator](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/main.py): `rag_ingestion/main.py`
- [Metadata loader](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/loader.py): `rag_ingestion/pipeline/loader.py`

### Document processing

- [PDF fetcher](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/fetcher.py): `rag_ingestion/pipeline/fetcher.py`
- [PDF converter](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/converter.py): `rag_ingestion/pipeline/converter.py`
- [Article chunker](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/chunker.py): `rag_ingestion/pipeline/chunker.py`
- [Context builder](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/context_builder.py): `rag_ingestion/pipeline/context_builder.py`

### Legal classification

- [Authority hierarchy](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/utils/hierarchy.py): `rag_ingestion/utils/hierarchy.py`
- [Collection router](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/utils/collection_router.py): `rag_ingestion/utils/collection_router.py`

### Embedding and storage

- [Local embedder](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/embedder.py): `rag_ingestion/pipeline/embedder.py`
- [Batch upserter](https://github.com/dualsynapse/jdih-bp2mi-qdrant-rag/blob/main/rag_ingestion/pipeline/upserter.py): `rag_ingestion/pipeline/upserter.py`
- **Qdrant collections**

### Other components

- **Pipeline operator**
- **Category metadata**

## Connections

- Pipeline operator → Pipeline orchestrator: runs pipeline (evidence: `README.md`)
- Category metadata → Metadata loader: provides JSON (evidence: `README.md`)
- Pipeline orchestrator → Metadata loader: loads documents (evidence: `rag_ingestion/main.py`)
- Metadata loader → Pipeline configuration: reads limits (evidence: `rag_ingestion/pipeline/loader.py`)
- Pipeline orchestrator → Authority hierarchy: classifies category (evidence: `rag_ingestion/main.py`)
- Pipeline orchestrator → PDF fetcher: fetches PDF (evidence: `rag_ingestion/main.py`)
- PDF fetcher → Pipeline configuration: reads timeout (evidence: `rag_ingestion/pipeline/fetcher.py`)
- Pipeline orchestrator → PDF converter: converts PDF (evidence: `rag_ingestion/main.py`)
- Pipeline orchestrator → Article chunker: chunks Markdown (evidence: `rag_ingestion/main.py`)
- Pipeline orchestrator → Context builder: builds content (evidence: `rag_ingestion/main.py`)
- Pipeline orchestrator → Batch upserter: submits chunks (evidence: `rag_ingestion/main.py`)
- Batch upserter → Local embedder: embeds content (evidence: `rag_ingestion/pipeline/upserter.py`)
- Local embedder → Pipeline configuration: reads model (evidence: `rag_ingestion/pipeline/embedder.py`)
- Batch upserter → Collection router: selects collection (evidence: `rag_ingestion/pipeline/upserter.py`)
- Batch upserter → Qdrant collections: upserts points (evidence: `rag_ingestion/pipeline/upserter.py`)
- Batch upserter → Pipeline configuration: reads credentials and collections (evidence: `rag_ingestion/pipeline/upserter.py`)
- Collection router → Pipeline configuration: reads collection names (evidence: `rag_ingestion/utils/collection_router.py`)
