# radsrei/pac-resposta-de-nimb architecture

> Architecture diagram of the GitHub repository radsrei/pac-resposta-de-nimb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/radsrei/pac-resposta-de-nimb
- Repository: https://github.com/radsrei/pac-resposta-de-nimb

## Overview

Nimb is a Tormenta20 book-grounded question-answering application with a React interface and FastAPI backend. Users authenticate, choose or configure an LLM, ask questions, and receive answers grounded in authorized book passages; successful exchanges are saved as chat sessions. Books are prepared separately by the vector builder, then cataloged for retrieval. The README also identifies book upload/validation, treasure rolls, and chaos behavior as product capabilities. Some backend and frontend modules were not sampled, so those branches are shown only where the index or README supports them.

Main entry points: [`backend/vector_builder/cli.py`](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/vector_builder/cli.py) (Index builder), [`backend/app/controllers/query_controller.py`](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/query_controller.py) (Question handling), [`backend/app/main.py`](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/main.py) (FastAPI app), [`frontend/V2 - front Studio/src/App.tsx`](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/frontend/V2%20-%20front%20Studio/src/App.tsx) (Auth gate)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["User interface"]
  node_app["Auth gate<br/>[App.tsx]"]
  node_terminal["Nimb terminal<br/>[Terminal.tsx]"]
  node_frontend_api["Frontend API clients"]
end

subgraph group_api["API and identity"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_auth["Authentication<br/>[auth_controller.py]"]
  node_rag_routes["RAG routes<br/>[rag.py]"]
  node_sqlite[("Application database<br/>[database.py]")]
end

subgraph group_rag["Book answers"]
  node_query["Question handling"]
  node_retrieval["Book retrieval<br/>[retrieval.py]"]
  node_catalog["Book catalog<br/>[book_catalog.py]"]
  node_vector_store[("Book indexes<br/>[book_catalog.py]")]
  node_embeddings["Embedding service<br/>[embeddings.py]"]
end

subgraph group_content["Book preparation"]
  node_book_admin["Book upload and checks<br/>[book_controller.py]"]
  node_builder["Index builder<br/>[cli.py]"]
  node_extract["PDF extraction<br/>[extract.py]"]
  node_chunking["Passage chunking<br/>[chunking.py]"]
  node_table_parse["Table parsing<br/>[tables.py]"]
end

subgraph group_extras["LLM and extras"]
  node_llm_config["LLM connections<br/>[llm_controller.py]"]
  node_llm_repo[("LLM settings store<br/>[llm_repository.py]")]
  node_llm_client["LLM client<br/>[llm_client.py]"]
  node_sessions[("Chat history")]
  node_treasure["Treasure rolls"]
end

node_user(("Player"))
node_google["Google sign-in"]
node_external_llm["LLM provider"]

node_user -->|"uses"| node_app
node_app -->|"opens when signed in"| node_terminal
node_app -->|"checks session"| node_frontend_api
node_frontend_api -.->|"calls API"| node_fastapi
node_google -.->|"authenticates"| node_auth
node_fastapi -->|"registers"| node_rag_routes
node_fastapi -->|"seeds LLM settings"| node_auth
node_rag_routes -->|"routes questions"| node_query
node_query -->|"searches passages"| node_retrieval
node_query -->|"resolves connection"| node_llm_repo
node_query -->|"requests answer"| node_llm_client
node_query -->|"saves exchange"| node_sessions
node_retrieval -->|"locates book data"| node_catalog
node_catalog -->|"reads index files"| node_vector_store
node_retrieval -->|"embeds query"| node_embeddings
node_book_admin -->|"serves book routes"| node_rag_routes
node_builder -->|"extracts content"| node_extract
node_builder -->|"chunks content"| node_chunking
node_builder -->|"builds table data"| node_table_parse
node_builder -->|"registers books"| node_catalog
node_builder -->|"writes indexes"| node_vector_store
node_llm_config -->|"stores connections"| node_llm_repo
node_llm_client -->|"sends prompts"| node_external_llm
node_fastapi -->|"initializes database"| node_sqlite
node_treasure -.->|"persists rolls"| node_sqlite

click node_app "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/frontend/V2%20-%20front%20Studio/src/App.tsx"
click node_terminal "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/frontend/V2%20-%20front%20Studio/src/Terminal.tsx"
click node_frontend_api "https://github.com/radsrei/pac-resposta-de-nimb/tree/main/frontend/V2%20-%20front%20Studio/src/services"
click node_fastapi "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/main.py"
click node_auth "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/auth_controller.py"
click node_rag_routes "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/routers/rag.py"
click node_query "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/query_controller.py"
click node_retrieval "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/services/retrieval.py"
click node_catalog "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/services/book_catalog.py"
click node_vector_store "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/services/book_catalog.py"
click node_embeddings "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/services/embeddings.py"
click node_book_admin "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/book_controller.py"
click node_builder "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/vector_builder/cli.py"
click node_extract "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/vector_builder/extract.py"
click node_chunking "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/vector_builder/chunking.py"
click node_table_parse "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/vector_builder/tables.py"
click node_llm_config "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/llm_controller.py"
click node_llm_repo "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/repositories/llm_repository.py"
click node_llm_client "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/services/llm_client.py"
click node_sessions "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/repositories/session_repository.py"
click node_treasure "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/treasure_controller.py"
click node_sqlite "https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/db/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_app,node_terminal,node_frontend_api toneBlue
class node_fastapi,node_auth,node_rag_routes,node_sqlite toneAmber
class node_query,node_retrieval,node_catalog,node_vector_store,node_embeddings toneMint
class node_book_admin,node_builder,node_extract,node_chunking,node_table_parse toneRose
class node_llm_config,node_llm_repo,node_llm_client,node_sessions,node_treasure,node_user,node_google,node_external_llm toneIndigo
```

## Components

### User interface

- [Auth gate](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/frontend/V2%20-%20front%20Studio/src/App.tsx): `frontend/V2 - front Studio/src/App.tsx`
- [Nimb terminal](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/frontend/V2%20-%20front%20Studio/src/Terminal.tsx): `frontend/V2 - front Studio/src/Terminal.tsx`
- [Frontend API clients](https://github.com/radsrei/pac-resposta-de-nimb/tree/main/frontend/V2%20-%20front%20Studio/src/services): `frontend/V2 - front Studio/src/services`

### API and identity

- [FastAPI app](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/auth_controller.py): `backend/app/controllers/auth_controller.py`
- [RAG routes](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/routers/rag.py): `backend/app/routers/rag.py`
- [Application database](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/db/database.py): `backend/app/db/database.py`

### Book answers

- [Question handling](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/query_controller.py): `backend/app/controllers/query_controller.py`
- [Book retrieval](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/services/retrieval.py): `backend/app/services/retrieval.py`
- [Book catalog](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/services/book_catalog.py): `backend/app/services/book_catalog.py`
- [Book indexes](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/services/book_catalog.py): `backend/app/services/book_catalog.py`
- [Embedding service](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/services/embeddings.py): `backend/app/services/embeddings.py`

### Book preparation

- [Book upload and checks](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/book_controller.py): `backend/app/controllers/book_controller.py`
- [Index builder](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/vector_builder/cli.py): `backend/vector_builder/cli.py`
- [PDF extraction](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/vector_builder/extract.py): `backend/vector_builder/extract.py`
- [Passage chunking](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/vector_builder/chunking.py): `backend/vector_builder/chunking.py`
- [Table parsing](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/vector_builder/tables.py): `backend/vector_builder/tables.py`

### LLM and extras

- [LLM connections](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/llm_controller.py): `backend/app/controllers/llm_controller.py`
- [LLM settings store](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/repositories/llm_repository.py): `backend/app/repositories/llm_repository.py`
- [LLM client](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/services/llm_client.py): `backend/app/services/llm_client.py`
- [Chat history](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/repositories/session_repository.py): `backend/app/repositories/session_repository.py`
- [Treasure rolls](https://github.com/radsrei/pac-resposta-de-nimb/blob/main/backend/app/controllers/treasure_controller.py): `backend/app/controllers/treasure_controller.py`

### Other components

- **Player**
- **Google sign-in**
- **LLM provider**

## Connections

- Player → Auth gate: uses
- Auth gate → Nimb terminal: opens when signed in (evidence: `frontend/V2 - front Studio/src/App.tsx`)
- Auth gate → Frontend API clients: checks session (evidence: `frontend/V2 - front Studio/src/App.tsx`)
- Frontend API clients → FastAPI app: calls API
- Google sign-in → Authentication: authenticates
- FastAPI app → RAG routes: registers (evidence: `backend/app/main.py`)
- FastAPI app → Authentication: seeds LLM settings (evidence: `backend/app/main.py`)
- RAG routes → Question handling: routes questions (evidence: `backend/app/routers/rag.py`)
- Question handling → Book retrieval: searches passages (evidence: `backend/app/controllers/query_controller.py`)
- Question handling → LLM settings store: resolves connection (evidence: `backend/app/controllers/query_controller.py`)
- Question handling → LLM client: requests answer (evidence: `backend/app/controllers/query_controller.py`)
- Question handling → Chat history: saves exchange (evidence: `backend/app/controllers/query_controller.py`)
- Book retrieval → Book catalog: locates book data (evidence: `backend/app/services/retrieval.py`)
- Book catalog → Book indexes: reads index files (evidence: `backend/app/services/book_catalog.py`)
- Book retrieval → Embedding service: embeds query (evidence: `backend/app/services/retrieval.py`)
- Book upload and checks → RAG routes: serves book routes (evidence: `backend/app/routers/rag.py`)
- Index builder → PDF extraction: extracts content (evidence: `backend/vector_builder/cli.py`)
- Index builder → Passage chunking: chunks content (evidence: `backend/vector_builder/cli.py`)
- Index builder → Table parsing: builds table data (evidence: `backend/vector_builder/cli.py`)
- Index builder → Book catalog: registers books (evidence: `backend/vector_builder/cli.py`)
- Index builder → Book indexes: writes indexes (evidence: `backend/vector_builder/cli.py`)
- LLM connections → LLM settings store: stores connections (evidence: `backend/app/controllers/llm_controller.py`)
- LLM client → LLM provider: sends prompts (evidence: `backend/app/services/llm_client.py`)
- FastAPI app → Application database: initializes database (evidence: `backend/app/main.py`)
- Treasure rolls → Application database: persists rolls
