# braians/fullstack-spring-boot-and-angular-blog architecture

> Architecture diagram of the GitHub repository braians/fullstack-spring-boot-and-angular-blog, 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/braians/fullstack-spring-boot-and-angular-blog
- Repository: https://github.com/braians/fullstack-spring-boot-and-angular-blog

## Overview

##### Main Components
- Backend Service – “spring-blog-backend”: This is the REST API service implemented with Spring Boot. Its responsibilities include:
- Providing endpoints (via various controllers such as AuthController, PostController, CategoryController, etc.)
- Business logic in services (AuthService, PostService, etc.) that encapsulate actions like authentication, post management, and category handling.
- Data persistence layer using Spring Data JPA with repositories (for User, Post, Comment, etc.) to interact with the MySQL database.
- Configuration, security (JWT filters, security configurations), exception handling, and Swagger documentation for API testing.
- Frontend Client – “spring-blog-client”: This Angular application handles:
- Routing and view architecture (modules for home, login, and user management).
- Interceptors (for JWT token attachment, error handling) and services (authentication, posts, comments, etc.).
- Presentation logic and UI components (layout, shared components, pagination, pages for posts, categories, authentication pages).
- Database (MySQL): Acts as the persistent data store for user information, blog posts, comments, categories, tags, etc.
- Docker & Deployment: Docker-compose and Dockerfiles for both backend and frontend indicate containerized deployment. The container setup encapsulates application runtime dependencies and configurations.

##### Their Relationships and Interactions
- The Angular frontend communicates with the Spring Boot backend via REST API endpoints. This communication involves sending HTTP requests for user authentication, CRUD operations on posts, comments, tags, and categories.
- The Spring Boot backend, after authenticating requests (using JWT authentication), processes business logic and interacts with the database using repository patterns.
- Docker-compose ties together the containers (backend, frontend, and the MySQL database), ensuring that proper environment variables and network settings are applied.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The clear division between frontend (Angular) and backend (Spring Boot) emphasizes a decoupled architecture.
- MVC-like Pattern in the Backend: Controllers (handling HTTP requests), Services (business logic), and Repositories (data persistence) mirror the MVC separation.
- Security Best Practices: Use of Spring Security with JWT for authenticated API access.
- RESTful API Design: The backend exposes REST endpoints suited for CRUD operations, highlighted by Swagger documentation.
- Modular Design in Angular: The frontend structure shows feature modules (login, home, user) and shared modules to promote reusability.

##### Detailing Key Technologies, Frameworks, and Libraries
- Backend Technologies: Java 11, Spring Boot (including spring-boot-starter-web, security, data-jpa), jjwt for JWT generation/validation, Lombok for easier coding, and MySQL as the data source.
- Frontend Technologies: Angular (CLI v17.1.1), Bulma for styling, ngx-toastr for notifications, ng-select, and additional libraries (Angular animations, FontAwesome).
- Deployment/Containers: Docker and docker-compose to orchestrate multi-container deployment.

- Controllers (grouping API endpoints).
- Services (business logic).
- Repositories / Data Access Layer.
- Security/Configuration components.
- For the Frontend, outline major modules (login, home, user management) and include key integration points like interceptors.
- Optionally, include an overlay of the Docker-based deployment environment showing container boundaries managed by “docker-compose”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (Angular)"
        FE["Angular App (Modules, Components, Routing)"]:::frontend
        FEInt["Interceptors (JWT & Errors)"]:::frontend
    end

    subgraph "Backend (Spring Boot)"
        BE_Controller["REST Controllers"]:::backend
        BE_Service["Business Services"]:::backend
        BE_Repo["Repositories (Data Persistence)"]:::backend
        BE_Security["Security & Configuration (JWT, Swagger, CORS)"]:::backend
    end

    DB["MySQL Database"]:::database

    subgraph "Deployment (Docker)"
        DC["Docker Compose Orchestration"]:::docker
        B_Docker["Backend Dockerfile"]:::docker
        F_Docker["Frontend Dockerfile"]:::docker
    end

    %% Relationships
    FE -->|"HTTP(JWT)"| BE_Controller
    FEInt -->|"Integrates with"| FE

    BE_Controller -->|"Calls business logic"| BE_Service
    BE_Service -->|"Interacts with"| BE_Repo
    BE_Repo -->|"Persist data"| DB
    BE_Security ---|"Secures"| BE_Controller

    DC ---|"Orchestrates"| FE
    DC ---|"Orchestrates"| BE_Controller
    DC ---|"Orchestrates"| DB

    %% Click Events for Frontend
    click FE "https://github.com/braians/fullstack-spring-boot-and-angular-blog/tree/master/spring-blog-client/src/app"
    click FEInt "https://github.com/braians/fullstack-spring-boot-and-angular-blog/tree/master/spring-blog-client/src/app/core/interceptors"

    %% Click Events for Backend
    click BE_Controller "https://github.com/braians/fullstack-spring-boot-and-angular-blog/tree/master/spring-blog-backend/src/main/java/com/github/braians/springblog/controller"
    click BE_Service "https://github.com/braians/fullstack-spring-boot-and-angular-blog/tree/master/spring-blog-backend/src/main/java/com/github/braians/springblog/service"
    click BE_Repo "https://github.com/braians/fullstack-spring-boot-and-angular-blog/tree/master/spring-blog-backend/src/main/java/com/github/braians/springblog/repository"
    click BE_Security "https://github.com/braians/fullstack-spring-boot-and-angular-blog/tree/master/spring-blog-backend/src/main/java/com/github/braians/springblog/config"

    %% Click Events for Deployment
    click DC "https://github.com/braians/fullstack-spring-boot-and-angular-blog/blob/master/docker-compose.yml"
    click B_Docker "https://github.com/braians/fullstack-spring-boot-and-angular-blog/tree/master/spring-blog-backend/Dockerfile"
    click F_Docker "https://github.com/braians/fullstack-spring-boot-and-angular-blog/tree/master/spring-blog-client/Dockerfile"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef database fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef docker fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
