# jordanrondon/quicknotesapi architecture

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

- Interactive diagram: https://gitdiagram.com/jordanrondon/quicknotesapi
- Repository: https://github.com/jordanrondon/quicknotesapi

## Overview

##### Main Components
- API Endpoints (Controllers): Represent the RESTful API endpoints for authentication (AuthController), note management (NoteController), and user management (UsersController).
- Business Logic Layer (Services): Show the service interfaces (INoteService and IUsersService) and their implementations (NoteService and UsersService) responsible for processing data and business rules.
- Data Access Layer (Repositories): Represent the repository interfaces (INoteRepository and IUsersRepository) that interact with the database.
- Domain Models: Mention the domain classes (Note and Users) as the core data structures.
- Security Components: Include elements like SecurityConfig, JwtRequestFilter, and the utility class JwtUtil. This layer handles JWT authentication and endpoint security.
- Database: Represent PostgreSQL as the external persistent storage. Note the initialization scripts present (01_schema.sql, 02_triggers.sql, 03_data.sql) that define database schema and seed data.
- External Client/Consumer: Although not part of the codebase, include a representation of the external client (e.g., a web browser, mobile app, or REST client) consuming the API.

##### Relationships and Interactions
- External clients send HTTP requests to the controllers.
- Controllers delegate requests to the service layer, which contains the business logic.
- Service components interact with repository interfaces to retrieve or persist the domain models.
- The security components (Spring Security configuration and JWT filter) intercept API requests for authentication/authorization before they reach the controllers.
- The database component stores user credentials, notes, and associated metadata.

##### Architectural Patterns and Design Principles
- The project follows a layered architecture (presentation, service, data access).
- Use of Spring Security and JWT indicates a clear separation of concerns for security.
- The modular structure (controllers, services, repositories, utils) supports maintainability and scalability.
- Dependency inversion: controllers depend on service interfaces rather than concrete implementations.

##### Technologies and Frameworks
- Java (JDK 21) and Spring Boot serve as the main framework.
- Spring Security manages authentication, complemented by JWT for secure token-based sessions.
- Maven for dependency management and project build.
- PostgreSQL as the database.
- Javadoc for generating documentation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    EC("External Client (Browser/REST Client)"):::client

    %% Security Layer
    subgraph "Security Layer"
        SC("SecurityConfig"):::security
        JRF("JwtRequestFilter"):::security
        JU("JwtUtil"):::security
    end

    %% API Controller Layer
    subgraph "API Controller Layer"
        AC("AuthController"):::controller
        NC("NoteController"):::controller
        UC("UsersController"):::controller
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        INS("INoteService"):::service
        IUS("IUsersService"):::service
        NS("NoteService"):::service
        US("UsersService"):::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        INR("INoteRepository"):::repository
        IUR("IUsersRepository"):::repository
    end

    %% Domain Models
    subgraph "Domain Models"
        N("Note"):::domain
        U("Users"):::domain
    end

    %% Database Layer
    subgraph "Database"
        DB("PostgreSQL"):::database
        DBS("DB Scripts"):::database
    end

    %% Relationships
    EC -->|"HTTP_Request"| JRF
    SC -->|"configures"| JRF
    JU -->|"validates"| JRF

    JRF -->|"authenticate"| AC
    JRF -->|"authenticate"| NC
    JRF -->|"authenticate"| UC

    AC -->|"calls"| IUS
    NC -->|"calls"| INS
    UC -->|"calls"| IUS

    INS -->|"implemented_by"| NS
    IUS -->|"implemented_by"| US

    NS -->|"access"| INR
    US -->|"access"| IUR

    INR -->|"CRUD"| DB
    IUR -->|"CRUD"| DB

    INR -->|"handles"| N
    IUR -->|"handles"| U

    DBS -->|"initialize"| DB

    %% Click Events
    click AC "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/controller/AuthController.java"
    click NC "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/controller/NoteController.java"
    click UC "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/controller/UsersController.java"

    click INS "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/service/Interface/INoteService.java"
    click IUS "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/service/Interface/IUsersService.java"
    click NS "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/service/NoteService.java"
    click US "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/service/UsersService.java"

    click INR "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/repository/INoteRepository.java"
    click IUR "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/repository/IUsersRepository.java"

    click N "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/model/Note.java"
    click U "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/model/Users.java"

    click SC "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/security/SecurityConfig.java"
    click JRF "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/security/JwtRequestFilter.java"
    click JU "https://github.com/jordanrondon/quicknotesapi/blob/main/src/main/java/com/QuickNotesAPI/QuickNotes/util/JwtUtil.java"

    click DBS "https://github.com/jordanrondon/quicknotesapi/tree/main/src/main/resources/database"

    %% Styles
    classDef client fill:#ffd6a5,stroke:#333,stroke-width:2px;
    classDef controller fill:#a2d2ff,stroke:#333,stroke-width:2px;
    classDef service fill:#ffafcc,stroke:#333,stroke-width:2px;
    classDef repository fill:#cdb4db,stroke:#333,stroke-width:2px;
    classDef domain fill:#bde0fe,stroke:#333,stroke-width:2px;
    classDef security fill:#ffc8dd,stroke:#333,stroke-width:2px;
    classDef database fill:#caffbf,stroke:#333,stroke-width:2px;
```
