# huuthonguyen76/job-advert-assigment architecture

> Architecture diagram of the GitHub repository huuthonguyen76/job-advert-assigment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/huuthonguyen76/job-advert-assigment
- Repository: https://github.com/huuthonguyen76/job-advert-assigment

## Overview

##### Project Type and Purpose
- This project is an AI-powered tool that processes various document formats (PDF, DOCX, images), extracts key job advertisement details, and generates optimized job adverts with custom visuals.
- It’s a full-stack application that features both a backend processing pipeline (using AI agents and extractors) and a frontend web interface (implemented via Gradio) for interaction with end users.

##### Analyzing the File Structure and What It Implies
- Top-level directories and files like Dockerfile, Makefile, pyproject.toml, and README.md indicate that the project is meant to be containerized and easily deployed.
- Under the src folder, you see specialized subdirectories:
- src/agent: Contains AI agent implementations (e.g., extraction, image generation, post-processing, template generation) which strongly suggests there’s an “agent workflow” orchestrated by Langgraph/Langchain in the system.
- src/app: Contains the main application, likely the entry point for the web UI.
- src/bucket: Likely responsible for shared aspects such as logging, configuration, and handling of local storage or file operations.
- src/common: Contains shared utility functions (in this case, image utilities) that support the core functionalities.
- src/component/job_advert_generation: Focuses on components that generate job advert specifications—likely integrating document information extraction and managing the workflow.
- src/model: Contains data models (or settings models) which define structured data flowing through the system.
- The file tree also shows a test_data folder, suggesting input samples for testing the pipeline.

##### Key System Components
a. Frontend Web Interface:
- Gradio UI which allows users to upload various job posting formats, view results, and download generated outputs.
b. Input Processing Module:
- Handles multi-format document input (PDF, DOCX, images) and conversion (OCR for images).
c. Information Extraction Module:
- Applies AI and LLM-based processing to extract structured data (company info, job details, key requirements etc.).
- This module might be represented via components under the agent and component directories.
d. Content Generation Module:
- Uses Gemini (LLM) along with Langchain/Langgraph agents to produce the optimized textual job adverts and image-based ad templates.
- Could be decomposed into stages (template generation, image generation, and post-processing) as shown in src/agent.
e. Data/Configuration and Integration:
- Includes bucket handling for logging, settings, and other shared functionality.
- The data models in src/model also feed into the workflow.
f. External Technologies:
- Integration with Gemini’s API for LLM and hints to external APIs (Bannerbear, Predis.ai) in exploratory comments, even if not fully integrated.

##### Relationships and Interactions
- The user interacts first with the Web Interface.
- Uploaded job advert documents are passed into the Input Processing component, which handles OCR and data extraction.
- The processed information is then fed into the Information Extraction component (internally orchestrated by agents) to generate structured data.
- Structured information flows to the Content Generation module where:
- Optimized text is generated using Gemini.
- Visual assets and ad templates are processed and integrated.
- The final output is served back to the web interface for user review/download.
- Under the hood, various shared utilities (from bucket, common, model) support data management and configuration.

##### Architectural Patterns and Design Principles
- Modular design: Clearly separated directories denote separation of concerns (AI agents, app UI, utility libraries).
- Pipeline/Workflow pattern: The sequential steps from input → extraction → content generation → output are clearly visible.
- Agent-based processing: The use of Langchain and Langgraph among different agent implementations highlights a decoupled, multi-stage processing architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    UI["Frontend Web Interface"]:::frontend

    %% Backend Processing
    IP["Input Processing Module"]:::backend
    IE["Information Extraction Module"]:::backend

    %% Content Generation Module Subgraph
    subgraph "Content Generation Module"
        TT["Text & Template Generation"]:::content
        IG["Image Generation"]:::content
        PP["Post-processing"]:::content
    end

    %% Utilities Subgraph
    subgraph "Utilities"
        DS1["Bucket Settings"]:::utility
        DS2["Model Settings"]:::utility
        DL["Logging"]:::utility
        DLL["LLM Integration"]:::utility
        CU["Common Utility Functions"]:::utility
    end

    %% External API
    EX["External API (Gemini)"]:::external

    %% Data Flow Connections
    UI -->|"document_upload"| IP
    IP -->|"processed_doc"| IE
    IE -->|"extracted_info"| TT
    IE -->|"extracted_info"| IG
    IE -->|"extracted_info"| PP

    TT -->|"generated_text"| UI
    IG -->|"generated_image"| UI
    PP -->|"final_advert"| UI

    %% Utilities Support (dashed connections)
    IE ---|"config"| DS1
    IE ---|"config"| DS2
    IE ---|"config"| DL
    IE ---|"config"| DLL
    IG ---|"utilizes"| CU

    %% External API Interaction (dotted connections)
    TT -.->|"LLM_Call"| EX
    IG -.->|"LLM_Call"| EX

    %% Click Events
    click UI "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/app/app.py"
    click IP "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/component/job_advert_generation/extract_doc_info_langchain.py"
    click IE "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/agent/ja_extract_info.py"
    click TT "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/agent/ja_template_generation.py"
    click IG "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/agent/ja_image_generation.py"
    click PP "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/agent/ja_post_generation.py"
    click DS1 "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/bucket/setting.py"
    click DS2 "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/model/setting_model.py"
    click DL "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/bucket/logging.py"
    click DLL "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/bucket/llm.py"
    click CU "https://github.com/huuthonguyen76/job-advert-assigment/blob/master/src/common/image_util.py"

    %% Styles / Classes
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef backend fill:#9f9,stroke:#333,stroke-width:2px;
    classDef content fill:#ff9,stroke:#333,stroke-width:2px;
    classDef utility fill:#9ff,stroke:#333,stroke-width:2px;
    classDef external fill:#fc9,stroke:#333,stroke-width:2px;
```
