How aymanetech/it-survey-in-spring-boot works
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