# sslithercode/laundryprogress architecture

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

- Interactive diagram: https://gitdiagram.com/sslithercode/laundryprogress
- Repository: https://github.com/sslithercode/laundryprogress

## Overview

##### Project type and purpose
- Project Type: Full-stack, serverless web application with an AI/ML integration.
- Purpose: Allow users to capture images of laundry machines, detect machine availability via an AI vision model, and display live status updates.

##### File structure
- app/ – Next.js “app router” frontend pages and API route endpoints (route.ts, route.tsx).
- components/ui/ – Reusable UI components (button, dropdown, navbar, webcam_stream, etc.).
- lib/utils.ts – Shared helper functions.
- Configuration files – next.config.mjs, tailwind.config.ts, tsconfig.json, postcss.config.mjs, .eslintrc.json.
- package.json – Defines React/Next.js, Tailwind, and any API-client dependencies.

##### README for additional insights
- Backend: A separate FastAPI Python service (laundry_api) providing machine data and AI processing with llama3-11b-vision.
- Database: Supabase for storing machine statuses or user data.
- Deployment: Frontend and API routes hosted on Vercel; Python FastAPI hosted separately (own deployment or localhost).
- External integrations: WASH_API_URL endpoints for fetching/pushing machine data.

##### Main components
a. Users (Web browser with webcam)
b. Next.js Frontend (React components under app/ and components/ui/)
c. Next.js API Routes (app/api/*) hosted as Vercel Serverless Functions
d. External FastAPI Service (laundry_api)
e. AI Model (llama3-11b-vision via Groq)
f. Supabase Database
g. Optional External Laundry Management API (WASH_API_URL)

##### Relationships and data flow
1. User opens browser → loads Next.js frontend (layout.tsx, page.tsx).
2. User triggers WebcamStream component → captures frame(s).
3. Frontend calls Next.js API route (get_machines, change_machine_status, update_machine_status).
4. API route forwards request to FastAPI service or directly calls external laundry API (process.env.WASH_API_URL).
5. FastAPI service invokes llama3-11b-vision to process the image → returns machine availability predictions.
6. FastAPI writes or reads from Supabase to persist status.
7. API route returns JSON response to frontend.
8. Frontend updates UI components (table, badges, progress) in real time.

##### Architectural patterns and design principles
- Serverless functions pattern for API endpoints (Next.js app/api folder = micro-endpoints).
- Component-based UI architecture (React + Tailwind CSS).
- Clear separation of concerns: UI vs. API vs. data vs. AI processing.
- Externalization of heavy ML workloads to a specialized service.
- Stateless frontend; all persistent state lives in Supabase or external APIs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        User["User Browser\n(Webcam)"]:::user
        Layout["Root Layout\n(app/layout.tsx)"]:::frontend
        Home["Home Page\n(app/page.tsx)"]:::frontend
        ChangeBasic["Basic Status Change\n(app/change_status_basic/page.tsx)"]:::frontend
        UpdateStatus["Update Status\n(app/update_status/page.tsx)"]:::frontend
        subgraph "UI Components"
            direction TB
            WebcamStream["WebcamStream\n(utils/webcam_stream.tsx)"]:::ui
            Table["Table\n(components/ui/table.tsx)"]:::ui
            Badge["Badge\n(components/ui/badge.tsx)"]:::ui
            Progress["Progress\n(components/ui/progress.tsx)"]:::ui
            Button["Button\n(components/ui/button.tsx)"]:::ui
            Dropdown["Dropdown\n(components/ui/dropdown.tsx)"]:::ui
            Navbar["Navbar\n(components/ui/navbar.tsx)"]:::ui
            Select["Select\n(components/ui/select.tsx)"]:::ui
        end
        Utils["Shared Utils\n(lib/utils.ts)"]:::utils
    end

    %% API Layer
    subgraph "API Layer\n(Vercel Serverless Functions)"
        direction TB
        GetMachines["GET /api/get_machines\n(route.ts)"]:::api
        ChangeMachineStatus["POST /api/change_machine_status\n(route.ts)"]:::api
        UpdateMachineStatus["POST /api/update_machine_status\n(route.tsx)"]:::api
    end

    %% AI Processing Layer
    subgraph "AI Processing Layer\n(FastAPI Service)"
        direction TB
        FastAPI["FastAPI Service\n(laundry_api)"]:::service
        AIModel["llama3-11b-vision\n(Groq)"]:::ai
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Supabase["Supabase DB"]:::db
        ExternalAPI["External Laundry API\n(WASH_API_URL)"]:::external
    end

    %% Relationships
    User -->|loads| Layout
    Layout --> Home
    Layout --> ChangeBasic
    Layout --> UpdateStatus
    Home --> WebcamStream
    ChangeBasic --> Button
    UpdateStatus --> Table
    WebcamStream -->|capture frame| GetMachines
    Button -->|calls| ChangeMachineStatus
    Table -->|refresh| UpdateMachineStatus

    GetMachines -->|forwards| FastAPI
    ChangeMachineStatus -->|forwards| FastAPI
    UpdateMachineStatus -->|forwards| FastAPI

    FastAPI -->|invoke| AIModel
    FastAPI -->|read/write| Supabase
    FastAPI -->|optional call| ExternalAPI

    FastAPI -->|JSON response| GetMachines
    FastAPI -->|JSON response| ChangeMachineStatus
    FastAPI -->|JSON response| UpdateMachineStatus

    GetMachines -->|return data| Home
    ChangeMachineStatus -->|return status| ChangeBasic
    UpdateMachineStatus -->|return status| UpdateStatus

    %% Click Events
    click Layout "https://github.com/sslithercode/laundryprogress/blob/main/app/layout.tsx"
    click Home "https://github.com/sslithercode/laundryprogress/blob/main/app/page.tsx"
    click ChangeBasic "https://github.com/sslithercode/laundryprogress/blob/main/app/change_status_basic/page.tsx"
    click UpdateStatus "https://github.com/sslithercode/laundryprogress/blob/main/app/update_status/page.tsx"
    click WebcamStream "https://github.com/sslithercode/laundryprogress/blob/main/components/ui/utils/webcam_stream.tsx"
    click Table "https://github.com/sslithercode/laundryprogress/blob/main/components/ui/table.tsx"
    click Badge "https://github.com/sslithercode/laundryprogress/blob/main/components/ui/badge.tsx"
    click Progress "https://github.com/sslithercode/laundryprogress/blob/main/components/ui/progress.tsx"
    click Button "https://github.com/sslithercode/laundryprogress/blob/main/components/ui/button.tsx"
    click Dropdown "https://github.com/sslithercode/laundryprogress/blob/main/components/ui/dropdown.tsx"
    click Navbar "https://github.com/sslithercode/laundryprogress/blob/main/components/ui/navbar.tsx"
    click Select "https://github.com/sslithercode/laundryprogress/blob/main/components/ui/select.tsx"
    click Utils "https://github.com/sslithercode/laundryprogress/blob/main/lib/utils.ts"
    click GetMachines "https://github.com/sslithercode/laundryprogress/blob/main/app/api/get_machines/route.ts"
    click ChangeMachineStatus "https://github.com/sslithercode/laundryprogress/blob/main/app/api/change_machine_status/route.ts"
    click UpdateMachineStatus "https://github.com/sslithercode/laundryprogress/blob/main/app/api/update_machine_status/route.tsx"

    %% Styles
    classDef user fill:#EFF8FF,stroke:#2B6CB0,color:#2B6CB0
    classDef frontend fill:#D0E6FF,stroke:#3182CE
    classDef ui fill:#BEE3F8,stroke:#3182CE
    classDef utils fill:#E2E8F0,stroke:#4A5568
    classDef api fill:#D1FFD6,stroke:#38A169
    classDef service fill:#FFF5E6,stroke:#DD6B20
    classDef ai fill:#FFE5B4,stroke:#DD6B20
    classDef db fill:#E0BBE4,stroke:#805AD5
    classDef external fill:#EAEAEA,stroke:#718096
```
