# leonelzalegas/promtior-challenge architecture

> Architecture diagram of the GitHub repository leonelzalegas/promtior-challenge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leonelzalegas/promtior-challenge
- Repository: https://github.com/leonelzalegas/promtior-challenge

## Overview

##### Project type and purpose
- This is a full-stack Retrieval-Augmented Generation (RAG) Q&A system built with LangChain, FastAPI, a static HTML/CSS/JS frontend, and a Chroma vector store.
- Offline: document ingestion, chunking, embedding, indexing.
- Online: retrieval + generation via a REST API.

##### File structure
- Top level: Dockerfile, .dockerignore, .gitignore, requirements.txt, ExtraInfo.pdf, README.md
- app/
– ingestion.py – crawls web + PDF via LangChain loaders, chunks, embeds, writes vectors to Chroma
– rag_chain.py – loads vector store, builds RetrievalQA chain, calls Gemini LLM
– __init__.py
- main.py – FastAPI server exposing REST endpoints
- static/index.html – simple JS frontend that calls the FastAPI backend

##### README for additional insights
- Embedding: GoogleGenerativeAIEmbedding
- Vector store: Chroma
- LLM: Google Gemini via langchain_google_genai
- Frontend – REST calls to FastAPI
- Deployment: Docker → AWS App Runner (ECR) & Railway
- Cache experiment discarded; no persistent cache layer

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Offline Pipeline"
        direction TB
        Ingestion["Ingestion Module\n(ingestion.py)"]:::backend
        Chunker["Chunker"]:::backend
        EmbedAPI["External Embedding API\n(GoogleGenerativeAIEmbedding)"]:::external
        VectorStore["Chroma Vector Store"]:::datastore
        Ingestion -->|"chunk → embed"| Chunker
        Chunker -->|"embed"| EmbedAPI
        EmbedAPI -->|"store embeddings"| VectorStore
    end

    subgraph "Online Pipeline"
        direction TB
        Browser["User Browser + Static Frontend"]:::frontend
        API["FastAPI Backend\n(main.py)"]:::backend
        RagChain["RAG Chain Module\n(rag_chain.py)"]:::backend
        VectorStore2["Chroma Vector Store"]:::datastore
        LLMAPI["External LLM API\n(Gemini)"]:::external
        Browser -->|"REST query"| API
        API -->|"calls rag_chain"| RagChain
        RagChain -->|"retrieve top-k"| VectorStore2
        RagChain -->|"generate answer"| LLMAPI
        LLMAPI -->|"return response"| RagChain
        RagChain -->|"response"| API
        API -->|"HTTP response"| Browser
    end

    subgraph "Project Files & Config"
        direction TB
        Init["App Initialization\n(__init__.py)"]:::backend
        Requirements["requirements.txt"]:::deployment
        DockerfileNode["Dockerfile"]:::deployment
        Dockerignore[".dockerignore"]:::deployment
        Gitignore[".gitignore"]:::deployment
        Readme["README.md"]:::deployment
        ExtraInfo["ExtraInfo.pdf"]:::deployment
    end

    subgraph "Deployment Workflow"
        direction TB
        DockerfileNode -->|"build image"| Registry["Container Registry\n(ECR / Railway)"]:::deployment
        Registry -->|"deploy"| Runner["AWS App Runner / Railway"]:::deployment
    end

    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef backend fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef datastore fill:#ffeb99,stroke:#333,stroke-width:1px
    classDef external fill:#f8d7da,stroke:#333,stroke-width:1px
    classDef deployment fill:#e2e3e5,stroke:#333,stroke-width:1px

    click Browser "https://github.com/leonelzalegas/promtior-challenge/blob/main/static/index.html"
    click API "https://github.com/leonelzalegas/promtior-challenge/blob/main/main.py"
    click Ingestion "https://github.com/leonelzalegas/promtior-challenge/blob/main/app/ingestion.py"
    click RagChain "https://github.com/leonelzalegas/promtior-challenge/blob/main/app/rag_chain.py"
    click Init "https://github.com/leonelzalegas/promtior-challenge/blob/main/app/__init__.py"
    click Requirements "https://github.com/leonelzalegas/promtior-challenge/blob/main/requirements.txt"
    click DockerfileNode "https://github.com/leonelzalegas/promtior-challenge/tree/main/Dockerfile"
    click Dockerignore "https://github.com/leonelzalegas/promtior-challenge/blob/main/.dockerignore"
    click Gitignore "https://github.com/leonelzalegas/promtior-challenge/blob/main/.gitignore"
    click Readme "https://github.com/leonelzalegas/promtior-challenge/blob/main/README.md"
    click ExtraInfo "https://github.com/leonelzalegas/promtior-challenge/blob/main/ExtraInfo.pdf"
```
