# aymanetech/it-survey-in-spring-boot architecture

> Architecture diagram of the GitHub repository aymanetech/it-survey-in-spring-boot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aymanetech/it-survey-in-spring-boot
- Repository: https://github.com/aymanetech/it-survey-in-spring-boot

## Overview

##### Project type and purpose
- This is a backend‐only, modular monolith web application built with Spring Boot.
- It implements a professional survey platform (“State of Dev”) for the IT industry, using Domain-Driven Design (DDD) and Spring Modulith to group code into bounded contexts.

##### High-level architecture overview
- The application is packaged as a single Spring Boot JAR, deployed via Docker (Dockerfile / docker-compose).
- It exposes REST endpoints (Swagger/OpenAPI) for surveys, survey editions, questions, subjects, authentication and owner operations.
- It persists data in PostgreSQL and uses Redis for caching.

A. External / Infrastructure
- HTTP Clients (e.g. UI or external consumers)
- PostgreSQL 16 database
- Redis cache
- Docker / Docker Compose orchestration
B. Spring Boot Modular Monolith
- Module: Survey Management (core domain)
– Web layer: SurveyController, ChapterController, QuestionController, SurveyEditionController, SurveySubmissionController, SurveyEditionResultController
– Application layer: survey.application.service + mappers + DTOs
– Domain layer: survey.domain.entity, value objects, repository interfaces
– Infrastructure layer: survey.infrastructure (deserializers, persistence adapters)
- Module: Identity and Access (user authentication + roles + authorities)
– Web layer: AuthenticationController (via JwtAuthenticationFilter)
– Application layer: AuthenticationService, UserService + DTOs + mappers
– Domain layer: user.domain.entity, repository interfaces, value objects
– Infrastructure: user.infrastructure.seeder
- Module: Owner Management (owners who can create surveys)
– Similar layered structure under owner.package
- Module: Common / Cross-cutting
– Common application services, mappers, validation annotations, exception handlers (GlobalExceptionHandler)
– Config: SecurityConfig, OpenApiConfig, RedisConfig, JWT filter
C. Interactions
- HTTP requests → Spring Web controllers (module-specific)
- Controllers → Application services → Domain logic + Repositories
- Repositories → PostgreSQL
- Application services → Redis cache (via Spring Cache abstraction) for survey templates, editions, subjects, statistics

##### Relationships & data-flow
1. Client issues REST call → enters Module X Controller
2. Controller forwards to Module X Service (application/service)
3. Service applies business rules, orchestrates Domain entities/repositories
4. Repository adapter (infrastructure) reads/writes PostgreSQL
5. Caching annotations in service or repository layer read/write Redis
6. Service returns DTOs → Controller → JSON response to client

##### Architectural patterns and principles
- Layered architecture within each module: Web → Application → Domain → Infrastructure
- Bounded contexts implemented via Spring Modulith modules (survey, user, owner)
- DDD building blocks: Entities, Value Objects, Repositories, Domain Exceptions
- Cross-cutting via common module (validation, error handling, mapping)
- JWT-based security filter in request chain

##### Technologies and frameworks to annotate
- Spring Boot 3.2.0 (core runtime)
- Spring Modulith (module boundaries)
- Spring Web MVC (REST controllers)
- Spring Data (optional – repositories)
- Spring Security + JWT
- Spring Cache + Redis
- PostgreSQL
- Docker & Docker Compose

## Diagram (Mermaid)

```mermaid
flowchart TD
    HTTP["HTTP Client"]:::external
    JWT["Spring Security / JWT Filter"]:::common
    HTTP -->|"REST JSON"| JWT

    subgraph "Docker / Spring Boot Monolith"
        direction TB
        APP["Application (Main)"]:::common
        click APP "https://github.com/aymanetech/it-survey-in-spring-boot/blob/main/src/main/java/com/wora/stateOfDev/Application.java"

        subgraph "Common / Cross-cutting"
            direction TB
            CommonDirs["Common Module"]:::common
            click CommonDirs "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/common"
            Config["Config"]:::common
            click Config "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/config"
            Validation["Validation & Utilities"]:::common
            click Validation "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/common/application/validation"
            Exception["GlobalExceptionHandler"]:::common
            click Exception "https://github.com/aymanetech/it-survey-in-spring-boot/blob/main/src/main/java/com/wora/stateOfDev/common/infrastructure/web/GlobalExceptionHandler.java"
        end

        subgraph "Survey Management Module"
            direction TB
            SM_Web["Web Layer (Controllers)"]:::survey
            click SM_Web "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/survey/infrastructure/web"
            SM_App["Application Layer"]:::survey
            click SM_App "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/survey/application"
            SM_Dom["Domain Layer"]:::survey
            click SM_Dom "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/survey/domain"
            SM_Infra["Infrastructure Layer"]:::survey
            click SM_Infra "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/survey/infrastructure/deserializer"
        end

        subgraph "Identity & Access Module"
            direction TB
            IA_Web["Web Layer"]:::identity
            IA_App["Application Layer"]:::identity
            click IA_App "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/user/application"
            IA_Dom["Domain Layer"]:::identity
            click IA_Dom "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/user/domain"
            IA_Infra["Infrastructure Seeder"]:::identity
            click IA_Infra "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/user/infrastructure/seeder"
        end

        subgraph "Owner Management Module"
            direction TB
            Owner_Web["Web Layer"]:::owner
            click Owner_Web "https://github.com/aymanetech/it-survey-in-spring-boot/blob/main/src/main/java/com/wora/stateOfDev/owner/infrastructure/web/OwnerController.java"
            Owner_App["Application Layer"]:::owner
            click Owner_App "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/owner/application"
            Owner_Dom["Domain Layer"]:::owner
            click Owner_Dom "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/src/main/java/com/wora/stateOfDev/owner/domain"
        end

        subgraph "Docker / Docker Compose Orchestration"
            direction TB
            DFile["Dockerfile"]:::infra
            click DFile "https://github.com/aymanetech/it-survey-in-spring-boot/tree/main/Dockerfile"
            DComp["docker-compose.yml"]:::infra
            click DComp "https://github.com/aymanetech/it-survey-in-spring-boot/blob/main/docker-compose.yml"
        end
    end

    JWT --> SM_Web
    JWT --> IA_Web
    JWT --> Owner_Web

    SM_Web -->|"calls"| SM_App
    SM_App -->|"JPA call"| SM_Infra
    SM_Infra -->|"reads/writes"| Postgres
    SM_App -.->|"Redis GET/PUT"| Redis

    IA_Web -->|"calls"| IA_App
    IA_App -->|"JPA call"| IA_Infra
    IA_Infra -->|"reads/writes"| Postgres
    IA_App -.->|"Redis GET/PUT"| Redis

    Owner_Web -->|"calls"| Owner_App
    Owner_App -->|"JPA call"| Owner_Dom
    Owner_Dom -->|"reads/writes"| Postgres
    Owner_App -.->|"Redis GET/PUT"| Redis

    CommonDirs --> SM_App
    CommonDirs --> IA_App
    CommonDirs --> Owner_App

    subgraph "External Systems"
        direction TB
        Postgres["PostgreSQL"]:::infra
        Redis["Redis Cache"]:::infra
    end

    classDef survey fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef identity fill:#d4edda,stroke:#333,stroke-width:1px
    classDef owner fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef common fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef infra fill:#eeeeee,stroke:#333,stroke-width:1px
    classDef external fill:#fff3cd,stroke:#333,stroke-width:1px
```
