# huuyafwww/trastocker architecture

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

- Interactive diagram: https://gitdiagram.com/huuyafwww/trastocker
- Repository: https://github.com/huuyafwww/trastocker

## Overview

##### Project type and purpose
- This is a full-stack monorepo (managed by TurboRepo & pnpm workspaces) implementing “Trastocker,” a home consumables stock-management system.
- It contains multiple runnable apps (backend, frontend, proxy, GitHub Pages) plus shared packages for database schemas, GraphQL schemas, validation schemas, and utility helpers.

##### File structure
- Top-level “apps” folder holds:
- app-backend-server: GraphQL API (Cloudflare Workers + D1)
- app-frontend-server: React/Next.js UI (Vite, Storybook, MSW mocks)
- app-proxy-server: a small Node/TS proxy layer to route or decorate API calls
- app-github-pages: static site (likely documentation or Storybook build)
- “definitions” folder holds:
- database-definition: Drizzle/SQL migrations, schema definitions
- graphql-definition: GraphQL codegen config
- validation-schema-definition: shared Zod or JSON-schema validators
- “helpers” folder holds reusable Node/TS utility libs (drizzle helper, sleep, etc.)
- Root contains CI/CD workflows, linting, Husky hooks, TurboRepo config.

##### README
- Confirms project purpose: stock management for home consumables.
- Requires Node ≥22, pnpm ≥9, and tbls (for DB docs).
- Instructs building shared libraries before running apps.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Monorepo" 
        subgraph "Configuration & CI/CD"
            PNPM["pnpm-workspace.yaml"]:::ci
            TURBO["turbo.json"]:::ci
            CIWF[".github/workflows/"]:::ci
        end

        subgraph "Shared Libraries"
            DBDEF["definitions/database-definition/"]:::libs
            DBMIG["definitions/database-definition/migrations/"]:::libs
            DBSCHEMA["definitions/database-definition/src/schema/"]:::libs
            DBCONFIG["definitions/database-definition/drizzle.config.ts"]:::libs

            GQLDEF["definitions/graphql-definition/"]:::libs
            GQLCODEGEN["definitions/graphql-definition/codegen.ts"]:::libs

            VALDEF["definitions/validation-schema-definition/"]:::libs
            VALSCHEMAS["definitions/validation-schema-definition/src/schemas/"]:::libs

            HDLZ["helpers/drizzle-helper/"]:::libs
            HNODE["helpers/nodejs-utility-helper/src/sleep.ts"]:::libs
            HTS["helpers/typescript-utility-helper/src/index.ts"]:::libs
        end

        subgraph "Applications"
            BACKEND["app-backend-server (CF Worker)"]:::app
            FRONTEND["app-frontend-server (Next.js UI)"]:::app
            PROXY["app-proxy-server (Node Proxy)"]:::app
            GH_PAGES["app-github-pages (Static Site)"]:::app
        end
    end

    subgraph "Infrastructure & External"
        D1["Cloudflare D1 (Database)"]:::infra
        CFWORKER["Cloudflare Workers"]:::infra
        GHPAGES["GitHub Pages"]:::infra
    end

    %% Dependencies
    DBDEF --> BACKEND
    DBSCHEMA --> BACKEND
    DBMIG --> BACKEND
    DBCONFIG --> BACKEND

    GQLDEF --> BACKEND
    GQLCODEGEN --> BACKEND

    VALDEF --> BACKEND
    VALSCHEMAS --> BACKEND

    HDLZ --> BACKEND
    HNODE --> BACKEND
    HTS --> BACKEND

    DBDEF --> FRONTEND
    GQLDEF --> FRONTEND
    VALDEF --> FRONTEND
    HDLZ --> FRONTEND

    FRONTEND -->|"GraphQL HTTP"| PROXY
    PROXY -->|"forwards requests"| BACKEND
    BACKEND -->|"SQL queries"| D1
    BACKEND -->|"deployed to"| CFWORKER
    GH_PAGES -->|"hosted on"| GHPAGES

    %% CI/CD flows
    CIWF -->|build & test| DBDEF
    CIWF -->|build & test| GQLDEF
    CIWF -->|build & test| VALDEF
    CIWF -->|build & test| HDLZ
    CIWF -->|deploy| BACKEND
    CIWF -->|deploy| FRONTEND
    CIWF -->|publish docs| GH_PAGES

    %% Click Events
    click PNPM "https://github.com/huuyafwww/trastocker/blob/develop/pnpm-workspace.yaml"
    click TURBO "https://github.com/huuyafwww/trastocker/blob/develop/turbo.json"
    click CIWF "https://github.com/huuyafwww/trastocker/tree/develop/.github/workflows/"

    click DBDEF "https://github.com/huuyafwww/trastocker/tree/develop/definitions/database-definition/"
    click DBMIG "https://github.com/huuyafwww/trastocker/tree/develop/definitions/database-definition/migrations/"
    click DBSCHEMA "https://github.com/huuyafwww/trastocker/tree/develop/definitions/database-definition/src/schema/"
    click DBCONFIG "https://github.com/huuyafwww/trastocker/blob/develop/definitions/database-definition/drizzle.config.ts"

    click GQLDEF "https://github.com/huuyafwww/trastocker/tree/develop/definitions/graphql-definition/"
    click GQLCODEGEN "https://github.com/huuyafwww/trastocker/blob/develop/definitions/graphql-definition/codegen.ts"

    click VALDEF "https://github.com/huuyafwww/trastocker/tree/develop/definitions/validation-schema-definition/"
    click VALSCHEMAS "https://github.com/huuyafwww/trastocker/tree/develop/definitions/validation-schema-definition/src/schemas/"

    click HDLZ "https://github.com/huuyafwww/trastocker/tree/develop/helpers/drizzle-helper/"
    click HNODE "https://github.com/huuyafwww/trastocker/blob/develop/helpers/nodejs-utility-helper/src/sleep.ts"
    click HTS "https://github.com/huuyafwww/trastocker/blob/develop/helpers/typescript-utility-helper/src/index.ts"

    click BACKEND "https://github.com/huuyafwww/trastocker/tree/develop/apps/app-backend-server/"
    click FRONTEND "https://github.com/huuyafwww/trastocker/tree/develop/apps/app-frontend-server/"
    click PROXY "https://github.com/huuyafwww/trastocker/tree/develop/apps/app-proxy-server/"
    click GH_PAGES "https://github.com/huuyafwww/trastocker/tree/develop/apps/app-github-pages/"

    click D1 "https://github.com/huuyafwww/trastocker/tree/develop/definitions/database-definition/migrations/"
    click CFWORKER "https://github.com/huuyafwww/trastocker/tree/develop/apps/app-backend-server/"
    click GHPAGES "https://github.com/huuyafwww/trastocker/tree/develop/apps/app-github-pages/"

    classDef app fill:#ADD8E6,stroke:#000;
    classDef libs fill:#90EE90,stroke:#000;
    classDef infra fill:#FFA500,stroke:#000;
    classDef ci fill:#DDA0DD,stroke:#000;
```
