# callicoder/spring-security-react-ant-design-polls-app architecture

> Architecture diagram of the GitHub repository callicoder/spring-security-react-ant-design-polls-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/callicoder/spring-security-react-ant-design-polls-app
- Repository: https://github.com/callicoder/spring-security-react-ant-design-polls-app

## Overview

##### Project type and purpose
- This is a full-stack polling application (“Polls App”) that lets users sign up, authenticate (via JWT), create polls, vote, and view results.
- The back end is a monolithic Spring Boot application with REST APIs, Spring Security (JWT), MySQL persistence, and Flyway-like migrations (db/migration).
- The front end is a React single-page application styled with Ant Design, served by a lightweight Nginx container in production.

##### File structure
Top-level directories/files:
- polling-app-client: React code, Webpack overrides, public assets, service worker, Nginx config, Dockerfile
- polling-app-server: Java source, Maven wrapper, security config, controllers, services, repositories, migration scripts, Dockerfile
- deployments: Kubernetes manifests (Kustomize, MySQL, frontend, backend)
- docker-compose.yml & minikube.txt: local multi-container orchestration
- .gitignore, Readme.md: repo-wide docs and ignores

Architectural hints:
- separation of concerns between client, server, and database
- use of JWT for stateless auth
- containerization via Dockerfiles & orchestration via Docker Compose or Kubernetes
- Spring MVC + service + repository layers (typical layered monolith)

##### README for additional insights
- Walkthrough series on building back-end (Spring Boot + Spring Security + JWT + MySQL) and front-end (React + Ant Design).
- Ports: 8080 for APIs, 3000 for client.
- Default roles loaded via data.sql.

##### Elements
- Labels: name each component (e.g., “React SPA”, “Nginx Proxy”, “Spring Boot API”)
- Blue rectangles for user-facing components (Browser, SPA)
- Green rectangles for services (Nginx, API)

Layer 1: User’s Browser
Layer 2: React SPA (static assets), served by Nginx container
Layer 3: Request routing (Nginx ↔ API Proxy)
Layer 4: Spring Boot Monolith
- Security filter chain (JWTAuthenticationFilter → JwtTokenProvider)
- Controllers (Auth, Poll, User)
- Services → Repositories
Layer 5: MySQL Database (with migrations & seed data)
Layer 6: DevOps / Infra
- Docker Build & Push (two images)
- docker-compose.yml (services + network + volumes)
- Kubernetes manifests (mysql-deployment, client/server deployments, kustomization)

Summary:
- Inside API, subdivide into Security layer, Controllers, Services, Repositories.
- JWT token flow on the path between client and API.
- Surround with an orchestration boundary indicating Docker Compose/Kubernetes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    Browser["User's Browser"]:::frontend
    Browser -->|"HTTP GET /"| ReactSPA
    Browser -->|"HTTP API Requests"| Nginx

    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        ReactSPA["React SPA"]:::frontend
        PollsUI["Polls UI Components"]:::frontend
        UserUI["User Authentication UI"]:::frontend
        APIUtils["API Utilities"]:::frontend
        ReactSPA --> PollsUI
        ReactSPA --> UserUI
        ReactSPA --> APIUtils
        ReactSPA --> Nginx
    end

    %% Infra Layer
    Nginx["Nginx Reverse Proxy"]:::infra
    Nginx -->|"Proxy /api on 8080"| APIServer

    %% Backend Layer
    subgraph "Spring Boot API" 
        direction TB
        App["PollsApplication"]:::backend

        subgraph "Security Layer"
            direction TB
            SecurityConfig["SecurityConfig"]:::backend
            JwtFilter["JwtAuthenticationFilter"]:::backend
            JwtProvider["JwtTokenProvider"]:::backend
            AuthEntry["JwtAuthenticationEntryPoint"]:::backend
            UserDetails["CustomUserDetailsService"]:::backend
        end

        subgraph "Controllers"
            direction TB
            AuthCtrl["AuthController"]:::backend
            PollCtrl["PollController"]:::backend
            UserCtrl["UserController"]:::backend
        end

        subgraph "Service Layer"
            direction TB
            PollService["PollService"]:::backend
        end

        subgraph "Repository Layer"
            direction TB
            PollRepo["PollRepository"]:::backend
            UserRepo["UserRepository"]:::backend
            RoleRepo["RoleRepository"]:::backend
            VoteRepo["VoteRepository"]:::backend
        end

        subgraph "Data Models"
            direction TB
            Models["Model Entities"]:::backend
            Audit["Audit Base Classes"]:::backend
        end

        subgraph "Payload DTOs"
            direction TB
            DTOs["Request/Response DTOs"]:::backend
        end

        App --> SecurityConfig
        SecurityConfig --> JwtFilter
        JwtFilter --> JwtProvider
        JwtFilter --> AuthEntry
        JwtFilter --> UserDetails
        App --> AuthCtrl
        App --> PollCtrl
        App --> UserCtrl
        AuthCtrl --> PollService
        PollCtrl --> PollService
        UserCtrl --> UserDetails
        PollService --> PollRepo
        PollRepo --> Models
        UserRepo --> Models
        RoleRepo --> Models
        VoteRepo --> Models
        DTOs --> AuthCtrl
        DTOs --> PollCtrl
        DTOs --> UserCtrl
    end

    %% Database Layer
    DB["MySQL Database"]:::database
    APIServer -->|"JDBC (Spring Data JPA)"| DB

    %% Migration & Seed
    DB -->|"Migrations & Seed Data"| Migration
    Migration["db/migration + data.sql"]:::database

    %% Orchestration
    subgraph "Orchestration (Docker Compose / Kubernetes)" 
        direction TB
        Compose["docker-compose.yml"]:::orchestration
        K8s["Kubernetes Manifests"]:::orchestration
    end

    Browser --> Compose
    Compose --> ReactSPA
    Compose --> APIServer
    Compose --> DB
    K8s --> ReactSPA
    K8s --> APIServer
    K8s --> DB

    %% Click Events
    click ReactSPA "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-client/src/app/App.js"
    click PollsUI "https://github.com/callicoder/spring-security-react-ant-design-polls-app/tree/master/polling-app-client/src/poll"
    click UserUI "https://github.com/callicoder/spring-security-react-ant-design-polls-app/tree/master/polling-app-client/src/user"
    click APIUtils "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-client/src/util/APIUtils.js"
    click Nginx "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-client/nginx.conf"
    click Compose "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/docker-compose.yml"
    click K8s "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/deployments/kustomization.yaml"
    click App "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/PollsApplication.java"
    click AuthCtrl "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/controller/AuthController.java"
    click PollCtrl "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/controller/PollController.java"
    click UserCtrl "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/controller/UserController.java"
    click SecurityConfig "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/config/SecurityConfig.java"
    click JwtFilter "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/security/JwtAuthenticationFilter.java"
    click JwtProvider "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/security/JwtTokenProvider.java"
    click AuthEntry "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/security/JwtAuthenticationEntryPoint.java"
    click UserDetails "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/security/CustomUserDetailsService.java"
    click PollService "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/service/PollService.java"
    click PollRepo "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/repository/PollRepository.java"
    click UserRepo "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/repository/UserRepository.java"
    click RoleRepo "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/repository/RoleRepository.java"
    click VoteRepo "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/java/com/example/polls/repository/VoteRepository.java"
    click Models "https://github.com/callicoder/spring-security-react-ant-design-polls-app/tree/master/polling-app-server/src/main/java/com/example/polls/model"
    click Audit "https://github.com/callicoder/spring-security-react-ant-design-polls-app/tree/master/polling-app-server/src/main/java/com/example/polls/model/audit"
    click DTOs "https://github.com/callicoder/spring-security-react-ant-design-polls-app/tree/master/polling-app-server/src/main/java/com/example/polls/payload"
    click Migration "https://github.com/callicoder/spring-security-react-ant-design-polls-app/tree/master/polling-app-server/src/main/resources/db/migration"
    click DB "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/resources/data.sql"
    click DB "https://github.com/callicoder/spring-security-react-ant-design-polls-app/blob/master/polling-app-server/src/main/resources/application.properties"

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1
    classDef infra fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20
    classDef backend fill:#FFE082,stroke:#FF6F00,color:#E65100
    classDef database fill:#B3E5FC,stroke:#01579B,color:#01579B
    classDef orchestration fill:#E1BEE7,stroke:#6A1B9A,color:#6A1B9A
```
