# rsvinicius/priori-task-api architecture

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

- Interactive diagram: https://gitdiagram.com/rsvinicius/priori-task-api
- Repository: https://github.com/rsvinicius/priori-task-api

## Overview

##### Main Components
- API Entry Point: Represent the PrioriTaskApplication as the main entry point.
- Controllers: Include components like AuthController and TaskController that define REST endpoints.
- Repositories: Create components such as UserRepository, TaskRepository, and CategoryRepository. These interact directly with the PostgreSQL database.
- Configuration: Include configuration blocks for EmailConfig, ThymeleafConfig, GlobalExceptionHandler, and WebSecurityConfig.
- Scheduler: Include the Quartz scheduler component, represented by the ReminderJob and associated ScheduleUtils and ScheduleService components.
- Database: Represent PostgreSQL, along with Flyway-managed database migrations (the SQL scripts in src/main/resources/db/migration).
- Email Template: Show Thymeleaf templates (ReminderEmail.html) and the Email service integration.
- Utility/Helpers: Optionally include a component for utilities like DateUtils and validators.

##### Relationships and Data Flow
- From Services, display the interaction with the Repository layer when persisting or retrieving data from PostgreSQL.
- That the Security module is integrated with Controllers and Services (for authorization/authentication purposes).

##### Architectural Patterns
- Layered (or N-tier) architectural pattern: Clearly separate the presentation (controllers), business logic (services), and data access (repositories).
- Integration with external services: The email service and scheduler are distinct yet integrated parts.
- Security Concern: Emphasize the use of JWT for stateless authentication within the API layer.
- Use of external configuration: Config files and environment-specific properties (application.yaml) are used to configure components like database connections and email settings.

##### Relevant Technologies
- Spring Boot & Kotlin for the application framework.
- PostgreSQL (with Flyway for migrations) for the database.
- Docker & Docker Compose for containerized database deployment.
- Quartz Scheduler for scheduling jobs.
- Apache Commons Email and Thymeleaf for email generation/notification.
- Spring Security & JWT for authentication/authorization.

##### Final Touches
- Specific details like filenames (e.g., “PrioriTaskApplication.kt” for the startup), key configuration classes, and scheduling jobs as labeled nodes.
- Clarity by spacing out components logically (grouping related items together, like all security classes in one area).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Global Entry Point
    A["PrioriTaskApplication (Entry)"]:::entry

    %% API Consumer (Client)
    C["Client"]:::external

    %% Controllers Subgraph
    subgraph "Controllers Layer"
        AuthC["AuthController"]:::controller
        TaskC["TaskController"]:::controller
    end

    %% Services Subgraph
    subgraph "Services Layer"
        AuthS["AuthService"]:::service
        TaskS["TaskService"]:::service
        UserS["UserService"]:::service
        SchS["ScheduleService"]:::service
        EmailS["EmailService"]:::service
        UDS["UserDetailsServiceImpl"]:::service
    end

    %% Repositories Subgraph
    subgraph "Repositories Layer"
        UserR["UserRepository"]:::repository
        TaskR["TaskRepository"]:::repository
        CatR["CategoryRepository"]:::repository
    end

    %% Security Subgraph
    subgraph "Security Module"
        JwtEntry["JwtAuthenticationEntryPoint"]:::security
        JwtFilter["JwtRequestFilter"]:::security
        JwtUtils["JwtUtils"]:::security
        UDI["UserDetailsImpl"]:::security
    end

    %% Configuration Subgraph
    subgraph "Configuration"
        EmailCfg["EmailConfig"]:::config
        ThymeleafCfg["ThymeleafConfig"]:::config
        GlobalEx["GlobalExceptionHandler"]:::config
        WebSec["WebSecurityConfig"]:::config
    end

    %% Scheduler Subgraph
    subgraph "Scheduler"
        RemJob["ReminderJob"]:::scheduler
        SchUtil["ScheduleUtils"]:::scheduler
    end

    %% Database and Migrations
    DB["PostgreSQL Database"]:::database
    Flyway["Flyway Migration Script"]:::database

    %% Email Template
    EmailTemp["ReminderEmail Template"]:::email

    %% Utility/Helpers Subgraph
    subgraph "Utilities/Helpers"
        DateU["DateUtils"]:::utility
        Validator["FutureOrCurrentDate Validator"]:::utility
    end

    %% Data Flow Connections
    C -->|"RESTRequest"| A
    A -->|"Triggers"| AuthC
    A -->|"Triggers"| TaskC

    AuthC -->|"Calls"| AuthS
    TaskC -->|"Calls"| TaskS

    AuthS -->|"Uses"| UserS
    AuthS -->|"Interacts"| UDS
    TaskS -->|"Interacts"| UserS

    UserS -->|"CRUD Operations"| UserR
    AuthS -->|"CRUD Operations"| UserR
    TaskS -->|"CRUD Operations"| TaskR
    TaskS -->|"Category Lookup"| CatR

    %% Security integration with Controllers and Services
    AuthC -->|"SecuredBy"| JwtFilter
    TaskC -->|"SecuredBy"| JwtFilter
    JwtFilter -->|"Validates"| JwtUtils
    JwtFilter -->|"Delegates to"| UDI

    %% Configuration links
    EmailS -->|"ConfiguredBy"| EmailCfg
    EmailS -->|"Uses"| ThymeleafCfg
    AuthC -->|"ErrorHandledBy"| GlobalEx
    TaskC -->|"ErrorHandledBy"| GlobalEx
    JwtFilter -->|"ConfiguredBy"| WebSec
    GlobalEx -->|"ConfiguredBy"| WebSec

    %% Scheduler flow
    SchS -->|"Schedules"| RemJob
    RemJob -->|"Triggers"| EmailS
    RemJob -->|"Uses"| SchUtil

    %% Database integration
    UserR -->|"Reads/Writes"| DB
    TaskR -->|"Reads/Writes"| DB
    CatR -->|"Reads/Writes"| DB
    Flyway -->|"Migrates"| DB

    %% Email Template integration
    EmailS -->|"Renders"| EmailTemp

    %% Click Events
    click A "https://github.com/rsvinicius/priori-task-api/blob/main/src/main/kotlin/com/example/prioritask/PrioriTaskApplication.kt"
    click AuthC "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/controller"
    click TaskC "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/controller"
    click AuthS "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/service"
    click TaskS "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/service"
    click UserS "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/service"
    click SchS "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/service"
    click EmailS "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/service"
    click UDS "https://github.com/rsvinicius/priori-task-api/blob/main/src/main/kotlin/com/example/prioritask/service/UserDetailsServiceImpl.kt"
    click UserR "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/repository"
    click TaskR "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/repository"
    click CatR "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/repository"
    click JwtEntry "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/security/jwt"
    click JwtFilter "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/security/jwt"
    click JwtUtils "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/security/jwt"
    click UDI "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/security"
    click EmailCfg "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/config"
    click ThymeleafCfg "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/config"
    click GlobalEx "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/config"
    click WebSec "https://github.com/rsvinicius/priori-task-api/tree/main/src/main/kotlin/com/example/prioritask/config"
    click RemJob "https://github.com/rsvinicius/priori-task-api/blob/main/src/main/kotlin/com/example/prioritask/scheduler/ReminderJob.kt"
    click SchUtil "https://github.com/rsvinicius/priori-task-api/blob/main/src/main/kotlin/com/example/prioritask/utils/ScheduleUtils.kt"
    click Flyway "https://github.com/rsvinicius/priori-task-api/blob/main/src/main/resources/db/migration/V1__create_tables_quartz_postgres.sql"
    click EmailTemp "https://github.com/rsvinicius/priori-task-api/blob/main/src/main/resources/templates/ReminderEmail.html"
    click DateU "https://github.com/rsvinicius/priori-task-api/blob/main/src/main/kotlin/com/example/prioritask/utils/DateUtils.kt"
    click Validator "https://github.com/rsvinicius/priori-task-api/blob/main/src/main/kotlin/com/example/prioritask/utils/validators/FutureOrCurrentDate.kt"

    %% Styles
    classDef entry fill:#e1bee7,stroke:#8e24aa,stroke-width:2px;
    classDef external fill:#fff9c4,stroke:#f9a825,stroke-width:2px;
    classDef controller fill:#bbdefb,stroke:#1e88e5,stroke-width:2px;
    classDef service fill:#c8e6c9,stroke:#43a047,stroke-width:2px;
    classDef repository fill:#ffe082,stroke:#ffb300,stroke-width:2px;
    classDef security fill:#ffcdd2,stroke:#e53935,stroke-width:2px;
    classDef config fill:#d1c4e9,stroke:#673ab7,stroke-width:2px;
    classDef scheduler fill:#ffccbc,stroke:#fb8c00,stroke-width:2px;
    classDef database fill:#d7ccc8,stroke:#8d6e63,stroke-width:2px;
    classDef email fill:#f8bbd0,stroke:#c2185b,stroke-width:2px;
    classDef utility fill:#f0f4c3,stroke:#afb42b,stroke-width:2px;
```
