# pr1nceps2002/wwcd architecture

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

- Interactive diagram: https://gitdiagram.com/pr1nceps2002/wwcd
- Repository: https://github.com/pr1nceps2002/wwcd

## Overview

##### Project type and purpose
- This is a full-stack web application (“Winner Winner Chicken Dinner”) that lets up to four users upload photos, computes an “excitement score” via facial-emotion AI, picks the top two, and generates shareable winner cards.
- Frontend: Next.js/React
- Backend: FastAPI + Python image/AI libraries

##### File-tree analysis
- Top-level:
- docker-compose.yml, build.sh → multi-container orchestration
- src/frontend → Next.js app (app directory, components, public, lib, configs)
- src/backend → FastAPI service (main.py, utils, templates, static, Dockerfile)
- Patterns: clear separation of UI (frontend) vs. business logic/image-processing (backend). No database—static file storage only.

##### README insights
- Frontend handles UI, image upload, and rendering results.
- Next.js API route under src/frontend/app/predict-winners/route.ts acts as a proxy or direct call to backend.
- Backend uses DeepFace for emotion recognition, rembg/Pillow/OpenCV for background removal and card compositing.
- Generated cards are placed under backend/static/generated_cards and served back.

## Diagram (Mermaid)

```mermaid
flowchart TB
    Client["Client (Browser/Mobile)"]:::ui

    subgraph "Frontend (Next.js)"
        FrontendContainer[/"Next.js Frontend"/]:::ui
        UIPages["UI Pages"]:::ui
        Components["UI Components"]:::ui
        API["Next.js API Route"]:::api
    end

    subgraph "Backend (FastAPI)"
        FastAPI["FastAPI Service"]:::api
        Endpoint["ImageReceiver Endpoint"]:::api
        subgraph "Processing Modules"
            Emotion["EmotionRecognition Service"]:::processing
            Background["BackgroundRemoval Service"]:::processing
            Compositor["CardCompositor Service"]:::processing
        end
        StaticServer["Static File Server"]:::infra
    end

    subgraph "Infrastructure"
        Volume[(Shared Storage Volume)]:::infra
        Compose["Docker Compose Orchestrator"]:::infra
    end

    Client -->|HTTP GET/POST| UIPages
    UIPages -->|renders & interactions| Components
    Components -->|user triggers upload| API
    API -->|HTTP POST multipart/form-data| Endpoint
    Endpoint -->|invoke| Emotion
    Endpoint -->|invoke| Background
    Endpoint -->|invoke| Compositor
    Compositor -->|write cards| Volume
    Volume -->|serves files| StaticServer
    StaticServer -->|static URLs| API
    API -->|return JSON with URLs| Components
    Components -->|renders cards| Client

    click FrontendContainer "https://github.com/pr1nceps2002/wwcd/tree/main/src/frontend"
    click UIPages "https://github.com/pr1nceps2002/wwcd/tree/main/src/frontend/app"
    click Components "https://github.com/pr1nceps2002/wwcd/tree/main/src/frontend/components"
    click API "https://github.com/pr1nceps2002/wwcd/blob/main/src/frontend/app/predict-winners/route.ts"
    click FastAPI "https://github.com/pr1nceps2002/wwcd/blob/main/src/backend/main.py"
    click Endpoint "https://github.com/pr1nceps2002/wwcd/blob/main/src/backend/main.py"
    click Emotion "https://github.com/pr1nceps2002/wwcd/blob/main/src/backend/main_utils.py"
    click Background "https://github.com/pr1nceps2002/wwcd/blob/main/src/backend/main_utils.py"
    click Compositor "https://github.com/pr1nceps2002/wwcd/blob/main/src/backend/main_utils.py"
    click StaticServer "https://github.com/pr1nceps2002/wwcd/tree/main/src/backend/static/generated_cards"
    click Compose "https://github.com/pr1nceps2002/wwcd/blob/main/docker-compose.yml"
    click Compose "https://github.com/pr1nceps2002/wwcd/blob/main/build.sh"

    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef api fill:#E0FFD8,stroke:#28a745,color:#28a745;
    classDef processing fill:#FFF9C4,stroke:#f9a825,color:#f9a825;
    classDef infra fill:#E0E0E0,stroke:#6a737d,color:#6a737d;
```
