# pichyynews/nuggetgroup architecture

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

- Interactive diagram: https://gitdiagram.com/pichyynews/nuggetgroup
- Repository: https://github.com/pichyynews/nuggetgroup

## Overview

##### Project type & purpose (what you’re diagramming)
From the file tree + README, this is **not an application codebase**; it’s a **Docker Compose–based infrastructure project** that orchestrates a small system consisting of:

- **Strapi** headless CMS (`prawee/strapi`) — main application service
- **PostgreSQL 15** (`postgres:15-alpine`) — persistence layer for Strapi
- **pgAdmin 4** (`dpage/pgadmin4`) — web UI for DB administration

##### What the file structure implies architecturally
Top-level files indicate a “compose split by service” pattern:

- `docker-compose.yaml` — root orchestrator (likely includes/merges the service yamls, defines shared network/volumes, env_file, etc.)
- `app.yaml` — Strapi service definition (named `s2app` per README)
- `db.yaml` — Postgres service definition (named `s2db`)
- `admin.yaml` — pgAdmin service definition (named `s2admin`)
- `.env.example` — environment contract (ports, DB creds, admin creds, etc.)
- `.gitignore` — ignore local `.env`, volumes, etc.

This strongly suggests:
- **Single deployment unit** (one compose stack)
- **One internal Docker network** (implicit or explicit)
- **Startup ordering**: app/admin depend on db readiness via **healthcheck** gating (explicitly stated in README)

##### User / Browser → Strapi
- HTTP to `localhost:1337`
- `/admin` as the Strapi admin UI path (same service)

##### Strapi → PostgreSQL
- TCP connection (5432 internally)
- Uses credentials from `.env`
- This is the core data dependency

##### User / Browser → pgAdmin
- HTTP to `localhost:5050`

##### pgAdmin → PostgreSQL
- TCP connection to Postgres (same network)
- Uses pgAdmin config + DB creds

##### Dependency/ordering
- DB healthcheck → gates startup/availability of Strapi + pgAdmin
- As “depends_on (healthy)” or “wait-for-DB”

##### Important architectural patterns to highlight (specific to this stack)
- **3-tier pattern** (App ↔ DB, plus Admin tool)
- **Headless CMS**: Strapi provides API + admin UI (same container)
- **Infrastructure-as-configuration**: environment-driven via `.env`
- **Resilience on startup**: DB **healthcheck** prevents race conditions
- **Single-network service discovery**: containers talk by service name on the compose network (worth labeling: “DNS via Docker Compose service name”)

##### Labels (be explicit)
- Service name (e.g., `s2app`)
- Docker image (e.g., `prawee/strapi`)
- Key ports (internal + published)

- Protocol (HTTP, TCP/Postgres)
- Port (1337, 5050, 5432)

- Browser → Strapi (manage content, serve APIs)
- Strapi → Postgres (read/write content)
- Browser → pgAdmin (DB management UI)
- pgAdmin → Postgres (admin queries)

- startup dependency (`depends_on: condition: service_healthy`)
- optional flows (if any)

##### Ingress endpoints
- `localhost:1337` (Strapi + `/admin`)
- `localhost:5050` (pgAdmin)

Title: **“NuggetGroup Docker Compose Architecture (Strapi + PostgreSQL + pgAdmin)”**

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% =========================
    %% Diagram 1 — Context
    %% =========================
    subgraph "Diagram 1: Context (Who uses what)"
        U["ContentAdmin/Developer\n(Browser)"]:::actor

        subgraph "DockerHostMachine\n(RunsDocker+ComposeStack)"
            SYS["NuggetGroupCMSStack\n(Strapi+PostgreSQL+pgAdmin)"]:::boundary
            STRAPI_CTX["StrapiHTTPEndpoint\nlocalhost:1337\n(also /admin)"]:::ingress
            PGADMIN_CTX["pgAdminHTTPEndpoint\nlocalhost:5050"]:::ingress
        end

        U -->|"HTTP:1337"| STRAPI_CTX
        U -->|"HTTP:5050"| PGADMIN_CTX
        STRAPI_CTX -->|"servedby"| SYS
        PGADMIN_CTX -->|"servedby"| SYS
    end

    %% =========================
    %% Diagram 2 — Container/Deployment (Main)
    %% =========================
    subgraph "Diagram 2: Container/Deployment (Docker Compose Topology)"
        subgraph "DockerComposeProject\n(SingleDeploymentUnit)"
            COMPOSE["docker-compose.yaml\n(ComposeOrchestrator)"]:::compose

            subgraph "ComposeNetwork\n(defaultnetwork+DNSbysvcname)"
                S2APP["s2app\nStrapiContainer\nimage:prawee/strapi\ninternal:1337\npublished:localhost:1337->1337"]:::container

                S2DB[("s2db\nPostgreSQL15\nimage:postgres:15-alpine\ninternal:5432\n(nohostpublish)")]:::db

                S2ADMIN["s2admin\npgAdmin4Container\nimage:dpage/pgadmin4\ninternal:5050\npublished:localhost:5050->5050"]:::container

                %% Volumes (explicitly called out; exact mounts may vary by yaml)
                VDB[("Volume:PostgresData\n(persistence)")]:::volume
                VAPP[("Volume:StrapiData\n(uploads/config if defined)")]:::volume
                VADM[("Volume:pgAdminState\n(persistence if defined)")]:::volume
            end
        end

        %% Runtime traffic (green)
        S2APP -->|"TCP/Postgres:5432\nread/writeCMSdata"| S2DB
        S2ADMIN -->|"TCP/Postgres:5432\nadminqueries"| S2DB

        %% Startup/healthcheck gating (orange dashed)
        S2DB -.->|"healthcheck:service_healthy\ndepends_on"| S2APP
        S2DB -.->|"healthcheck:service_healthy\ndepends_on"| S2ADMIN

        %% Persistence wiring
        S2DB ---|"mounts"| VDB
        S2APP ---|"mounts(ifconfigured)"| VAPP
        S2ADMIN ---|"mounts(ifconfigured)"| VADM

        %% Compose ties (declarative)
        COMPOSE -->|"includes/merges"| S2APP
        COMPOSE -->|"includes/merges"| S2DB
        COMPOSE -->|"includes/merges"| S2ADMIN
    end

    %% =========================
    %% Diagram 3 — Configuration & Secrets Flow
    %% =========================
    subgraph "Diagram 3: Configuration & Secrets Flow (.env-driven)"
        ENVEX[".env.example\n(template/contract)"]:::doc
        ENV[".env\n(runtimeenvironment)"]:::doc

        ENVEX -->|"copiedto"| ENV

        ENV -->|"POSTGRES_USER/PASSWORD/DB\n(andrelated)"| S2DB
        ENV -->|"DATABASE_* + appkeys\n(connects to s2db by svcname)"| S2APP
        ENV -->|"PGADMIN_DEFAULT_EMAIL/PASSWORD\n(andrelated)"| S2ADMIN
    end

    %% =========================
    %% Click Events (from component_mapping)
    %% =========================
    click COMPOSE "https://github.com/pichyynews/nuggetgroup/blob/main/docker-compose.yaml"
    click S2APP "https://github.com/pichyynews/nuggetgroup/blob/main/app.yaml"
    click S2DB "https://github.com/pichyynews/nuggetgroup/blob/main/db.yaml"
    click S2ADMIN "https://github.com/pichyynews/nuggetgroup/blob/main/admin.yaml"
    click ENVEX "https://github.com/pichyynews/nuggetgroup/blob/main/.env.example"

    %% Represent documentation as a node for click
    README["README\n(ports,servicenames,healthchecknotes)"]:::doc
    click README "https://github.com/pichyynews/nuggetgroup/blob/main/README.md"
    README -->|"documents"| COMPOSE

    %% =========================
    %% Styles
    %% =========================
    classDef actor fill:#ffffff,stroke:#1f2937,stroke-width:1px,color:#111827
    classDef boundary fill:#f3f4f6,stroke:#6b7280,stroke-width:1px,color:#111827
    classDef ingress fill:#e0f2fe,stroke:#0284c7,stroke-width:1px,color:#0c4a6e
    classDef compose fill:#ede9fe,stroke:#6d28d9,stroke-width:1px,color:#2e1065
    classDef container fill:#dbeafe,stroke:#2563eb,stroke-width:1px,color:#1e3a8a
    classDef db fill:#fff7ed,stroke:#ea580c,stroke-width:1px,color:#7c2d12
    classDef volume fill:#ecfccb,stroke:#65a30d,stroke-width:1px,color:#365314
    classDef doc fill:#fefce8,stroke:#ca8a04,stroke-width:1px,color:#713f12

    %% Link styles: runtime traffic green, dependency orange dashed, others neutral
    linkStyle 0 stroke:#16a34a,stroke-width:2px
    linkStyle 1 stroke:#16a34a,stroke-width:2px
    linkStyle 2 stroke:#64748b,stroke-width:1px
    linkStyle 3 stroke:#64748b,stroke-width:1px

    linkStyle 4 stroke:#16a34a,stroke-width:2px
    linkStyle 5 stroke:#16a34a,stroke-width:2px

    linkStyle 6 stroke:#f59e0b,stroke-width:2px,stroke-dasharray:6 4
    linkStyle 7 stroke:#f59e0b,stroke-width:2px,stroke-dasharray:6 4

    linkStyle 8 stroke:#65a30d,stroke-width:1.5px
    linkStyle 9 stroke:#65a30d,stroke-width:1.5px
    linkStyle 10 stroke:#65a30d,stroke-width:1.5px

    linkStyle 11 stroke:#6d28d9,stroke-width:1.5px
    linkStyle 12 stroke:#6d28d9,stroke-width:1.5px
    linkStyle 13 stroke:#6d28d9,stroke-width:1.5px

    linkStyle 14 stroke:#ca8a04,stroke-width:1.5px
    linkStyle 15 stroke:#ca8a04,stroke-width:1.5px
    linkStyle 16 stroke:#ca8a04,stroke-width:1.5px
    linkStyle 17 stroke:#ca8a04,stroke-width:1.5px
    linkStyle 18 stroke:#ca8a04,stroke-width:1.5px
```
