# mehmetcozdemir/jutform-preflight architecture

> Architecture diagram of the GitHub repository mehmetcozdemir/jutform-preflight, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mehmetcozdemir/jutform-preflight
- Repository: https://github.com/mehmetcozdemir/jutform-preflight

## Overview

1. **What this repo is**
   - This is not a business app; it is a **pre-flight environment check** for the JutForm assessment stack.
   - Its job is to prove that Docker, PHP, Nginx, MySQL, Redis, and Mailpit can all run together on the machine.

2. **Deployment model**
   - The whole environment is defined in **`docker-compose.yml`** and runs as a small, containerized stack.
   - The architecture is “**edge web server + PHP app + supporting services**,” with health/verification endpoints exposed through a single local entry point.

3. **Request entry point**
   - Users and scripts hit **Nginx** on **`http://localhost:8080`**.
   - Nginx serves the static status page and proxies PHP requests to **php-fpm**.
   - This makes Nginx the front door for both browser checks and API-based checks.

4. **Backend application boundary**
   - The only visible backend code is **`backend/public/index.php`**, which acts as the PHP entry point/front controller.
   - Its role is likely to expose health/diagnostic responses and exercise connectivity to downstream services.
   - PHP runs separately from Nginx, so web serving and application execution are cleanly split.

5. **Frontend boundary**
   - The frontend is already built and checked in under **`frontend/dist/index.html`**.
   - There is no source-side SPA build pipeline in this repo; the frontend is a static status page served by Nginx.
   - The browser experience is therefore lightweight and mostly exists to visualize the service checks.

6. **Database subsystem**
   - **MySQL** is part of the verification target and is initialized from **`docker/mysql/init/00-schema.sql`**.
   - That schema file is the only explicit database asset in the tree, so the DB is used primarily to confirm connectivity and query execution rather than to model a full domain.
   - The MySQL container is part of the environment contract the assessment expects.

7. **Cache subsystem**
   - **Redis** is included as another runtime dependency to validate PHP’s ability to connect, write, and read.
   - It is not backed by any repo data files, which suggests it is a pure service-health dependency in this preflight setup.

8. **Email subsystem**
   - **Mailpit** provides SMTP capture for email delivery checks.
   - It is an integration target rather than an internal application component, verifying that outbound mail infrastructure is reachable.

9. **Container build and runtime configuration**
   - **`docker/php/Dockerfile`** builds the PHP runtime with the required extensions called out in the README: `pdo`, `pdo_mysql`, `redis`, `json`, `intl`, and `zip`.
   - **`docker/nginx/Dockerfile`**, **`docker/nginx/nginx.conf`**, and **`docker/nginx/default.conf`** define the web server image and routing behavior.
   - These files are the main infrastructure boundary between host machine and the assessment stack.

10. **Verification flow**
   - The same underlying checks can be triggered three ways: via the browser UI, **`curl /api/health`**, or **`./scripts/verify.sh`**.
   - That means the repo has one conceptual health-check pipeline with multiple presentation layers, not multiple independent implementations.
   - The script is the CLI wrapper around the service checks used for automated validation.

11. **Data flow summary**
   - Browser or CLI → Nginx → PHP-FPM → probes MySQL/Redis/Mailpit.
   - Static status UI is served directly by Nginx, while dynamic health data comes from PHP.
   - MySQL schema initialization happens once at container startup through the mounted init SQL.

12. **Operational boundaries**
   - Host ports are explicitly exposed for local verification, with the README calling out **8080, 8025, 3307, 6380, and 1025**.
   - The repo assumes Docker Compose orchestration, so the architecture is designed around reproducible local startup rather than long-running external infrastructure.

Main entry points: [`docker-compose.yml`](https://github.com/mehmetcozdemir/jutform-preflight/blob/main/docker-compose.yml) (Compose), [`backend/public/index.php`](https://github.com/mehmetcozdemir/jutform-preflight/blob/main/backend/public/index.php) (Health entry), [`docker/nginx/Dockerfile`](https://github.com/mehmetcozdemir/jutform-preflight/tree/main/docker/nginx/Dockerfile) (Nginx image), [`docker/php/Dockerfile`](https://github.com/mehmetcozdemir/jutform-preflight/tree/main/docker/php/Dockerfile) (PHP image)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Orchestration"]
  node_compose["Compose<br/>orchestrator<br/>[docker-compose.yml]"]
end

subgraph group_edge["Edge"]
  node_nginx_docker["Nginx image<br/>container build"]
  node_nginx_conf["Nginx config<br/>routing config<br/>[nginx.conf]"]
  node_nginx_site["Site config<br/>vhost config<br/>[default.conf]"]
  node_nginx["Nginx<br/>web server"]
end

subgraph group_app["Application"]
  node_php_docker["PHP image<br/>container build"]
  node_php_entry["Health entry<br/>php front controller<br/>[index.php]"]
  node_frontend_ui["Status page<br/>static frontend<br/>[index.html]"]
  node_phpfpm["PHP-FPM<br/>app runtime"]
end

subgraph group_data["Services"]
  node_mysql[("MySQL<br/>database service")]
  node_mysql_schema["Schema init<br/>sql bootstrap<br/>[00-schema.sql]"]
  node_redis[("Redis<br/>cache service")]
  node_mailpit["Mailpit<br/>smtp capture"]
end

subgraph group_verification["Verification"]
  node_verify_script["Verify script<br/>cli wrapper<br/>[verify.sh]"]
  node_browser(("Browser<br/>local client"))
  node_curl(("Curl<br/>http client"))
end

node_compose -->|"builds"| node_nginx_docker
node_compose -->|"builds"| node_php_docker
node_compose -->|"starts"| node_mysql
node_compose -->|"starts"| node_redis
node_compose -->|"starts"| node_mailpit
node_nginx_docker -->|"runs as"| node_nginx
node_nginx_conf -->|"configures"| node_nginx
node_nginx_site -->|"routes"| node_nginx
node_frontend_ui -->|"served by"| node_nginx
node_php_docker -->|"runs as"| node_phpfpm
node_php_entry -->|"executes on"| node_phpfpm
node_nginx -->|"proxies"| node_phpfpm
node_browser -->|"requests"| node_nginx
node_curl -->|"requests"| node_nginx
node_verify_script -->|"checks"| node_nginx
node_php_entry -->|"probes"| node_mysql
node_php_entry -->|"probes"| node_redis
node_php_entry -->|"probes"| node_mailpit
node_mysql_schema -->|"initializes"| node_mysql

click node_compose "https://github.com/mehmetcozdemir/jutform-preflight/blob/main/docker-compose.yml"
click node_nginx_docker "https://github.com/mehmetcozdemir/jutform-preflight/tree/main/docker/nginx/Dockerfile"
click node_nginx_conf "https://github.com/mehmetcozdemir/jutform-preflight/blob/main/docker/nginx/nginx.conf"
click node_nginx_site "https://github.com/mehmetcozdemir/jutform-preflight/blob/main/docker/nginx/default.conf"
click node_php_docker "https://github.com/mehmetcozdemir/jutform-preflight/tree/main/docker/php/Dockerfile"
click node_php_entry "https://github.com/mehmetcozdemir/jutform-preflight/blob/main/backend/public/index.php"
click node_frontend_ui "https://github.com/mehmetcozdemir/jutform-preflight/blob/main/frontend/dist/index.html"
click node_verify_script "https://github.com/mehmetcozdemir/jutform-preflight/blob/main/scripts/verify.sh"
click node_mysql_schema "https://github.com/mehmetcozdemir/jutform-preflight/blob/main/docker/mysql/init/00-schema.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_compose toneBlue
class node_nginx_docker,node_nginx_conf,node_nginx_site,node_nginx toneAmber
class node_php_docker,node_php_entry,node_frontend_ui,node_phpfpm toneMint
class node_mysql,node_mysql_schema,node_redis,node_mailpit toneRose
class node_verify_script,node_browser,node_curl toneIndigo
```

## Components

### Orchestration

Docker Compose defines and wires the local assessment stack.

- [Compose](https://github.com/mehmetcozdemir/jutform-preflight/blob/main/docker-compose.yml): orchestrator · Top-level stack definition and service wiring. · `docker-compose.yml`

### Edge

Web entry, static delivery, and request routing.

- [Nginx image](https://github.com/mehmetcozdemir/jutform-preflight/tree/main/docker/nginx/Dockerfile): container build · Builds the web server runtime. · `docker/nginx/Dockerfile`
- [Nginx config](https://github.com/mehmetcozdemir/jutform-preflight/blob/main/docker/nginx/nginx.conf): routing config · Server and proxy behavior for the local front door. · `docker/nginx/nginx.conf`
- [Site config](https://github.com/mehmetcozdemir/jutform-preflight/blob/main/docker/nginx/default.conf): vhost config · Default site routes static content and PHP requests. · `docker/nginx/default.conf`
- **Nginx**: web server · Front door that serves static content and proxies PHP.

### Application

PHP front controller and checked-in status UI.

- [PHP image](https://github.com/mehmetcozdemir/jutform-preflight/tree/main/docker/php/Dockerfile): container build · Builds the PHP-FPM runtime with required extensions. · `docker/php/Dockerfile`
- [Health entry](https://github.com/mehmetcozdemir/jutform-preflight/blob/main/backend/public/index.php): php front controller · Application entry point for dynamic status and probes. · `backend/public/index.php`
- [Status page](https://github.com/mehmetcozdemir/jutform-preflight/blob/main/frontend/dist/index.html): static frontend · Prebuilt browser UI served directly by Nginx. · `frontend/dist/index.html`
- **PHP-FPM**: app runtime · Executes the PHP application behind the web server.

### Services

Stateful and integration services validated by the stack.

- **MySQL**: database service · Relational dependency exercised by the health checks.
- [Schema init](https://github.com/mehmetcozdemir/jutform-preflight/blob/main/docker/mysql/init/00-schema.sql): sql bootstrap · Startup schema loaded into MySQL. · `docker/mysql/init/00-schema.sql`
- **Redis**: cache service · Cache dependency used to validate read/write connectivity.
- **Mailpit**: smtp capture · Mail sink for outbound delivery checks.

### Verification

CLI path for automated health checks.

- [Verify script](https://github.com/mehmetcozdemir/jutform-preflight/blob/main/scripts/verify.sh): cli wrapper · Automated local verification entry point. · `scripts/verify.sh`
- **Browser**: local client · Human-facing entry to the status page and checks.
- **Curl**: http client · Command-line entry to the health endpoint.

## Connections

- Compose → Nginx image: builds · Compose instantiates the web server image.
- Compose → PHP image: builds · Compose instantiates the PHP runtime image.
- Compose → MySQL: starts · Compose launches the database service.
- Compose → Redis: starts · Compose launches the cache service.
- Compose → Mailpit: starts · Compose launches the mail capture service.
- Nginx image → Nginx: runs as · The built image provides the Nginx runtime.
- Nginx config → Nginx: configures · Core server behavior is defined here.
- Site config → Nginx: routes · Site routing and content handling are defined here.
- Status page → Nginx: served by · Static status page is delivered directly by Nginx.
- PHP image → PHP-FPM: runs as · The built image provides the PHP-FPM runtime.
- Health entry → PHP-FPM: executes on · Dynamic responses are generated by the PHP runtime.
- Nginx → PHP-FPM: proxies · Nginx forwards PHP requests to the app runtime.
- Browser → Nginx: requests · Browser traffic enters through the local web server.
- Curl → Nginx: requests · CLI health checks enter through the same front door.
- Verify script → Nginx: checks · Scripted verification uses the exposed HTTP entry point.
- Health entry → MySQL: probes · PHP validates database connectivity and queries.
- Health entry → Redis: probes · PHP validates cache connectivity.
- Health entry → Mailpit: probes · PHP validates outbound mail delivery.
- Schema init → MySQL: initializes · Schema is loaded when the database container starts.
