# dabrovsky/jobfinder-engine architecture

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

- Interactive diagram: https://gitdiagram.com/dabrovsky/jobfinder-engine
- Repository: https://github.com/dabrovsky/jobfinder-engine

## Overview

##### Main Components

A. API Layer
- JobOffersController as the main endpoint handler
- Error handling middleware (from concerns/api/errors_handler.rb)

B. Core Business Logic Layer
- Command Pattern Implementation
- JobOffers commands (list)
- Providers commands (fetch)
- CommandHandler concern as a shared component

- Query Layer
- JobOffers queries (fetch)
- BaseQuery as the parent

C. Data Layer
- Database component showing JobOffer model
- ApplicationRecord as the base model

D. Background Processing
- Job Queue component (solid_queue.yml indicates background processing)
- FetchRecordsJob as a scheduled task

E. External Services Integration
- Provider APIs component
- NoFluffJobs API integration
- Common API handling layer

##### Relationships and Data Flow

- External requests → API Layer
- API Layer → Commands
- Commands → Queries → Data Layer
- Background Jobs → Provider APIs → Data Layer
- Serializers handling data transformation (JobOfferSerializer)

##### Additional Elements

- Notes about scheduled tasks (config/schedule.rb)
- Testing structure parallel to the main components
- Docker containerization boundary

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph API
        API_Gateway["API V1 Gateway"]:::api
        ErrorHandler["Error Handling Middleware"]:::api
    end

    subgraph BusinessLogic
        subgraph Commands
            CommandHandler["Command Handler"]:::command
            JobOffersCommand["Job Offers List Command"]:::command
            ProvidersCommand["Providers Fetch Command"]:::command
        end

        subgraph Queries
            BaseQuery["Base Query"]:::query
            JobOffersQuery["Job Offers Fetch Query"]:::query
        end
    end

    subgraph DataLayer
        JobOffer["Job Offer Model"]:::data
        Serializer["Job Offer Serializer"]:::data
    end

    subgraph BackgroundProcessing
        JobQueue["Job Queue"]:::job
        FetchRecordsJob["Fetch Records Job"]:::job
        Schedule["Job Schedule"]:::job
    end

    subgraph ExternalServices
        NoFluffJobsAPI["NoFluffJobs API"]:::external
        CommonAPIHandler["Common API Handler"]:::external
    end

    API_Gateway --> CommandHandler
    ErrorHandler --> API_Gateway
    CommandHandler --> JobOffersCommand
    CommandHandler --> ProvidersCommand
    JobOffersCommand --> JobOffersQuery
    ProvidersCommand --> JobOffersQuery
    JobOffersQuery --> BaseQuery
    BaseQuery --> JobOffer
    JobOffer --> Serializer
    FetchRecordsJob --> CommonAPIHandler
    CommonAPIHandler --> NoFluffJobsAPI
    NoFluffJobsAPI --> JobOffer
    JobQueue --> FetchRecordsJob
    Schedule --> JobQueue

    %% Click Events
    click API_Gateway "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/controllers/api/v1/job_offers_controller.rb"
    click ErrorHandler "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/controllers/concerns/api/errors_handler.rb"
    click CommandHandler "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/commands/concerns/command_handler.rb"
    click JobOffersCommand "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/commands/job_offers/list.rb"
    click ProvidersCommand "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/commands/providers/fetch.rb"
    click BaseQuery "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/queries/base_query.rb"
    click JobOffersQuery "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/queries/job_offers/fetch_query.rb"
    click JobOffer "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/models/job_offer.rb"
    click FetchRecordsJob "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/jobs/providers/fetch_records_job.rb"
    click NoFluffJobsAPI "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/services/providers/api/nofluffjobs.rb"
    click CommonAPIHandler "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/services/providers/api/common.rb"
    click JobQueue "https://github.com/Dabrovsky/jobfinder-engine/blob/main/config/solid_queue.yml"
    click Serializer "https://github.com/Dabrovsky/jobfinder-engine/blob/main/app/serializers/job_offer_serializer.rb"
    click Schedule "https://github.com/Dabrovsky/jobfinder-engine/blob/main/config/schedule.rb"

    %% Styling
    classDef api fill:#2196F3,stroke:#1565C0,color:white
    classDef command fill:#4CAF50,stroke:#2E7D32,color:white
    classDef query fill:#8BC34A,stroke:#558B2F,color:white
    classDef data fill:#FFC107,stroke:#FFA000,color:black
    classDef job fill:#FF9800,stroke:#F57C00,color:white
    classDef external fill:#9C27B0,stroke:#7B1FA2,color:white

    %% Legend
    subgraph Legend
        API_L["API Components"]:::api
        Command_L["Command Components"]:::command
        Query_L["Query Components"]:::query
        Data_L["Data Components"]:::data
        Job_L["Background Jobs"]:::job
        External_L["External Services"]:::external
    end
```
