# abdelrahman-elshahed/hiring_system_using_rag architecture

> Architecture diagram of the GitHub repository abdelrahman-elshahed/hiring_system_using_rag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abdelrahman-elshahed/hiring_system_using_rag
- Repository: https://github.com/abdelrahman-elshahed/hiring_system_using_rag

## Overview

##### Project Type and Purpose
- This is a full-stack, Python-based recruiting/hiring system built around Retrieval-Augmented Generation (RAG).
- Purpose: present job requirements, ingest candidate info (CVs/applications), index candidate data, perform semantic search/ranking, and generate summaries or next-step recommendations using a language model.

##### File Structure
Top-Level Directories and Files:
- api/
– api/api.py: REST-style endpoints (e.g., submit CV, query candidates, generate responses).
- app/
– streamlit_app.py: the Streamlit UI front end.
- src/
– chat.py: handles chat interactions with the language model.
– vector_db.py: wraps FAISS vector index operations (load/index/search).
– text_chunking.py, text_processing.py: preprocess and split text for embedding.
– cv_management.py: ingest CVs into index, maintain metadata.
– ranking.py: score and rank candidates.
- db/
– cv_index.faiss: the FAISS vector index file.
– cv_metadata.pkl: serialized metadata (CV IDs, file paths, attributes).
- templates/
– job_application.html: Jinja2/HTML template for application UI (used by Streamlit or API).
- jobs/
– job_template_generator.py: generates new job requirement templates (likely based on a PDF or prompt).
- config/
– config/config.py: configuration (API keys, DB paths, model names).
- main.py & run_app.py: orchestration entrypoints (choose API server vs. interactive UI).

##### README
- README only gives the title “Hiring_System_Using_RAG.”

a. Components to include:
1. Frontend (Streamlit UI)
2. API Layer (Flask/FastAPI endpoints in api/api.py)
3. RAG Pipeline (chat.py + vector_db.py + text_*.py + ranking.py)
4. Vector Database (FAISS index + metadata in db/)
5. Job Template Generator (jobs/job_template_generator.py)
6. Configuration Module (config/config.py)
7. Data Storage (applications/*.json, CV files, PDFs)
8. External LLM Service (OpenAI or similar)

b. Relationships & Data Flow:
- Frontend ↔ API Layer: user clicks “submit CV” or “search,” Streamlit makes REST calls to api/api.py.
- API Layer → RAG Pipeline: invokes src/ modules to process text, chunk & embed, query FAISS, rank results, invoke chat with LLM.
- RAG Pipeline → Vector DB: vector_db.py loads or updates cv_index.faiss and cv_metadata.pkl.
- Job Template Generator reads/writes templates and can be exposed via API or CLI.
- Configuration is imported wherever needed (database paths, API keys).
- Results (ranked candidate list, summaries) are returned from API to Frontend.

c. Architectural Patterns & Principles:
- Layered architecture: Presentation (Streamlit), API/Controller, Service (RAG pipeline), Data Access (FAISS + file I/O).
- Modular design: each src/*.py is a single responsibility.
- Separation of concerns: config in one module, data in db/, templates in templates/.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["Streamlit UI"]:::frontend
        Template["job_application.html"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        API["api/api.py Controller"]:::backend
    end

    %% Service Layer
    subgraph "Service Layer"
        Chat["src/chat.py"]:::backend
        VectorDBWrapper["src/vector_db.py"]:::backend
        TextChunk["src/text_chunking.py"]:::backend
        TextProc["src/text_processing.py"]:::backend
        CVMgmt["src/cv_management.py"]:::backend
        Ranking["src/ranking.py"]:::backend
        JobTemplate["jobs/job_template_generator.py"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        FAISSIndex["cv_index.faiss"]:::data
        Metadata["cv_metadata.pkl"]:::data
        Apps["applications/"]:::data
    end

    %% External Services & Config
    External["External LLM Service"]:::external
    Config["config/config.py"]:::config

    %% Request Flows
    UI -->|"REST calls"| API
    Template -->|"renders form"| UI
    API -->|"invoke chat"| Chat
    API -->|"invoke vector db"| VectorDBWrapper
    API -->|"text chunking"| TextChunk
    API -->|"text processing"| TextProc
    API -->|"CV ingestion"| CVMgmt
    API -->|"candidate ranking"| Ranking
    API -->|"generate job template"| JobTemplate

    %% Service Interactions
    Chat -->|"embeddings & search"| VectorDBWrapper
    VectorDBWrapper --> FAISSIndex
    VectorDBWrapper --> Metadata
    CVMgmt -->|"reads/writes"| Apps
    Chat -->|"calls LLM"| External
    TextChunk -->|"chunks for"| TextProc

    %% Config Dependencies
    Config -.-> API
    Config -.-> Chat
    Config -.-> VectorDBWrapper
    Config -.-> TextChunk
    Config -.-> TextProc
    Config -.-> CVMgmt
    Config -.-> Ranking
    Config -.-> JobTemplate

    %% Click Events
    click UI "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/app/streamlit_app.py"
    click Template "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/templates/job_application.html"
    click API "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/api/api.py"
    click Chat "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/src/chat.py"
    click VectorDBWrapper "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/src/vector_db.py"
    click TextChunk "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/src/text_chunking.py"
    click TextProc "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/src/text_processing.py"
    click CVMgmt "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/src/cv_management.py"
    click Ranking "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/src/ranking.py"
    click JobTemplate "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/jobs/job_template_generator.py"
    click FAISSIndex "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/db/cv_index.faiss"
    click Metadata "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/db/cv_metadata.pkl"
    click Apps "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/tree/main/applications/"
    click Config "https://github.com/abdelrahman-elshahed/hiring_system_using_rag/blob/main/config/config.py"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#0366d6,color:#000;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,color:#000;
    classDef data fill:#FFE0B2,stroke:#EF6C00,color:#000;
    classDef external fill:#E0E0E0,stroke:#757575,color:#000;
    classDef config fill:#F5F5F5,stroke:#9E9E9E,color:#000;
```
