# aizen2510/btl_web_n8 architecture

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

- Interactive diagram: https://gitdiagram.com/aizen2510/btl_web_n8
- Repository: https://github.com/aizen2510/btl_web_n8

## Overview

##### Project type and purpose
- This is a front-end Single-Page Application (SPA) built with React 17, UmiJS and Ant Design v4, written in TypeScript.
- It serves as the V3 “Web Base” UI, integrating with a NestJS/PostgreSQL back end via REST/JSON and using Keycloak for SSO.

##### Main components
a. Client (Browser)
- SPA bundle (JavaScript/CSS/assets) delivered by UmiJS/Webpack
- service-worker for offline support
b. Static Host / CDN / Runtime Container
- Vercel (or Docker + Nginx) serving the compiled SPA
c. Authentication Service
- Keycloak (external OAuth2/OpenID Connect)
d. API Gateway / Back-end
- NestJS REST API
- Proxy rules in UmiJS (config/proxy.ts)
e. Data Store
- PostgreSQL
f. External services
- OneSignal (push notifications)
- TinyMCE (rich-text editor assets served from public/)

##### Internal front-end modules
- Routing (config/routes.ts, pages/)
- UI components (src/components/)
- Data models (src/models/)
- Service layer (src/services/… modules wrap all API calls, typings)
- Global utilities/config (src/utils/, config/config.ts, environment .env)
- Mock server (src/mock/)

##### Relationships and data flows
- Browser → (HTTPS) → Static Host → delivers SPA
- SPA → Keycloak → redirects back with tokens
- SPA (with token) → NestJS API → PostgreSQL
- SPA ↔ OneSignal via its JS SDK for push notifications
- SPA → uses service-worker for caching, background sync

##### Architectural patterns & design principles
- Layered architecture: UI layer, service layer, data layer
- Convention-over-configuration via UmiJS plugins (routing, i18n, proxy)
- Separation of concerns: components vs pages vs services vs models
- Environment-based configuration (dev/prod in config/)

- Annotations for build/deploy artifacts (Dockerfile, nginx.conf, vercel/project.json)

## Diagram (Mermaid)

```mermaid
flowchart TB
    classDef frontend fill:#ADD8E6,stroke:#000;
    classDef backend fill:#90EE90,stroke:#000;
    classDef external fill:#FFA500,stroke:#000;
    classDef datastore fill:#FFFFE0,stroke:#000;
    classDef infra fill:#D3D3D3,stroke:#000;

    subgraph "Browser (Client)"
        direction TB
        SPA["SPA Bundle\n(UmiJS/Webpack)"]:::frontend
        SW["Service Worker"]:::frontend

        subgraph "SPA Internal"
            direction TB
            Routes["Routes & Pages"]:::frontend
            Components["UI Components"]:::frontend
            Models["Data Models"]:::frontend
            Services["Service Layer & Models"]:::frontend
            Utils["Global Utils & Config"]:::frontend
            Proxy["API Proxy Rules"]:::frontend
            OIDC["OIDC Boundary Component"]:::frontend
            OneSigBounder["OneSignal Boundary"]:::frontend
            Mock["Mock Server"]:::frontend
        end
    end

    StaticHost["Static Host / CDN\n(Vercel / Docker+Nginx)"]:::infra
    API["NestJS REST API"]:::backend
    DB["PostgreSQL"]:::datastore
    Keycloak["Keycloak (Auth Service)"]:::external
    OneSignal["OneSignal"]:::external
    TinyMCE["TinyMCE Assets"]:::external

    StaticHost -->|"delivers SPA"| SPA
    SPA -->|"OAuth2 login"| Keycloak
    Keycloak -->|"redirect with tokens"| SPA
    SPA -->|"REST API"| API
    API -->|"data queries"| DB
    SPA -->|"Push events"| OneSignal
    SPA -->|"Loads assets"| TinyMCE
    SPA -->|"Caches & bg sync"| SW

    click SPA "https://github.com/aizen2510/btl_web_n8/blob/main/src/app.tsx"
    click SW "https://github.com/aizen2510/btl_web_n8/blob/main/src/service-worker.js"
    click Routes "https://github.com/aizen2510/btl_web_n8/blob/main/config/routes.ts"
    click Routes "https://github.com/aizen2510/btl_web_n8/tree/main/src/pages/"
    click Components "https://github.com/aizen2510/btl_web_n8/tree/main/src/components/"
    click Models "https://github.com/aizen2510/btl_web_n8/tree/main/src/models/"
    click Services "https://github.com/aizen2510/btl_web_n8/tree/main/src/services/"
    click Utils "https://github.com/aizen2510/btl_web_n8/tree/main/src/utils/"
    click Utils "https://github.com/aizen2510/btl_web_n8/blob/main/config/config.ts"
    click Utils "https://github.com/aizen2510/btl_web_n8/blob/main/config/config.dev.ts"
    click Utils "https://github.com/aizen2510/btl_web_n8/blob/main/.env"
    click Proxy "https://github.com/aizen2510/btl_web_n8/blob/main/config/proxy.ts"
    click OIDC "https://github.com/aizen2510/btl_web_n8/blob/main/src/components/OIDCBounder/index.tsx"
    click OIDC "https://github.com/aizen2510/btl_web_n8/blob/main/src/components/OIDCBounder/constant.ts"
    click Utils "https://github.com/aizen2510/btl_web_n8/blob/main/src/utils/oidcConfig.ts"
    click OneSigBounder "https://github.com/aizen2510/btl_web_n8/blob/main/src/components/OneSignalBounder/index.tsx"
    click OneSignal "https://github.com/aizen2510/btl_web_n8/blob/main/public/OneSignalSDKWorker.js"
    click TinyMCE "https://github.com/aizen2510/btl_web_n8/tree/main/public/tinymce/"
    click Mock "https://github.com/aizen2510/btl_web_n8/tree/main/mock/"
    click StaticHost "https://github.com/aizen2510/btl_web_n8/blob/main/.vercel/project.json"
    click StaticHost "https://github.com/aizen2510/btl_web_n8/tree/main/Dockerfile"
    click StaticHost "https://github.com/aizen2510/btl_web_n8/blob/main/.nginx/nginx.conf"
```
