# fazlibeqir/e-majstori architecture

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

- Interactive diagram: https://gitdiagram.com/fazlibeqir/e-majstori
- Repository: https://github.com/fazlibeqir/e-majstori

## Overview

##### Main Components

- Backend Application (Spring Boot)
– This is the primary focus of the file tree. It includes several layers:
▪ Web Layer (Controllers like AppUserController, AuthController, CategoryController, etc.)
▪ Service Layer (Service interfaces and their implementations, e.g., AuthService and AuthServiceImpl)
▪ Data Access Layer (Repositories for entities such as AppUser, Category, Job, JobProvider, and Location)
▪ Domain Model (Entities, DTOs, and relational mappings defined under model and model/relations)
▪ Configuration and Security (Classes like SecurityConfig, CorsConfig, JWTAuthFilter, and JWTUtils)

- Database (PostgreSQL)
– As noted in the README and supported by migration scripts located under src/main/resources/db/migration, the project relies on PostgreSQL.

- Containerization & DevOps Tools
– Dockerfile and Docker Compose files are provided (inside backend/Dockerfile and backend/local/docker-compose.yml), which indicate containerized deployment.

- Frontend Application (React+Vite)
– Although the file tree doesn’t include frontend files, the README mentions a separate frontend repository hosted on Vercel. This component interacts with the backend via API calls.

##### Relationships and Interactions

- The Frontend sends HTTP requests (via RESTful API calls) to the Backend.
- The Backend Web Layer (Controllers) receives API calls, handles authentication (using JWT-based security configurations), and delegates requests to respective Service layer implementations.
- The Service layer processes business logic and interacts with the Data Access Layer.
- The Repository layer performs CRUD operations on the Database (PostgreSQL).
- Docker and Docker Compose are used for container orchestration, ensuring that the backend and database run in isolated, reproducible environments.

##### Architectural Patterns and Design Principles

- Layered Architecture – The project is clearly separated into presentation (controllers), business logic (services), and data access (repositories) layers.
- Security Mechanisms – The use of Spring Security configurations, custom JWT authentication, and CORS configuration are integrated as part of the overall flow.
- Microservice-Style Container Deployment – Although this seems like a monolithic backend, the containerization with Docker suggests an approach that could be scaled or integrated within a microservices environment.
- Use of DTOs – Separating API models (DTOs) from persistence models to ensure loose coupling between external interfaces and underlying data representations.

– Frontend (React+Vite)
– Backend Service (Spring Boot Application)
– Database (PostgreSQL)
– Docker Environment (illustrating containerization for both Backend and Database)

– Controllers (e.g., AuthController, JobController, etc.)
– Services (e.g., AuthServiceImpl, JobServiceImpl, etc.)
– Repositories (e.g., AppUserRepository, JobRepository, etc.)
– Domain/Models (entities and DTOs)
– Configuration & Security (JWTAuthFilter, JWTUtils, SecurityConfig, CorsConfig)

– Consider grouping configuration and security classes together inside the backend component.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Frontend (React+Vite)"]:::frontend
    subgraph "Containerized Environment"
        B["Backend Application (Spring Boot)"]:::backend
        H["PostgreSQL Database"]:::database
    end

    A -->|"REST_API"| B

    %% Backend Architecture Layers
    subgraph "Backend Architecture"
        C["Web Layer (Controllers)"]:::controller
        subgraph "Service Layer"
            D1["Service Interfaces"]:::service
            D2["Service Implementations"]:::service
        end
        E["Data Access Layer (Repositories)"]:::repository
        subgraph "Domain Models"
            F1["Entities"]:::domain
            F2["DTOs"]:::domain
            F3["Relations"]:::domain
        end
        G["Configuration & Security"]:::config
    end

    %% Connections within Backend Application
    B -->|"handles"| C
    C -->|"delegates_to"| D1
    D1 -->|"implemented_by"| D2
    D2 -->|"invokes"| E
    E -->|"CRUD_operations"| H
    C -->|"utilizes"| F1
    D2 -->|"uses"| F1
    B -->|"secured_by"| G

    %% Docker / DevOps Tools
    I["Dockerfile"]:::docker
    J["Docker Compose"]:::docker
    I -->|"builds"| B
    J -->|"orchestrates"| B
    J -->|"orchestrates"| H

    %% Click Events for Component Mapping
    click B "https://github.com/fazlibeqir/e-majstori/blob/main/backend/src/main/java/ukim/finki/backend/BackendApplication.java"
    click C "https://github.com/fazlibeqir/e-majstori/tree/main/backend/src/main/java/ukim/finki/backend/web"
    click D1 "https://github.com/fazlibeqir/e-majstori/tree/main/backend/src/main/java/ukim/finki/backend/service"
    click D2 "https://github.com/fazlibeqir/e-majstori/tree/main/backend/src/main/java/ukim/finki/backend/service/impl"
    click E "https://github.com/fazlibeqir/e-majstori/tree/main/backend/src/main/java/ukim/finki/backend/repository"
    click F1 "https://github.com/fazlibeqir/e-majstori/tree/main/backend/src/main/java/ukim/finki/backend/model"
    click F2 "https://github.com/fazlibeqir/e-majstori/tree/main/backend/src/main/java/ukim/finki/backend/model/dto"
    click F3 "https://github.com/fazlibeqir/e-majstori/tree/main/backend/src/main/java/ukim/finki/backend/model/relations"
    click G "https://github.com/fazlibeqir/e-majstori/tree/main/backend/src/main/java/ukim/finki/backend/configs"
    click H "https://github.com/fazlibeqir/e-majstori/tree/main/backend/src/main/resources/db/migration"
    click I "https://github.com/fazlibeqir/e-majstori/tree/main/backend/Dockerfile"
    click J "https://github.com/fazlibeqir/e-majstori/blob/main/backend/local/docker-compose.yml"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef backend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef controller fill:#cfc,stroke:#333,stroke-width:2px;
    classDef service fill:#fc9,stroke:#333,stroke-width:2px;
    classDef repository fill:#cff,stroke:#333,stroke-width:2px;
    classDef domain fill:#ffc,stroke:#333,stroke-width:2px;
    classDef config fill:#fcc,stroke:#333,stroke-width:2px;
    classDef database fill:#9cf,stroke:#333,stroke-width:2px;
    classDef docker fill:#ddd,stroke:#333,stroke-width:2px;
```
