# aryan-verma23/blogging_app architecture

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

- Interactive diagram: https://gitdiagram.com/aryan-verma23/blogging_app
- Repository: https://github.com/aryan-verma23/blogging_app

## Overview

##### Main Components

a) Client Layer:
- External clients (Web/Mobile) that interact with the API
- POSTMAN as a testing client

b) API Layer:
- Controllers package (`CategoryController`, `UserController`)
- REST endpoints grouping

c) Service Layer:
- Service interfaces (`UserService`, `CategoryService`)
- Service implementations (`UserServiceImpl`, `CategoryServiceImpl`)

d) Data Access Layer:
- Repository interfaces (`UserRepo`, `CategoryRepo`)
- Entity classes (`User`, `Category`)

e) Database Layer:
- MySQL database

##### Component Relationships

a) Top-down flow:
**Clients → Controllers → Services → Repositories → Database**

b) Cross-cutting concerns:
- Exception handling (`GlobalException`, `ResourceNotFoundException`)
- DTOs (`UserDto`, `CategoryDto`, `APIresponse`)

##### Component Details

For each major component, include:

a) Controllers:
- Available HTTP methods (GET, POST, PUT, DELETE)
- Main endpoints (/users, /categories)

b) Services:
- Business logic layer
- Implementation details
- Service interface methods

c) Repositories:
- JPA repository interfaces
- Database operations

d) Data Flow:
- Request/Response cycle
- DTO transformations
- Exception handling paths

##### Additional Elements

a) Annotations:
- @RestController
- @Service
- @Repository
- @Entity

b) Relationships:
- One-to-Many between entities
- Service-Repository dependencies
- Controller-Service dependencies

##### Technical Stack Indicators

- Spring Boot
- Hibernate/JPA
- MySQL
- Java 17
- Maven

**[Client Layer]**
- ↓
**[API Layer (Controllers)]**
- ↓
**[Service Layer]**
- ↓
**[Repository Layer]**
- ↓
**[Database Layer]**

**[Exception Handling] → [All Layers]**
**[DTOs/Payloads] → [Controllers ↔ Services]**

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef client fill:#2196F3,stroke:#1565C0,color:white
    classDef controller fill:#42A5F5,stroke:#1E88E5,color:white
    classDef service fill:#4CAF50,stroke:#388E3C,color:white
    classDef repo fill:#FDD835,stroke:#FBC02D,color:black
    classDef database fill:#90A4AE,stroke:#607D8B,color:white
    classDef exception fill:#F44336,stroke:#D32F2F,color:white
    classDef dto fill:#9C27B0,stroke:#7B1FA2,color:white
    
    %% Client Layer
    subgraph Clients
        WebClient[Web Client]:::client
        MobileClient[Mobile Client]:::client
        Postman[Postman]:::client
    end

    %% API Layer
    subgraph Controllers
        UserController["UserController<br>@RestController"]:::controller
        CategoryController["CategoryController<br>@RestController"]:::controller
    end

    %% Service Layer
    subgraph Services
        UserService["UserService<br>Interface"]:::service
        CategoryService["CategoryService<br>Interface"]:::service
        UserServiceImpl["UserServiceImpl<br>@Service"]:::service
        CategoryServiceImpl["CategoryServiceImpl<br>@Service"]:::service
    end

    %% Repository Layer
    subgraph Repositories
        UserRepo["UserRepo<br>@Repository"]:::repo
        CategoryRepo["CategoryRepo<br>@Repository"]:::repo
    end

    %% Database Layer
    Database[(MySQL)]:::database

    %% Cross-cutting Concerns
    subgraph Exceptions
        GlobalException["GlobalException"]:::exception
        ResourceNotFound["ResourceNotFoundException"]:::exception
    end

    subgraph DTOs
        UserDto["UserDto"]:::dto
        CategoryDto["CategoryDto"]:::dto
        APIResponse["APIResponse"]:::dto
    end

    %% Relationships
    WebClient & MobileClient & Postman --> UserController & CategoryController
    UserController --> UserService
    CategoryController --> CategoryService
    UserService --> UserServiceImpl
    CategoryService --> CategoryServiceImpl
    UserServiceImpl --> UserRepo
    CategoryServiceImpl --> CategoryRepo
    UserRepo & CategoryRepo --> Database
    
    %% DTO Relationships
    UserController <--> UserDto
    CategoryController <--> CategoryDto
    UserController & CategoryController --> APIResponse
    
    %% Exception Relationships
    GlobalException -.-> Controllers
    ResourceNotFound -.-> Services

    %% Click Events
    click UserController "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/controllers/UserController.java"
    click CategoryController "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/controllers/CategoryController.java"
    click UserService "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/services/UserService.java"
    click CategoryService "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/services/CategoryService.java"
    click UserServiceImpl "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/services/impl/UserServiceImpl.java"
    click CategoryServiceImpl "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/services/impl/CategoryServiceimpl.java"
    click UserRepo "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/repositories/UserRepo.java"
    click CategoryRepo "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/repositories/CategoryRepo.java"
    click GlobalException "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/exceptions/GlobalException.java"
    click ResourceNotFound "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/exceptions/ResourceNotFoundException.java"
    click UserDto "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/payloads/UserDto.java"
    click CategoryDto "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/payloads/CategoryDto.java"
    click APIResponse "https://github.com/Aryan-Verma23/Blogging_App/blob/master/blog_app/src/main/java/com/aryan/blog/payloads/APIresponse.java"
```
