# dangduydev/insurtech architecture

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

- Interactive diagram: https://gitdiagram.com/dangduydev/insurtech
- Repository: https://github.com/dangduydev/insurtech

## Overview

##### Project Type and Purpose
- The project is a Java-based back-end application built using Maven and Spring Boot.
- Its purpose appears to be an “Insurtech” system – likely a service for handling insurance-related operations – based on package names and the use of controllers, services, entities, and repositories common in RESTful API architectures.

##### High-Level Components
- Application Entry Point: InsurtechApplication.java serves as the startup class.
- API Layer (Controllers):
- Located in src/main/java/com/project/insurtech/controllers, these classes (e.g., AdminController, CategoryController, ClaimController, etc.) manage HTTP endpoints.
- Service Layer:
- Found in src/main/java/com/project/insurtech/service and its Impl subpackage. These interfaces and their implementations encapsulate the business logic (e.g., ClaimService, ContractService, etc.).
- Data Access Layer:
- Repositories in the repositories package handle CRUD operations with the underlying database.
- Domain Model and Data Transfer Objects (DTOs):
- Entities in the entities package represent the database tables (such as User, Contract, Product, etc.).
- Corresponding DTOs and Response objects convert data between layers and structure API outputs.
- Security and Utility Components:
- Security-related classes in configurations (SecurityConfig, WebSecurityConfig) and filters (JwtTokenFilter, CorsFilter) manage authentication and request filtering.
- Helpers and exception handling classes (GlobalExceptionHandler, ValidationHelper) assist with cross-cutting concerns.
- External Integrations:
- Configuration for Minio (MinioConfig) indicates integration with an object storage solution.
- JWT utilities (JwtTokenUtil) enable token-based user authentication.

##### Architectural Patterns & Design Principles
- Layered (n-tier) architecture: Clear separation of controllers (presentation/API layer), services (business logic), and repositories (data persistence).
- Use of Dependency Injection: Seen from the Spring Boot configuration and service interfaces with implementations.
- Exception Handling and Logging: Implemented via GlobalExceptionHandler and LoggingResponseBodyAdvice, emphasizing robust error management.
- Security Practices: Usage of JWT and CORS filtering for secure API access.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Client
    Client["Client (HTTP Request)"]:::externalClient

    %% Application Entry Point
    subgraph "Application Layer"
        A1["InsurtechApplication"]:::application
    end

    %% API Layer
    subgraph "API Layer"
        AP["Controllers"]:::api
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        SI["Service Interfaces"]:::service
        SIM["Service Implementations"]:::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        RE["Repositories"]:::data
        EN["Entities"]:::data
        DTO["DTOs"]:::data
    end

    %% Security and Cross-Cutting Concerns
    subgraph "Security & Cross-Cutting"
        SC["Security Configs"]:::security
        JWT["JWT Utilities"]:::security
        CORS["CORS Filter"]:::security
        EXH["Exception Handling & Helpers"]:::security
        DM["Data Mappers"]:::security
    end

    %% External Integrations
    subgraph "External Integration"
        MINC["Minio Config"]:::external
        MINS["Minio Service"]:::external
    end

    %% Connections
    Client -->|"calls"| A1
    A1 -->|"initializes"| AP
    AP -->|"delegates_to"| SI
    SI -->|"implemented_by"| SIM
    SIM -->|"performs_CRUD_at"| RE
    RE -->|"manages"| EN
    AP -->|"transforms_data_via"| DTO
    AP -->|"maps_using"| DM
    AP -->|"secured_by"| SC
    SC -->|"employs"| JWT
    SC -->|"applies"| CORS
    AP -->|"handles_errors_with"| EXH
    SIM -->|"integrates_with"| MINS
    MINS -->|"configured_by"| MINC

    %% Styles for different layers
    classDef application fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef api fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef service fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef data fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef security fill:#F5CBA7,stroke:#922B21,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef externalClient fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/dangduydev/insurtech/blob/main/src/main/java/com/project/insurtech/InsurtechApplication.java"
    click AP "https://github.com/dangduydev/insurtech/tree/main/src/main/java/com/project/insurtech/controllers"
    click SI "https://github.com/dangduydev/insurtech/tree/main/src/main/java/com/project/insurtech/service"
    click SIM "https://github.com/dangduydev/insurtech/tree/main/src/main/java/com/project/insurtech/service/Impl"
    click RE "https://github.com/dangduydev/insurtech/tree/main/src/main/java/com/project/insurtech/repositories"
    click EN "https://github.com/dangduydev/insurtech/tree/main/src/main/java/com/project/insurtech/entities"
    click DTO "https://github.com/dangduydev/insurtech/tree/main/src/main/java/com/project/insurtech/dtos"
    click SC "https://github.com/dangduydev/insurtech/tree/main/src/main/java/com/project/insurtech/configurations"
    click JWT "https://github.com/dangduydev/insurtech/blob/main/src/main/java/com/project/insurtech/components/JwtTokenUtil.java"
    click JWT "https://github.com/dangduydev/insurtech/blob/main/src/main/java/com/project/insurtech/filters/JwtTokenFilter.java"
    click CORS "https://github.com/dangduydev/insurtech/blob/main/src/main/java/com/project/insurtech/components/CorsFilter.java"
    click EXH "https://github.com/dangduydev/insurtech/tree/main/src/main/java/com/project/insurtech/components/helpers"
    click MINC "https://github.com/dangduydev/insurtech/blob/main/src/main/java/com/project/insurtech/configurations/MinioConfig.java"
    click MINS "https://github.com/dangduydev/insurtech/blob/main/src/main/java/com/project/insurtech/service/Impl/MinioService.java"
    click DM "https://github.com/dangduydev/insurtech/tree/main/src/main/java/com/project/insurtech/components/mappers"
```
