# zahidulhasan95503/indoc architecture

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

- Interactive diagram: https://gitdiagram.com/zahidulhasan95503/indoc
- Repository: https://github.com/zahidulhasan95503/indoc

## Overview

##### Main Components
- Frontend Presentation Layer:
- Thymeleaf templates (located in src/main/resources/templates) that generate the user interface.
- Static resources (CSS, JavaScript, images) serve the styling and client-side interaction.
- Backend Application Layer:
- Controllers (under src/main/java/com/legal/controller) handle incoming HTTP requests from the UI.
- Service layer (under src/main/java/com/legal/service) that encapsulates business logic (e.g., YouTubeService, document-specific logic).
- DAO/repository layer (src/main/java/com/legal/dao, e.g., UserRepository) to interface with the database.
- Domain/Entity Layer:
- Entities such as Users and message (under src/main/java/com/legal/entites) representing the core data models.
- DTOs (such as YouTubeVideo in src/main/java/com/legal/DTO) used for data transfer.
- Configuration and Security:
- Configuration classes (like Myconfig, UserDetailsImpl, UserDetailsServiceImpl in src/main/java/com/legal/config) set up Spring Security and other application configurations.
- External API Integrations:
- Integration points for Google Maps API to locate service centers.
- Usage of APIs such as Ollama Chat AI in the OllamaChatApi controller.
- Database:
- The project uses MySQL (and likely Spring JPA with Jdbc) to persist data.

##### Relationships and Interactions
- Users interact with the Frontend (served by Thymeleaf templates) via their browsers.
- The frontend issues HTTP requests to the REST controllers in the backend.
- Controllers delegate business logic to corresponding services.
- Services use the DAO/repository layer to interact with the database.
- The configuration layer (using Spring Boot’s auto-configuration and security classes) ensures components are wired correctly and secure.
- The platform also interacts with external services (Google Maps API, possibly external AI API) via REST calls initiated from the appropriate service or controller.

##### Architectural Patterns and Design Principles
- MVC (Model-View-Controller): The separation is clear between the view (Thymeleaf templates/static assets), the controller (business logic handling HTTP requests), and the model (entities and DTOs).
- Layered Architecture: Distinct layers (Presentation, Business, Data Access) ensure modularity and maintainability.
- External API Integration: Clear boundary components for interacting with third-party services like Google Maps and chat AI.
- Security: Spring Security is implemented for user authentication and authorization, encapsulated in custom UserDetails and UserDetailsService classes.

- For the Frontend, label “Thymeleaf Templates & Static Content” (HTML, CSS, JS).
- Within the Backend, separate the controllers (e.g., HomeController, UserController, OllamaChatApi) and mention configuration classes that secure user sessions.
- In the Service layer, mention business service components like YouTubeService.
- A block for DAOs/Repositories (UserRepository) leading to the database.
b. Flows and Relationships:
- Controllers process requests, calling corresponding services.
- Services delegate data operations to repositories, which in turn interact with the MySQL database.
c. Use Visual Cues:
- Clearly label every component with its role (e.g., “UserController – handles user registration/login” or “Spring Security Config – authentication”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User Browser"]:::user

    subgraph "Frontend Presentation Layer"
        Templates["Thymeleaf Templates"]:::frontend
        Static["Static Content"]:::frontend
    end

    subgraph "Backend Application Layer"
        Controllers["Backend Controllers"]:::backend
        Service["Business Service (YouTubeService)"]:::backend
        Repository["User Repository"]:::backend
        DB["MySQL Database"]:::database
    end

    subgraph "Domain & Configuration"
        Entities["Entities (Users, Message)"]:::domain
        DTO["DTO (YouTubeVideo)"]:::domain
        Config["Configuration Classes"]:::config
    end

    GoogleMaps["Google Maps API"]:::external
    OllamaAI["Ollama AI API"]:::external

    %% Flow connections
    User --> Templates
    User --> Static

    Templates --> Controllers
    Static --> Controllers

    Controllers --> Service
    Service --> Repository
    Repository --> DB

    Service -->|"Uses"| Entities
    Service -->|"transfersData"| DTO

    Config -->|"configures"| Controllers

    Controllers -->|"RESTCall"| GoogleMaps
    Controllers -->|"RESTCall"| OllamaAI

    %% Click Events
    click Templates "https://github.com/zahidulhasan95503/indoc/tree/main/src/main/resources/templates"
    click Static "https://github.com/zahidulhasan95503/indoc/tree/main/src/main/resources/static"
    click Controllers "https://github.com/zahidulhasan95503/indoc/tree/main/src/main/java/com/legal/controller"
    click Service "https://github.com/zahidulhasan95503/indoc/blob/main/src/main/java/com/legal/service/YouTubeService.java"
    click Repository "https://github.com/zahidulhasan95503/indoc/blob/main/src/main/java/com/legal/dao/UserRepository.java"
    click Entities "https://github.com/zahidulhasan95503/indoc/tree/main/src/main/java/com/legal/entites"
    click DTO "https://github.com/zahidulhasan95503/indoc/blob/main/src/main/java/com/legal/DTO/YouTubeVideo.java"
    click Config "https://github.com/zahidulhasan95503/indoc/tree/main/src/main/java/com/legal/config"

    %% Styles
    classDef user fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef database fill:#B0E0E6,stroke:#333,stroke-width:1px;
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef domain fill:#FFE4E1,stroke:#333,stroke-width:1px;
    classDef config fill:#FFB6C1,stroke:#333,stroke-width:1px;
```
