# flutterchina/flutter_in_action_2nd architecture

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

- Interactive diagram: https://gitdiagram.com/flutterchina/flutter_in_action_2nd
- Repository: https://github.com/flutterchina/flutter_in_action_2nd

## Overview

##### Project type and purpose
- This is a static documentation/book website built with VuePress (Node.js-based static site generator).
- Purpose: render markdown chapters (src/*.md) into a bilingual Flutter tutorial site and e-book (docs/ directory) and deploy it (e.g., GitHub Pages).

##### File structure
- Top-level:
- `package.json` / `package-lock.json` – Node.js dependencies & scripts.
- `src/` – source markdown chapters, VuePress config (`.vuepress/`) and theme files.
- `docs/` – generated static output: HTML, CSS, JS assets.
- `app.js`, `doc.js`, `deploy.sh`, `doc.sh` – custom build/dev/server scripts.
- Patterns: Static Site Generation (SSG) with clear separation: content (markdown) → generator (VuePress + custom scripts) → output (docs).

##### README for additional insights
- Confirms it’s a Flutter book (“Flutter实战·第二版”), updated via markdown in `src/`, deployed online.
- Encourages weekly updates and uses GitHub issues for feedback.

##### Main components & their interactions
a. Components
- Content Layer: Markdown files (`src/**/*.md`)
- SSG Engine: VuePress (`src/.vuepress/`, themes, layouts)
- Build Scripts: `doc.js` (build logic), `doc.sh` (build wrapper), `app.js` (local dev server)
- Output Layer: Static site (`docs/` folder)
- Deployment: `deploy.sh` pushes `docs/` to hosting (e.g., GitHub Pages)
- External Services: GitHub (repo, issues), GitHub Pages (hosting)
b. Relationships / Data Flow
- Developer runs `npm run docs:build` (calls `doc.sh` → `doc.js`)
- VuePress processes `src/**/*.md` through theme/layouts → emits HTML+assets into `docs/`
- `deploy.sh` takes `docs/` and updates remote hosting branch
- End users load static assets via CDN/GitHub Pages
c. Architectural patterns / design principles
- Static Site Generation (SSG) – pre-rendering for performance & SEO
- Separation of concerns: content vs. presentation (theme) vs. config vs. build/deploy scripts
- Convention over configuration (VuePress folder layout)
d. Key technologies
- Node.js / npm
- VuePress (Vue.js, webpack under the hood)
- Markdown → HTML
- Shell scripts for orchestration
- GitHub Pages for hosting

## Diagram (Mermaid)

```mermaid
flowchart TD
    Dev["Developer"]:::external
    User["End User"]:::external

    subgraph "Content Layer"
        MS["Markdown Source\n(src/)"]:::code
    end

    subgraph "VuePress Engine"
        VPConfig["Config\n(.vuepress/config.js)"]:::code
        VPPublic["Public Assets\n(.vuepress/public/)"]:::code
        VPThemeDef["Theme Definitions\n(.vuepress/theme/)"]:::code
        VPLayout["Theme Layout\n(.vuepress/theme/layouts/Layout.vue)"]:::code
        ELayoutBook["Custom Ebook Layouts\n(src/_layouts/ebook/)"]:::code
        ELayoutWeb["Custom Website Layouts\n(src/_layouts/website/)"]:::code
    end

    Package["Project Config & Scripts\n(package.json)"]:::code
    BuildWrapper["Build Wrapper Script\n(doc.sh)"]:::code
    BuildLogic["Build Logic Script\n(doc.js)"]:::code
    DevServer["Dev Server\n(app.js)"]:::code
    StaticOut["Static Output\n(docs/)"]:::output
    Deploy["Deployment Script\n(deploy.sh)"]:::code
    Host["GitHub Pages / CDN"]:::external

    Dev -->|npm run docs:build| BuildWrapper
    BuildWrapper --> BuildLogic
    BuildLogic -->|processes markdown| MS
    BuildLogic --> VPConfig
    BuildLogic --> VPPublic
    BuildLogic --> VPThemeDef
    BuildLogic --> VPLayout
    BuildLogic --> ELayoutBook
    BuildLogic --> ELayoutWeb
    BuildLogic -->|generates| StaticOut
    StaticOut --> Deploy
    Deploy -->|git push| Host
    Host -->|serves static site| User

    Dev -->|npm run docs:dev| DevServer
    DevServer -->|serves locally| StaticOut

    MS -->|source from| Package
    BuildWrapper --> Package
    DevServer --> Package

    click MS "https://github.com/flutterchina/flutter_in_action_2nd/tree/main/src/"
    click VPConfig "https://github.com/flutterchina/flutter_in_action_2nd/blob/main/src/.vuepress/config.js"
    click VPPublic "https://github.com/flutterchina/flutter_in_action_2nd/tree/main/src/.vuepress/public/"
    click VPThemeDef "https://github.com/flutterchina/flutter_in_action_2nd/tree/main/src/.vuepress/theme/"
    click VPLayout "https://github.com/flutterchina/flutter_in_action_2nd/blob/main/src/.vuepress/theme/layouts/Layout.vue"
    click ELayoutBook "https://github.com/flutterchina/flutter_in_action_2nd/tree/main/src/_layouts/ebook/"
    click ELayoutWeb "https://github.com/flutterchina/flutter_in_action_2nd/tree/main/src/_layouts/website/"
    click BuildLogic "https://github.com/flutterchina/flutter_in_action_2nd/blob/main/doc.js"
    click BuildWrapper "https://github.com/flutterchina/flutter_in_action_2nd/blob/main/doc.sh"
    click DevServer "https://github.com/flutterchina/flutter_in_action_2nd/blob/main/app.js"
    click Deploy "https://github.com/flutterchina/flutter_in_action_2nd/blob/main/deploy.sh"
    click StaticOut "https://github.com/flutterchina/flutter_in_action_2nd/tree/main/docs/"
    click Package "https://github.com/flutterchina/flutter_in_action_2nd/blob/main/package.json"

    classDef code fill:#8FBCE6,stroke:#0366d6,color:#000
    classDef output fill:#A3E635,stroke:#6B7280,color:#000
    classDef external fill:#F6AD55,stroke:#DD6B20,color:#000
```
