# dai-shi/waku architecture

> Architecture diagram of the GitHub repository dai-shi/waku, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dai-shi/waku
- Repository: https://github.com/dai-shi/waku

## Overview

##### Main Components Overview

a) Core Framework Components:
- Build System
- Router System
- Rendering Engine
- Server Components Handler
- Client Components Handler
- State Management Integration

b) Development Components:
- Development Server
- Hot Reload System
- Static Asset Handler
- Environment Variables Manager

##### Detailed Architecture Layers

**┌─────────────────────────────────────────────┐**
- Application Layer              │
- ┤
- Pages Router  │  Static Assets │  Metadata  │
- ┤
- Server/Client Component Bridge       │
- ┤
- Server Components │      Client Components  │
- ┤
- Build & Deployment Pipeline System       │
- ┘

##### Key Interactions to Highlight

a) Routing Flow:
- File-based routing system (`/src/pages`)
- Dynamic route handling
- Layout system integration
- Navigation management

b) Rendering Pipeline:
- Server Component Processing
- Client Component Hydration
- Static/Dynamic Rendering Decisions
- SSG/SSR Pipeline

c) Data Flow:
- Server Actions
- State Management
- Environment Variables
- Static Asset Handling

##### Deployment Architecture

Multiple deployment targets:
- Vercel
- Netlify
- Cloudflare
- PartyKit
- Deno Deploy
- AWS Lambda

##### Component Relationships

Clear relationships between:
- Pages and Layouts
- Server and Client Components
- Static and Dynamic Rendering
- Build System and Deployment Targets

##### Technical Details

Annotations for:
- Node.js version requirements
- Framework compatibility
- Build optimization processes
- Development vs. Production flows

##### Implementation Notes

- CSS/Styling implementation
- State Management integration
- Server Actions implementation
- Metadata handling

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Application Layer"
        Pages["Pages Router"]:::router
        Assets["Static Assets"]:::static
        Meta["Metadata"]:::meta
    end

    subgraph "Component Bridge"
        Bridge["Server/Client Bridge"]:::bridge
    end

    subgraph "Component Layer"
        ServerComp["Server Components"]:::server
        ClientComp["Client Components"]:::client
    end

    subgraph "Core Framework"
        Build["Build System"]:::core
        Router["Router System"]:::core
        Render["Rendering Engine"]:::core
        ServerHandler["Server Components Handler"]:::core
        ClientHandler["Client Components Handler"]:::core
    end

    subgraph "Development Tools"
        DevServer["Development Server"]:::dev
        HotReload["Hot Reload System"]:::dev
        AssetHandler["Static Asset Handler"]:::dev
        EnvManager["Environment Variables Manager"]:::dev
    end

    subgraph "Deployment Targets"
        Vercel["Vercel"]:::deploy
        Netlify["Netlify"]:::deploy
        Cloudflare["Cloudflare"]:::deploy
        PartyKit["PartyKit"]:::deploy
        Deno["Deno Deploy"]:::deploy
        Lambda["AWS Lambda"]:::deploy
    end

    Pages --> Bridge
    Assets --> Bridge
    Meta --> Bridge
    Bridge --> ServerComp
    Bridge --> ClientComp
    ServerComp --> ServerHandler
    ClientComp --> ClientHandler
    ServerHandler --> Build
    ClientHandler --> Build
    Router --> Build
    Render --> Build
    Build --> Vercel
    Build --> Netlify
    Build --> Cloudflare
    Build --> PartyKit
    Build --> Deno
    Build --> Lambda
    DevServer --> HotReload
    DevServer --> AssetHandler
    DevServer --> EnvManager

    %% Click Events
    click Build "https://github.com/dai-shi/waku/blob/main/packages/waku/src/lib/builder/build.ts"
    click Router "https://github.com/dai-shi/waku/tree/main/packages/waku/src/router/"
    click Render "https://github.com/dai-shi/waku/tree/main/packages/waku/src/lib/renderers/"
    click ServerHandler "https://github.com/dai-shi/waku/blob/main/packages/waku/src/lib/plugins/vite-plugin-rsc-transform.ts"
    click ClientHandler "https://github.com/dai-shi/waku/blob/main/packages/waku/src/client.ts"
    click DevServer "https://github.com/dai-shi/waku/blob/main/packages/waku/src/lib/middleware/dev-server.ts"
    click HotReload "https://github.com/dai-shi/waku/blob/main/packages/waku/src/lib/plugins/vite-plugin-rsc-hmr.ts"
    click AssetHandler "https://github.com/dai-shi/waku/blob/main/packages/waku/src/lib/plugins/vite-plugin-nonjs-resolve.ts"
    click EnvManager "https://github.com/dai-shi/waku/blob/main/packages/waku/src/lib/plugins/vite-plugin-rsc-env.ts"

    %% Styles
    classDef router fill:#FFA500,stroke:#333,stroke-width:2px
    classDef static fill:#A0A0A0,stroke:#333,stroke-width:2px
    classDef meta fill:#FFD700,stroke:#333,stroke-width:2px
    classDef bridge fill:#9370DB,stroke:#333,stroke-width:2px
    classDef server fill:#4169E1,stroke:#333,stroke-width:2px
    classDef client fill:#32CD32,stroke:#333,stroke-width:2px
    classDef core fill:#483D8B,stroke:#333,stroke-width:2px,color:#fff
    classDef dev fill:#8B4513,stroke:#333,stroke-width:2px,color:#fff
    classDef deploy fill:#696969,stroke:#333,stroke-width:2px
```
