# ilay1678/i-tools architecture

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

- Interactive diagram: https://gitdiagram.com/ilay1678/i-tools
- Repository: https://github.com/ilay1678/i-tools

## Overview

##### Project type and purpose
- This is a full-stack, serverless web application built with Next.js (App Router) that bundles multiple lightweight tools (TV-auth token generator, car-move QR code, JSON formatter, generic QR code generator).
- The README confirms its purpose as an “i-tools” toolbox for end users, deployed via Vercel or Cloudflare Pages/Workers, or run in a Docker container.

##### File structure
- Top-level build & deployment files (.cnb*, Dockerfile, wrangler.json, GitHub Actions workflows) point to container/Cloudflare Workers deployment.
- next.config.js, open-next.config.ts and tsconfig.json indicate Next.js with TypeScript.
- The `app/` directory uses Next.js App Router:
- `app/page.tsx`, `app/layout.tsx` – global layout and entry pages.
- `app/components/` – shared React components (AntdProvider, Loading).
- `app/api/` – server-side API routes (e.g. `/api/alipan-tv-token/*`, `/api/oauth/alipan/token/route.ts`).
- Feature‐specific subfolders (alipan-tv-token, move-car, qrcode, json-formatter) each have a `page.tsx` for the UI and API endpoints for dynamic logic.
- `public/` hosts static assets (robots.txt).
- No traditional database—state is ephemeral or relies on external OAuth provider.

##### README for additional insights
- Five tools are listed, each one corresponds to a UI page under `app/` and supporting API routes.
- Deployment targets (Vercel, Cloudflare Workers, Docker) indicate serverless functions or containerized Node environments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client and CDN
    Browser["Browser (User)"]:::client
    CDN["CDN/Edge Network"]:::cdn

    %% Next.js Application Containers
    subgraph "Next.js Application"
        subgraph "UI Layer"
            Layout["Global Layout\napp/layout.tsx"]:::ui
            EntryPage["Home Page\napp/page.tsx"]:::ui
            TVUI["TV Auth UI\napp/alipan-tv-token/page.tsx"]:::ui
            CarUI["Car-Move UI\napp/move-car"]:::ui
            JSONUI["JSON Formatter UI\napp/json-formatter/page.tsx"]:::ui
            QRUI["QR Code UI\napp/qrcode/page.tsx"]:::ui
            SharedComp["Shared Components\nAntdProvider.tsx\nLoading.tsx"]:::ui
            Styles["Global Styles\napp/globals.css"]:::config
        end

        subgraph "API Layer"
            TVGen["Generate QR API\napp/api/alipan-tv-token/generate_qr/route.ts"]:::api
            TVStatus["Check Status API\napp/api/alipan-tv-token/check_status/[sid]/route.ts"]:::api
            OAuthHandler["OAuth Token Handler\napp/api/oauth/alipan/token/route.ts"]:::api
            QRAPI["QR Code Generator API"]:::api
            JSONAPI["JSON Formatter API"]:::api
        end

        subgraph "Utilities"
            DecodeUtil["decode.ts\napp/utils/decode.ts"]:::util
        end
    end

    %% External Service
    ExternalOAuth["External OAuth Service"]:::external

    %% Deployment & Build
    subgraph "Deployment & Build"
        Configs["Next.js & OpenNext Configs\nnext.config.js\nopen-next.config.ts\ntsconfig.json\nnext-env.d.ts"]:::config
        BuildFiles["Docker & CNB Configs\nDockerfile\n.cnb.yml\n.web_trigger.yml\nwrangler.json"]:::infra
        Workflows["GitHub Actions\nclean-up.yml\ndocker-build.yml\nsync-to-cnb.yml"]:::infra
    end

    %% Connections
    Browser -->|"HTTP Request"| CDN
    CDN -->|"Serves Static & Edge Functions"| Layout
    CDN --> EntryPage
    Layout --> TVUI
    Layout --> CarUI
    Layout --> JSONUI
    Layout --> QRUI

    TVUI -->|"calls"| TVGen
    TVUI --> TVStatus
    TVUI --> OAuthHandler
    CarUI -->|"calls"| QRAPI
    JSONUI -->|"calls"| JSONAPI
    QRUI -->|"calls"| QRAPI

    TVGen -->|"uses OAuth"| ExternalOAuth
    OAuthHandler --> ExternalOAuth
    QRAPI --> DecodeUtil
    JSONAPI --> DecodeUtil

    Configs -->|"Configure"| BuildFiles
    Workflows --> BuildFiles
    BuildFiles -->|"Deploy to"| CDN

    %% Click Events
    click Layout "https://github.com/ilay1678/i-tools/blob/main/app/layout.tsx"
    click EntryPage "https://github.com/ilay1678/i-tools/blob/main/app/page.tsx"
    click TVUI "https://github.com/ilay1678/i-tools/blob/main/app/alipan-tv-token/page.tsx"
    click CarUI "https://github.com/ilay1678/i-tools/tree/main/app/move-car"
    click JSONUI "https://github.com/ilay1678/i-tools/blob/main/app/json-formatter/page.tsx"
    click QRUI "https://github.com/ilay1678/i-tools/blob/main/app/qrcode/page.tsx"
    click SharedComp "https://github.com/ilay1678/i-tools/tree/main/app/components"
    click Styles "https://github.com/ilay1678/i-tools/blob/main/app/globals.css"
    click TVGen "https://github.com/ilay1678/i-tools/blob/main/app/api/alipan-tv-token/generate_qr/route.ts"
    click TVStatus "https://github.com/ilay1678/i-tools/blob/main/app/api/alipan-tv-token/check_status/[sid]/route.ts"
    click OAuthHandler "https://github.com/ilay1678/i-tools/blob/main/app/api/oauth/alipan/token/route.ts"
    click DecodeUtil "https://github.com/ilay1678/i-tools/blob/main/app/utils/decode.ts"
    click Configs "https://github.com/ilay1678/i-tools/blob/main/next.config.js"
    click BuildFiles "https://github.com/ilay1678/i-tools/tree/main/Dockerfile"
    click Workflows "https://github.com/ilay1678/i-tools/blob/main/.github/workflows/docker-build.yml"

    %% Styles
    classDef client fill:#a2d2ff,stroke:#0366d6,color:#000
    classDef cdn fill:#bde0fe,stroke:#0077b6,color:#000
    classDef ui fill:#caf0f8,stroke:#0096c7,color:#000
    classDef api fill:#d8f3dc,stroke:#2d6a4f,color:#000
    classDef util fill:#f1faee,stroke:#1d3557,color:#000
    classDef external fill:#ffe8d6,stroke:#e63946,color:#000
    classDef config fill:#e9ecef,stroke:#495057,color:#000
    classDef infra fill:#f8edeb,stroke:#6d6875,color:#000
```
