# imoken777/sillahub architecture

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

- Interactive diagram: https://gitdiagram.com/imoken777/sillahub
- Repository: https://github.com/imoken777/sillahub

## Overview

##### Project type and purpose
- This is a full-stack Next.js 13 application bootstrapped with Cloudflare Pages (c3).
- Frontend: React/Next.js “app router” under src/app with server-side rendering and static asset delivery.
- Backend/API: Cloudflare Pages Functions (under src/app/api) exposing REST endpoints, including a cron-style public/cron parser pipeline.
- Persistence: Drizzle ORM managing relational schema and migrations. Potentially backed by a Cloudflare-hosted database or KV (example bindings present).
- DevOps: GitHub Actions for CI/deploy, Wrangler for preview/deploy to Cloudflare Pages.

##### File structure
- Top-level:
- next.config.mjs, tailwind.config.ts, postcss.config.mjs → framework and styling config
- drizzle.config.ts, src/drizzle → database ORM config & migration scripts
- wrangler.toml → Cloudflare Functions binding & deploy config
- .github/workflows → CI (ci.yml), CD (deploy.yml)
- src/app → Next.js “app router” layout.tsx, page.tsx, not-found.tsx, global CSS
- src/app/api/[...route] → catch-all Function endpoints: public/factory.ts, public/cron/* parser jobs, route.ts
- src/lib/db.ts → DB client initialization (Drizzle)
- src/components → UI components (layout, model, ui) consumed by pages
- src/constants, src/types, src/utils → shared types, constants, helpers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Browser
    Browser["Client Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        NextFE["Next.js Frontend\n(Next.js13 + Tailwind)"]:::frontend
        AppRouter["src/app"]:::frontend
        GlobalStyles["globals.css & public/"]:::frontend
        LayoutComponents["src/components"]:::frontend
    end

    %% API Layer
    subgraph "API Layer\n(Cloudflare Pages Functions)"
        direction TB
        APICatchAll["route.ts\n(Catch-all handler)"]:::api
        PublicFactory["public/factory.ts"]:::api
        CronGet["getAllSyllabus.ts"]:::api
        CronIndex["index.ts"]:::api
        CronParser["parser.ts"]:::api
    end

    %% Database Layer
    subgraph "Database Layer\n(Drizzle ORM)"
        direction TB
        DrizzleConfig["drizzle.config.ts"]:::db
        Migrations["src/drizzle/migrations\n*.sql & meta"]:::db
        SchemaDef["src/drizzle/schema.ts"]:::db
        DBClient["src/lib/db.ts"]:::db
        DrizzleDB["Drizzle DB\n(Cylinder)"]:::db
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        direction TB
        Types["src/types"]:::shared
        Constants["src/constants"]:::shared
        Utils["src/utils"]:::shared
    end

    %% Configurations
    subgraph "Configuration Files"
        direction TB
        NextConfig["next.config.mjs"]:::config
        TailwindConfig["tailwind.config.ts"]:::config
        PostCSSConfig["postcss.config.mjs"]:::config
        WranglerConfig["wrangler.toml"]:::config
    end

    %% DevOps & Deployment
    subgraph "DevOps & Deployment"
        direction TB
        GitHub["GitHub Repo"]:::ci
        CIAction[".github/workflows/ci.yml"]:::ci
        CDAction[".github/workflows/deploy.yml"]:::ci
        CloudflarePages["Cloudflare Pages"]:::infra
    end

    %% External Data
    ExternalData["External Data Source\n(Cron Targets)"]:::external

    %% Relationships
    Browser -->|"HTTP GET/SSR"| NextFE
    NextFE -->|"fetch assets"| GlobalStyles
    NextFE -->|"uses components"| LayoutComponents
    NextFE -->|"API requests"| APICatchAll
    APICatchAll -->|"routes to"| PublicFactory
    APICatchAll -->|"routes to"| CronGet
    APICatchAll -->|"routes to"| CronIndex
    APICatchAll -->|"routes to"| CronParser
    PublicFactory -->|"DB query"| DBClient
    CronGet -->|"DB query"| DBClient
    CronIndex -->|"DB query"| DBClient
    CronParser -->|"fetch"| ExternalData
    CronParser -->|"DB write"| DBClient
    DBClient -->|"executes migrations & queries"| DrizzleDB
    DrizzleConfig --> DrizzleDB
    Migrations --> DrizzleDB
    SchemaDef --> DrizzleDB
    Types --> NextFE
    Types --> APICatchAll
    Constants --> NextFE
    Constants --> APICatchAll
    Utils --> NextFE
    Utils --> APICatchAll
    NextConfig --> NextFE
    TailwindConfig --> NextFE
    PostCSSConfig --> NextFE
    WranglerConfig --> APICatchAll
    GitHub --> CIAction
    CIAction -->|"build & test"| CloudflarePages
    CIAction --> CDAction
    CDAction -->|"deploy via Wrangler"| CloudflarePages

    %% Click Events
    click AppRouter "https://github.com/imoken777/sillahub/tree/main/src/app"
    click GlobalStyles "https://github.com/imoken777/sillahub/blob/main/src/app/globals.css"
    click GlobalStyles "https://github.com/imoken777/sillahub/tree/main/public/"
    click LayoutComponents "https://github.com/imoken777/sillahub/tree/main/src/components"
    click APICatchAll "https://github.com/imoken777/sillahub/blob/main/src/app/api/[...route]/route.ts"
    click PublicFactory "https://github.com/imoken777/sillahub/blob/main/src/app/api/[...route]/public/factory.ts"
    click CronGet "https://github.com/imoken777/sillahub/blob/main/src/app/api/[...route]/public/cron/getAllSyllabus.ts"
    click CronIndex "https://github.com/imoken777/sillahub/blob/main/src/app/api/[...route]/public/cron/index.ts"
    click CronParser "https://github.com/imoken777/sillahub/blob/main/src/app/api/[...route]/public/cron/parser.ts"
    click DrizzleConfig "https://github.com/imoken777/sillahub/blob/main/drizzle.config.ts"
    click Migrations "https://github.com/imoken777/sillahub/tree/main/src/drizzle/migrations"
    click SchemaDef "https://github.com/imoken777/sillahub/blob/main/src/drizzle/schema.ts"
    click DBClient "https://github.com/imoken777/sillahub/blob/main/src/lib/db.ts"
    click Types "https://github.com/imoken777/sillahub/tree/main/src/types"
    click Constants "https://github.com/imoken777/sillahub/tree/main/src/constants"
    click Utils "https://github.com/imoken777/sillahub/tree/main/src/utils"
    click NextConfig "https://github.com/imoken777/sillahub/blob/main/next.config.mjs"
    click TailwindConfig "https://github.com/imoken777/sillahub/blob/main/tailwind.config.ts"
    click PostCSSConfig "https://github.com/imoken777/sillahub/blob/main/postcss.config.mjs"
    click WranglerConfig "https://github.com/imoken777/sillahub/blob/main/wrangler.toml"
    click CIAction "https://github.com/imoken777/sillahub/blob/main/.github/workflows/ci.yml"
    click CDAction "https://github.com/imoken777/sillahub/blob/main/.github/workflows/deploy.yml"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#025DA8,stroke-width:2px
    classDef api fill:#E0F7FA,stroke:#00796B,stroke-width:2px
    classDef db fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px
    classDef shared fill:#F3E5F5,stroke:#6A1B9A,stroke-width:2px
    classDef config fill:#FFF3E0,stroke:#EF6C00,stroke-width:2px
    classDef ci fill:#FFF8E1,stroke:#FF8F00,stroke-width:2px
    classDef infra fill:#ECEFF1,stroke:#546E7A,stroke-width:2px
    classDef external fill:#F5F5F5,stroke:#BDBDBD,stroke-width:2px
```
