# jhordyess/dockerized-spring-react-mysql architecture

> Architecture diagram of the GitHub repository jhordyess/dockerized-spring-react-mysql, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jhordyess/dockerized-spring-react-mysql
- Repository: https://github.com/jhordyess/dockerized-spring-react-mysql

## Overview

##### Project type and purpose
- This is a full-stack, Dockerized web application.
- Frontend: React single-page app served by Nginx.
- Backend: Spring Boot REST API.
- Data layer: MySQL database + phpMyAdmin for management.
- Orchestration: Docker Compose (production and development variants).

##### Main components
a. Frontend Container
- Nginx server hosting the compiled React app (index.html, static assets).
- Port 80 on the host → mapped to the container’s port 80.
b. Backend Container
- Spring Boot application (DemoUserApplication).
- Exposes a REST API on port 8080.
- Follows MVC:
– Controller (UserController)
– Domain & Repository (User, UserRepository)
c. Database Container
- MySQL server (3306)
- Uses environment variables from .env for credentials and schema.
d. phpMyAdmin Container
- Web UI for managing MySQL (default port 81).
e. Docker Network & Volumes
- Shared network allowing containers to communicate by service name.
- Volume for MySQL data persistence.
f. Docker Compose Orchestrator
- Defines service interdependencies and startup order (docker-compose.yml & docker-compose.dev.yml).

##### Relationships and data flows
- Browser → Nginx (frontend)
→ serves React assets.
- React app → Spring Boot API over HTTP (e.g., POST /api/users).
- Spring Boot → MySQL via JDBC.
- phpMyAdmin → MySQL for DB inspection/management.

##### Architectural patterns & design principles
- Separation of concerns: UI vs API vs persistence.
- Containerization: each component runs in its own Docker container.
- Dev vs Prod mode:
- Prod Compose file builds images and exposes ports 80 (frontend) & 3306.
- Dev Compose file adds code-volume mounting and phpMyAdmin service.
- Spring MVC pattern in backend

- Clear labels for each container/service.
- Callouts for major frameworks and languages:
- React (JavaScript, Vite)
- Nginx
- Spring Boot (Java, Maven)
- MySQL + phpMyAdmin

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Browser
    Browser["User Browser"]:::external

    %% Docker Network
    subgraph "Docker Network"
        direction TB
        F["Frontend Container\nNginx + React\nport 80"]:::frontend
        B["Backend Container\nSpring Boot API\nport 8080"]:::backend
        DB["MySQL Database\nport 3306"]:::database
        PA["phpMyAdmin\nport 81"]:::admin
    end

    %% Orchestrators
    subgraph "Docker Compose Orchestrator"
        direction TB
        DCProd["docker-compose.yml"]:::compose
        DCDev["docker-compose.dev.yml"]:::compose
    end

    %% Devcontainers
    subgraph "Devcontainers"
        direction TB
        FDV["frontend/.devcontainer.json"]:::compose
        BDV["backend/.devcontainer.json"]:::compose
    end

    %% Flows
    Browser -->|"HTTP 80"| F
    F -->|"HTTP /api/... to 8080"| B
    B -->|"JDBC 3306"| DB
    PA -->|"HTTP 81"| DB

    %% Orchestration links
    DCProd --> F
    DCProd --> B
    DCProd --> DB
    DCDev --> F
    DCDev --> B
    DCDev --> DB
    DCDev --> PA

    %% Devcontainer links
    FDV --> F
    BDV --> B

    %% File Mappings
    subgraph "File Mappings"
        direction TB
        FDockerfile["frontend/Dockerfile"]:::file
        Fnginx["frontend/nginx.conf"]:::file
        Findex["frontend/index.html"]:::file
        Fsrc["frontend/src/"]:::file
        Fpkg["frontend/package.json"]:::file
        Fvite["frontend/vite.config.js"]:::file
        BDocker["backend/Dockerfile"]:::file
        Bpom["backend/pom.xml"]:::file
        DemoApp["DemoUserApplication.java"]:::file
        UserCtrl["UserController.java"]:::file
        UserDomain["User.java"]:::file
        UserRepo["UserRepository.java"]:::file
        BConfig["application.yml"]:::file
        EnvExample[".env.example"]:::file
        ProdCompose["docker-compose.yml"]:::file
        DevCompose["docker-compose.dev.yml"]:::file
        FDVC["frontend/.devcontainer.json"]:::file
        BDVC["backend/.devcontainer.json"]:::file
    end

    %% Click Events
    click F "https://github.com/jhordyess/dockerized-spring-react-mysql/tree/main/frontend/Dockerfile"
    click F "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/frontend/nginx.conf"
    click F "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/frontend/index.html"
    click F "https://github.com/jhordyess/dockerized-spring-react-mysql/tree/main/frontend/src/"
    click F "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/frontend/package.json"
    click F "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/frontend/vite.config.js"
    click B "https://github.com/jhordyess/dockerized-spring-react-mysql/tree/main/backend/Dockerfile"
    click B "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/backend/pom.xml"
    click B "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/backend/src/main/java/com/jhordyess/demouser/DemoUserApplication.java"
    click B "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/backend/src/main/java/com/jhordyess/demouser/controller/UserController.java"
    click B "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/backend/src/main/java/com/jhordyess/demouser/domain/User.java"
    click B "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/backend/src/main/java/com/jhordyess/demouser/domain/UserRepository.java"
    click B "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/backend/src/main/resources/application.yml"
    click DCProd "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/docker-compose.yml"
    click DCDev "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/docker-compose.dev.yml"
    click FDV "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/frontend/.devcontainer.json"
    click BDV "https://github.com/jhordyess/dockerized-spring-react-mysql/blob/main/backend/.devcontainer.json"

    %% Styles
    classDef frontend fill:#CCE5FF,stroke:#333,stroke-width:1px
    classDef backend fill:#CCFFCC,stroke:#333,stroke-width:1px
    classDef database fill:#FFCCCC,stroke:#333,stroke-width:1px
    classDef admin fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef compose fill:#FFF2CC,stroke:#333,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#333,stroke-width:1px
    classDef file fill:#F0F0F0,stroke:#999,stroke-dasharray: 2 2
```
