# liemqle/liemsniffers-fortune-cookies architecture

> Architecture diagram of the GitHub repository liemqle/liemsniffers-fortune-cookies, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/liemqle/liemsniffers-fortune-cookies
- Repository: https://github.com/liemqle/liemsniffers-fortune-cookies

## Overview

##### Project type and purpose
- This is a small full-stack Go application (“Simple Fortune Cookie”) consisting of two Go services:
- frontend: serves HTML pages and JavaScript
- backend: provides a REST-style API delivering fortune cookie messages
- It’s designed for labs or workshops (applies containerization, CI/CD, orchestration).

##### File structure
Top-level:
- .github/workflows: GitHub Actions definitions (branch testing, main build/deploy).
- cicd: custom availabilityTest.sh script.
- deployments: Kubernetes YAML for backend, frontend, redis.
- docker-compose.yml: local multi-container orchestration (frontend, backend, redis).
- backend/: Go module for API server (main.go, util.go, foredis.go).
- frontend/: Go module for webserver (templates, static assets, util.go, tests).
Documentation:
- Step-by-step .md files for introduction, running, automation, containerization, CD, DB, testing.

##### README for additional insights
- README summarizes project purpose and structure.

##### Detailed elements
- Volumes or configMaps if added later

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CI/CD Tier
    subgraph "CI/CD Tier"
        GitHub["GitHub Repository"]:::external
        Workflows["GitHub Actions Workflows"]:::cicd
        Availability["Availability Test Script"]:::cicd
        GitHub -->|push code| Workflows
        Workflows -->|run tests| Availability
        Workflows -->|build & push images| Registry
    end

    %% Container Registry
    subgraph "Container Registry"
        Registry["Docker Container Registry"]:::registry
    end
    Workflows -->|push images| Registry
    Registry -->|images| Cluster

    %% Kubernetes Cluster
    subgraph "Kubernetes Cluster"
        User["User Browser"]:::external
        Ingress["Ingress/LoadBalancer"]:::cluster
        User -->|HTTP| Ingress

        subgraph "Services"
            Frontend["Frontend Service (Go)"]:::service
            Backend["Backend Service (Go)"]:::service
            Redis[(Redis Data Store)]:::datastore
        end
        Ingress -->|HTTP| Frontend
        Frontend -->|HTTP/REST| Backend
        Backend -->|TCP| Redis

        subgraph "Manifests"
            FEManifest["frontend.yml"]:::manifest
            BEManifest["backend.yml"]:::manifest
            RedisManifest["redis.yml"]:::manifest
        end
        FEManifest --> Frontend
        BEManifest --> Backend
        RedisManifest --> Redis
    end

    %% Local Development
    subgraph "Local Development (docker-compose)"  
        Compose["docker-compose.yml"]:::local
    end
    Compose -.-> Frontend
    Compose -.-> Backend
    Compose -.-> Redis

    %% Click Events
    click Frontend "https://github.com/liemqle/liemsniffers-fortune-cookies/tree/main/frontend/"
    click Backend "https://github.com/liemqle/liemsniffers-fortune-cookies/tree/main/backend/"
    click RedisManifest "https://github.com/liemqle/liemsniffers-fortune-cookies/blob/main/deployments/redis.yml"
    click BEManifest "https://github.com/liemqle/liemsniffers-fortune-cookies/blob/main/deployments/backend.yml"
    click FEManifest "https://github.com/liemqle/liemsniffers-fortune-cookies/blob/main/deployments/frontend.yml"
    click Compose "https://github.com/liemqle/liemsniffers-fortune-cookies/blob/main/docker-compose.yml"
    click Workflows "https://github.com/liemqle/liemsniffers-fortune-cookies/tree/main/.github/workflows/"
    click Availability "https://github.com/liemqle/liemsniffers-fortune-cookies/blob/main/cicd/availabilityTest.sh"

    %% Styles
    classDef cicd fill:#cce5ff,stroke:#339;
    classDef registry fill:#ffe5b4,stroke:#e68a00;
    classDef cluster fill:#d4edda,stroke:#228B22;
    classDef service fill:#b3ffb3,stroke:#2e8b57;
    classDef datastore fill:#cce5cc,stroke:#2e8b57;
    classDef manifest fill:#f0f0f0,stroke:#888;
    classDef external fill:#f2f2f2,stroke:#666;
    classDef local fill:#fff2cc,stroke:#cc9900;
```
