# btwiiin/findjobweb architecture

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

- Interactive diagram: https://gitdiagram.com/btwiiin/findjobweb
- Repository: https://github.com/btwiiin/findjobweb

## Overview

##### Project Overview & Purpose
- This project is a job posting platform built with a microservices architecture.
- It provides capabilities for employers to post/manage jobs and for job seekers to browse, search (with filtering and geolocation via an interactive map), and apply for jobs.
- The system uses an event-driven pattern with RabbitMQ (integrated via MassTransit) to decouple service communications.
- The front-end uses Next.js (React) for an interactive user interface and the back-end consists of several .NET microservices.
- Authentication is implemented via an external Identity service (utilizing Duende and Blazor components) with planned notification functionalities.

##### Analyzing the File Structure
- Notice the clear separation between frontend and backend:
- The "frontend/web-app" directory includes all client-side files and components for the user interface.
- The "src" folder contains several microservices: ApplyingService, IdentityService, JobPostingService, NotificationService, SearchService, and a GatewayService.
- Each service is organized into controllers, DTOs, models, repository layers, and consumers (for handling events).
- Dockerfiles in multiple services and a docker-compose.yml file at the root indicate containerization and orchestration.

##### Identifying the Main Architectural Components
a. Frontend (Client-side)
- Built with Next.js, it is responsible for rendering the job listings, interactive maps, forms for applying, and overall user interaction.
b. API Gateway
- GatewayService acts as an entry point to route and expose backend services.
c. Microservices (Back-end)
- JobPostingService: Manages job posts (CRUD operations, listings, search indexing).
- ApplyingService: Handles job applications and operations related to applying for jobs.
- IdentityService: Manages authentication, user sessions, and user profiles.
- SearchService: Provides advanced search functionality, heavily utilizing Elasticsearch.
- NotificationService (Planned/Partially implemented): Would handle job notifications and events triggering alerts.
d. Communication & Event Bus
- RabbitMQ (via MassTransit) for asynchronous, event-driven communication between these services.
e. Databases & External Tools
- PostgreSQL for persistent storage.
- Elasticsearch for search functionalities.
- Additional external integrations for identity (using Duende) and potentially for maps or other services.

##### Determining Relationships & Interactions
- The front-end communicates with the API Gateway for all user requests.
- The API Gateway routes the requests to the appropriate microservice.
- Microservices interact with each other by publishing or subscribing to events on RabbitMQ. For example, when a new job post is created in the JobPostingService, an event is sent for the SearchService to update indices and for the NotificationService to potentially trigger notifications.
- IdentityService is a shared component used for authentication and authorization across the full system.
- Each microservice communicates with its own database instance or shared database for both transactional (PostgreSQL) and search functionalities (Elasticsearch).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend (Next.js)"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        APIGW["API Gateway"]:::api
    end

    %% Microservices
    subgraph "Microservices"
        JP["JobPostingService (.NET)"]:::service
        AS["ApplyingService (.NET)"]:::service
        IS["IdentityService (.NET)"]:::service
        SS["SearchService (.NET)"]:::service
        NS["NotificationService (.NET)"]:::service
    end

    %% Infrastructure
    subgraph "Infrastructure"
        EB["Event Bus (RabbitMQ)"]:::middleware
        PG[(PostgreSQL)]:::db
        ES[(Elasticsearch)]:::db
        EID["External Identity Provider (Duende)"]:::external
    end

    %% Data Flow
    FE -->|"HTTP/REST"| APIGW
    APIGW -->|"routes"| JP
    APIGW -->|"routes"| AS
    APIGW -->|"routes"| IS
    APIGW -->|"routes"| SS
    APIGW -->|"routes"| NS

    %% Event-driven interactions
    JP -->|"publish_event"| EB
    EB -->|"event_update"| SS
    EB -->|"event_trigger"| NS

    %% Database Access
    JP -->|"db_access"| PG
    AS -->|"db_access"| PG
    IS -->|"db_access"| PG
    NS -->|"db_access"| PG
    SS -->|"search"| ES

    %% External Authentication
    IS -->|"auth"| EID

    %% Click Events
    click FE "https://github.com/btwiiin/findjobweb/tree/master/frontend/web-app"
    click APIGW "https://github.com/btwiiin/findjobweb/tree/master/src/GatewayService"
    click JP "https://github.com/btwiiin/findjobweb/tree/master/src/JobPostingService"
    click AS "https://github.com/btwiiin/findjobweb/tree/master/src/ApplyingService"
    click IS "https://github.com/btwiiin/findjobweb/tree/master/src/IdentityService"
    click SS "https://github.com/btwiiin/findjobweb/tree/master/src/SearchService"
    click NS "https://github.com/btwiiin/findjobweb/tree/master/src/NotificationService"
    click EB "https://github.com/btwiiin/findjobweb/blob/master/docker-compose.yml"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef api fill:#ccf,stroke:#333,stroke-width:2px;
    classDef service fill:#cfc,stroke:#333,stroke-width:2px;
    classDef middleware fill:#fc9,stroke:#333,stroke-width:2px;
    classDef db fill:#cff,stroke:#333,stroke-width:2px;
    classDef external fill:#f96,stroke:#333,stroke-width:2px;
```
