# teacat/tocas architecture

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

- Interactive diagram: https://gitdiagram.com/teacat/tocas
- Repository: https://github.com/teacat/tocas

## Overview

##### Project type and purpose
- Tocas UI is a front-end design system / component library (an open-source UI toolkit) that delivers modular CSS and JavaScript to build websites and progressive web apps quickly and intuitively.
- Evidence:
- Hundreds of individual *.css files (buttons, menus, modals, etc.) and a small JS set under `src/scripts/`.
- A `dist/` folder with compiled `tocas.css` and `tocas.js` for distribution.
- README describes usage via CDN or NPM.

##### File structure
Top-level:
- `src/` – source modules (one CSS file per component + `src/scripts/` for interactive behavior).
- `dist/` – build outputs: minified CSS and JS, plus assets (flags, fonts).
- `package.json` – metadata, build commands (if any), dependencies.
- `README.md` & `LICENSE`.
Patterns:
- Single‐repository, modular component approach
- Build pipeline (likely bundling & minification) produces a unified CSS and JS.

##### Insights from README
- Core deliverable: `tocas.min.css` and `tocas.min.js` via CDN/NPM.
- No backend or runtime server: purely front-end assets.

##### Main components of the system
A. Source Layer (developer view)
1. CSS Modules (e.g. `accordion.css`, `button.css`, …)
2. Script Modules (`src/scripts/tocas.*.js`)
3. Build/Tooling Config (e.g. `.prettierrc`, package.json scripts)
B. Build / Bundling Pipeline
- Transforms & merges all CSS modules → `dist/tocas.css`
- Transforms & bundles all JS modules → `dist/tocas.js`
- Copies assets (flags, fonts) into `dist/flags` and `dist/fonts`
C. Distribution Layer
1. NPM Package
2. CDN Artifacts (cdnjs links)
3. Documentation Site (tocas-ui.com)
D. Consumers
- Web applications import CSS/JS via `<link>` / `<script>` tags.
- Uses dependencies: Google Fonts (Noto Sans TC), optional Font Awesome, floating-ui.

##### Architectural patterns & design principles
- Modular component pattern (one file per UI element)
- Layered architecture (source → build → distribution → consumption)
- Dependency inclusion vs. peer dependencies (some assets are bundled, others loaded externally)

##### Important details to capture
- The per-component modular breakdown in `src/`
- The build step that aggregates everything into two core files
- The publishing targets (NPM, CDN) and their usage by client apps

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Source Layer
    subgraph "Source Layer"
        direction TB
        CSSModules["CSS Modules"]:::source
        ScriptModules["Script Modules"]:::source
        Config["Build/Tooling Config"]:::source
        Prettierrc[".prettierrc"]:::source
        SrcFlags["Source Assets – Flags"]:::source
        SrcFonts["Source Assets – Fonts/Icons"]:::source
        Docs["Documentation & Metadata"]:::source
    end

    %% Build Pipeline
    Pipeline["Build & Bundling Pipeline"]:::pipeline

    %% Distribution Layer
    subgraph "Distribution Layer"
        direction TB
        TocasCSS["dist/tocas.css"]:::dist
        TocasJS["dist/tocas.js"]:::dist
        DistFlags["Distributed Assets – Flags"]:::dist
        DistFonts["Distributed Assets – Fonts/Icons"]:::dist
        NPM["NPM Registry"]:::external
        CDN["CDN (cdnjs)"]:::external
        DocSite["Documentation Site"]:::external
    end

    %% Consumers
    Consumer["Consumer Web App"]:::consumer

    %% External Dependencies
    subgraph "External Dependencies"
        direction TB
        FA["Font Awesome"]:::external
        FloatingUI["floating-ui"]:::external
        FlagIcons["flag-icons"]:::external
    end

    %% Connections
    CSSModules -->|"bundles & compiles"| Pipeline
    ScriptModules -->|"bundles & compiles"| Pipeline
    Config -->|uses| Pipeline
    Prettierrc -->|formats| Pipeline
    SrcFlags -->|copies| Pipeline
    SrcFonts -->|copies| Pipeline
    Pipeline -->|"outputs"| TocasCSS
    Pipeline -->|"outputs"| TocasJS
    Pipeline -->|"outputs"| DistFlags
    Pipeline -->|"outputs"| DistFonts
    Pipeline -->|publishes| NPM
    Pipeline -->|publishes| CDN
    NPM -->|"downloads & applies"| Consumer
    CDN -->|"downloads & applies"| Consumer

    Pipeline -.->|"pulls"| FA
    Pipeline -.->|"pulls"| FloatingUI
    Pipeline -.->|"pulls"| FlagIcons

    Consumer -->|views docs| DocSite

    %% Click Events
    click CSSModules "https://github.com/teacat/tocas/tree/master/src/"
    click ScriptModules "https://github.com/teacat/tocas/tree/master/src/scripts/"
    click Config "https://github.com/teacat/tocas/blob/master/package.json"
    click Prettierrc "https://github.com/teacat/tocas/blob/master/src/scripts/.prettierrc"
    click SrcFlags "https://github.com/teacat/tocas/tree/master/src/flags/"
    click SrcFonts "https://github.com/teacat/tocas/tree/master/src/fonts/icons"
    click TocasCSS "https://github.com/teacat/tocas/blob/master/dist/tocas.css"
    click TocasJS "https://github.com/teacat/tocas/blob/master/dist/tocas.js"
    click DistFlags "https://github.com/teacat/tocas/tree/master/dist/flags/"
    click DistFonts "https://github.com/teacat/tocas/tree/master/dist/fonts/icons"
    click Docs "https://github.com/teacat/tocas/blob/master/README.md"

    %% Styles
    classDef source fill:#bbdefb,stroke:#1e88e5,color:#0d47a1,stroke-width:1px;
    classDef pipeline fill:#ffe0b2,stroke:#ef6c00,color:#e65100,stroke-width:1px;
    classDef dist fill:#c8e6c9,stroke:#388e3c,color:#1b5e20,stroke-width:1px;
    classDef external fill:#eceff1,stroke:#607d8b,color:#37474f,stroke-width:1px,stroke-dasharray: 5 5;
    classDef consumer fill:#e1bee7,stroke:#8e24aa,color:#4a148c,stroke-width:1px;
```
