# wolfowi/coriander-backend architecture

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

- Interactive diagram: https://gitdiagram.com/wolfowi/coriander-backend
- Repository: https://github.com/wolfowi/coriander-backend

## Overview

##### Project Type & Purpose
- This is a single-service, RESTful backend API (“CoriCore API”) for a Human Resources management system.
- Built with ASP.NET Core 9.0, EF Core, and PostgreSQL, exposing endpoints for authentication, user/employee management, leave, equipment, meetings, performance reviews, and “gatherings.”

##### File Structure & Patterns
- Layered, monolithic architecture with clear separation of concerns:
- Controllers/ – HTTP entry points (REST endpoints)
- Services/ – Business logic implementations
- Interfaces/ – Service contracts (dependency‐injection abstractions)
- DTOs/ – Input/output models for API surface
- Models/ – EF Core entity classes
- Data/ – DbContext and database configuration
- Migrations/ – EF Core schema evolution scripts
- wwwroot/ – Static assets & uploaded files
- Program.cs & appsettings.json – Startup, DI registration, middleware pipeline
- Integration/config: Dockerfile, .github/workflows, .env templates.
- Testing harness: CoriCore.Tests covers controller, service, and database tests.

##### Key Architectural Insights from README
- Layered design (Presentation → Business → Data).
- Technology ecosystem: JWT, Google OAuth, BCrypt, MailKit, RestSharp, Cloudinary.
- External integrations (email, OAuth provider, image storage).
- Containerization (Docker), CI/CD (GitHub Actions → Render).
- Swagger/OpenAPI for API documentation.

##### Detailed Elements to Capture
- Authentication flow (JWT issuance & verification).
- Service interface → implementation relationships.
- EF Core migrations triggering schema updates.
- External callouts: Google OAuth token endpoint, SMTP host, Cloudinary API.
- Docker multi-stage build flow: build → publish → runtime image.
- CI/CD triggers and automatic deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients" 
        direction TB
        SwaggerUI["Swagger UI"]:::controllers
        FrontendApp["Frontend App/Mobile"]:::controllers
        Postman["Postman"]:::controllers
    end

    %% API Surface (Controllers)
    subgraph "Controllers" 
        direction TB
        AuthController["AuthController"]:::controllers
        EmployeeController["EmployeeController"]:::controllers
        LeaveRequestController["LeaveRequestController"]:::controllers
        GatheringController["GatheringController"]:::controllers
        ImageController["ImageController"]:::controllers
    end

    %% Middleware & Host
    ASPNetHost["ASP.NET Core Web Host\n(Program.cs)"]:::controllers

    %% Services Layer
    subgraph "Services" 
        direction TB
        AuthService["AuthService"]:::services
        EmployeeService["EmployeeService"]:::services
        LeaveRequestService["LeaveRequestService"]:::services
        GatheringService["GatheringService"]:::services
        EmailService["EmailService"]:::services
        ImageService["ImageService"]:::services
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        AppDbContext["AppDbContext"]:::data
        Migrations["Migrations"]:::data
        PostgreSQL["PostgreSQL Database"]:::data
    end

    %% External Integrations
    subgraph "External Services"
        direction TB
        GoogleOAuth["Google OAuth 2.0"]:::external
        SMTP["SMTP Server (MailKit)"]:::external
        Cloudinary["Cloudinary API"]:::external
        ThirdPartyAPI["Third-Party APIs\n(RestSharp)"]:::external
    end

    %% DevOps Pipeline
    subgraph "DevOps & CI/CD"
        direction TB
        DockerfileNode["Dockerfile"]:::devops
        GitHubActions["GitHub Actions"]:::devops
        Render["Render.com Deployment"]:::devops
    end

    %% Connections
    SwaggerUI -->|calls endpoints| AuthController
    FrontendApp -->|HTTP Requests| AuthController
    Postman -->|API Testing| AuthController

    %% Controllers to Host
    AuthController --> ASPNetHost
    EmployeeController --> ASPNetHost
    LeaveRequestController --> ASPNetHost
    GatheringController --> ASPNetHost
    ImageController --> ASPNetHost

    %% Host to Services
    ASPNetHost -->|DI Method Calls| AuthService
    ASPNetHost --> EmployeeService
    ASPNetHost --> LeaveRequestService
    ASPNetHost --> GatheringService
    ASPNetHost --> EmailService
    ASPNetHost --> ImageService

    %% Services to Data
    AuthService --> AppDbContext
    EmployeeService --> AppDbContext
    LeaveRequestService --> AppDbContext
    GatheringService --> AppDbContext

    %% Data
    AppDbContext --> PostgreSQL
    Migrations --> PostgreSQL

    %% Services to External
    AuthService -->|OAuth Validation| GoogleOAuth
    EmailService -->|Send Email| SMTP
    ImageService -->|Upload Image| Cloudinary
    AuthService -->|API Calls| ThirdPartyAPI

    %% DevOps Flow
    DockerfileNode -->|build image| GitHubActions
    GitHubActions -->|deploy| Render

    %% Click Events
    click AuthController "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Controllers/AuthController.cs"
    click EmployeeController "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Controllers/EmployeeController.cs"
    click LeaveRequestController "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Controllers/LeaveRequestController.cs"
    click GatheringController "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Controllers/GatheringController.cs"
    click ImageController "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Controllers/ImageController.cs"
    click AuthService "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Services/AuthServices.cs"
    click EmployeeService "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Services/EmployeeService.cs"
    click LeaveRequestService "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Services/LeaveRequestService.cs"
    click GatheringService "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Services/GatheringService.cs"
    click EmailService "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Services/EmailService.cs"
    click ImageService "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Services/ImageService.cs"
    click AppDbContext "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Data/AppDbContext.cs"
    click Migrations "https://github.com/wolfowi/coriander-backend/tree/main/CoriCore/Migrations"
    click DockerfileNode "https://github.com/wolfowi/coriander-backend/tree/main/Dockerfile"
    click GitHubActions "https://github.com/wolfowi/coriander-backend/blob/main/.github/workflows/ci.yml"
    click Render "https://github.com/wolfowi/coriander-backend/blob/main/.github/workflows/production-deploy.yml"
    click ASPNetHost "https://github.com/wolfowi/coriander-backend/blob/main/CoriCore/Program.cs"

    %% Styles
    classDef controllers fill:#cfe2f3,color:#000,stroke:#000,stroke-width:1px;
    classDef services fill:#d9ead3,color:#000,stroke:#000,stroke-width:1px;
    classDef data fill:#fce5cd,color:#000,stroke:#000,stroke-width:1px;
    classDef external fill:#d9d2e9,color:#000,stroke:#000,stroke-width:1px;
    classDef devops fill:#f2f2f2,color:#000,stroke:#000,stroke-width:1px;
```
