# siriknikita/poly-micro-frontend-demo architecture

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

- Interactive diagram: https://gitdiagram.com/siriknikita/poly-micro-frontend-demo
- Repository: https://github.com/siriknikita/poly-micro-frontend-demo

## Overview

##### Project type and purpose
- This is a **single-page React application (SPA)** whose purpose is to serve as the frontend UI for managing microservices: authentication, testing, monitoring, CI/CD pipelines, and release management.
- It does **not** include its own backend code; it depends on external microservice APIs and leverages an in-browser IndexedDB for local data.

##### File structure
- **Top-level folders**:
- `src/components` – feature-based UI modules (auth, help, monitoring, pipelining, releases, testing)
- `src/context` – React Context providers for global state (Guidance, Project, Release, Toast)
- `src/db` – Dexie wrapper for IndexedDB (`db.ts`, seeding/reset scripts)
- `src/hooks` – reusable custom hooks for data fetching and UI logic
- `src/utils` – utilities around release management and sync
- Configuration files for Vite, Tailwind, TypeScript, ESLint, Vitest, GitHub Actions, Vercel, Docker/SonarQube.

##### README insights
- **Tech stack**: React 18 + TypeScript, Vite, Tailwind, React Router, React Context, Dexie (IndexedDB), Vitest, Recharts, React Toastify.
- **Features**: JWT-based auth; AI-assisted testing; real-time monitoring; CI/CD pipeline visualization; release management.
- **Patterns**: SOLID principles in React, feature-based organization, separation of concerns (hooks vs components), context API for global state.

##### Main components
A. **Frontend SPA** (hosted on Vercel or CDN)
- React app entry (`main.tsx` → `App.tsx`)
- Feature modules: Auth, Testing, Monitoring, Pipelining, Releases, Help
- Shared UI services: React Router, Context Providers, Toast notifications
- Local storage: IndexedDB via Dexie (`src/db/db.ts`)
B. **External Services / APIs**
- **Auth API** – issues JWTs, role-based ACL
- **Test Service API** – AI test generation, execution results
- **Monitoring API** – streaming metrics, logs
- **Pipeline Orchestrator API** – fetch pipelines, trigger builds/deploys
- **Release Management API** – versioning, changelogs
C. **CI/CD & DevOps** (for the repository)
- **GitHub Actions** – lint, test, build, release workflows
- **Docker & SonarQube** – static analysis (optional)
D. **Local Developer Tools**
- Vite dev server
- Vitest runner
- ESLint / Prettier
- Docker-Compose for SonarQube

##### Relationships and data flows
1. **User** interacts with **Browser** → SPA UI
2. **SPA UI**:
- Retrieves/stores session data & cached entities in **IndexedDB**
- Calls **Auth API** for login/register; receives JWT → stored in context
- Calls **Test API**, **Monitoring API**, **Pipeline API**, **Release API**
- UI updates via React Context + hooks; charts via Recharts
3. All **API calls** attach JWT in headers → backend microservices
5. **GitHub Actions** push build artifacts to Vercel; trigger documentation updates

##### Architectural patterns & design principles
- **Feature-based modularization**: each domain (auth, monitoring, testing, pipelining, releases) in its own directory
- **Separation of concerns**:
- UI components render only presentation
- Business logic & data fetching in custom hooks
- Global state in React Context providers
- Constants & utilities extracted to dedicated modules
- **SOLID**: components follow SRP; open-closed via props; Liskov in interchangeable buttons; DI via hooks & contexts
- **Offline-first / caching**: Dexie (IndexedDB) for UX stability

- **Component labels**: Auth Service, Test Service, Monitoring Service, Pipeline Orchestrator, Release Manager
- **Annotations** for protocols (HTTP, WebSocket) and data formats (JSON, JWT)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User and Browser
    User["User"]:::user
    Browser["Browser"]:::user
    User -->|"interacts with"| Browser

    %% Frontend SPA
    subgraph "Frontend SPA" 
        direction TB
        Main["main.tsx"]:::frontend
        App["App.tsx"]:::frontend
        Router["AppRouter"]:::frontend
        Contexts["Context Providers"]:::frontend
        subgraph "Feature Modules"
            direction TB
            AuthMod["Auth Module"]:::frontend
            TestMod["Testing Module"]:::frontend
            MonMod["Monitoring Module"]:::frontend
            PipeMod["Pipelining Module"]:::frontend
            RelMod["Releases Module"]:::frontend
            HelpMod["Help Module"]:::frontend
        end
        SharedLayout["AppLayout & Shared"]:::frontend
        DB["IndexedDB (Dexie)"]:::storage
    end

    Browser -->|"loads SPA"| Main
    Main -->|"renders"| App
    App -->|"routes via"| Router
    App -->|"provides via"| Contexts
    Router --> AuthMod
    Router --> TestMod
    Router --> MonMod
    Router --> PipeMod
    Router --> RelMod
    Router --> HelpMod
    App --> SharedLayout
    App --> DB

    %% External APIs
    subgraph "External Microservice APIs"
        direction TB
        AuthAPI["Auth Service API"]:::external
        TestAPI["Test Service API"]:::external
        MonAPI["Monitoring Service API"]:::external
        PipeAPI["Pipeline Orchestrator API"]:::external
        RelAPI["Release Manager API"]:::external
    end

    AuthMod -->|"POST /login JWT"| AuthAPI
    TestMod -->|"POST /test & GET results"| TestAPI
    MonMod -->|"GET /metrics (WebSocket)"| MonAPI
    PipeMod -->|"GET/POST pipelines"| PipeAPI
    RelMod -->|"GET/POST releases"| RelAPI
    Contexts --> AuthAPI
    DB --> AuthMod

    %% DevOps & CI/CD
    subgraph "CI/CD & DevOps Tools"
        direction TB
        GHActions["GitHub Actions"]:::devops
        Vercel["Vercel Deployment"]:::devops
        Sonar["Docker & SonarQube"]:::devops
        Vitest["Vitest Runner"]:::devops
        ESLint["ESLint/Prettier"]:::devops
        Vite["Vite Dev Server"]:::devops
    end

    App -->|"built by"| GHActions
    GHActions -->|"deploys to"| Vercel
    GHActions -->|"runs analysis on"| Sonar
    GHActions --> Vitest
    GHActions --> ESLint
    Browser --> Vite

    %% Click Events
    click Main "https://github.com/siriknikita/poly-micro-frontend-demo/blob/main/src/main.tsx"
    click App "https://github.com/siriknikita/poly-micro-frontend-demo/blob/main/src/App.tsx"
    click AuthMod "https://github.com/siriknikita/poly-micro-frontend-demo/tree/main/src/components/auth"
    click TestMod "https://github.com/siriknikita/poly-micro-frontend-demo/tree/main/src/components/testing"
    click MonMod "https://github.com/siriknikita/poly-micro-frontend-demo/tree/main/src/components/monitoring"
    click PipeMod "https://github.com/siriknikita/poly-micro-frontend-demo/tree/main/src/components/pipelining"
    click RelMod "https://github.com/siriknikita/poly-micro-frontend-demo/tree/main/src/components/releases"
    click HelpMod "https://github.com/siriknikita/poly-micro-frontend-demo/tree/main/src/components/help"
    click Router "https://github.com/siriknikita/poly-micro-frontend-demo/blob/main/src/components/shared/AppRouter.tsx"
    click SharedLayout "https://github.com/siriknikita/poly-micro-frontend-demo/tree/main/src/components/layout"
    click Contexts "https://github.com/siriknikita/poly-micro-frontend-demo/tree/main/src/context"
    click DB "https://github.com/siriknikita/poly-micro-frontend-demo/blob/main/src/db/db.ts"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef storage fill:#d4edda,stroke:#28a745,color:#000;
    classDef external fill:#ffe5b4,stroke:#ff9900,color:#000;
    classDef devops fill:#e0ccff,stroke:#9933ff,color:#000;
    classDef user fill:#f0f0f0,stroke:#666,color:#000;
```
