# sourcefuse/react-boilerplate-ts-ui architecture

> Architecture diagram of the GitHub repository sourcefuse/react-boilerplate-ts-ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sourcefuse/react-boilerplate-ts-ui
- Repository: https://github.com/sourcefuse/react-boilerplate-ts-ui

## Overview

##### Project type and purpose
- This is a front-end “boilerplate” React application written in TypeScript, bundled with Vite, pre-configured with Material-UI (MUI) theming, Redux (RTK + RTK Query), form components, routes, providers, storybook for components, and CI/CD & security workflows.
- It also includes an AWS-CDK folder to deploy the built static assets to S3 + CloudFront (Infrastructure-as-Code).

##### File structure
- Top-level folders:
- src: your React application (Components, Pages, Hooks, Providers, Redux slices, Routes, Layouts)
- public + assets: static files (index.html, manifest, robots.txt, images)
- cdk: AWS-CDK code for provisioning S3, CloudFront, IAM, etc.
- .storybook: Storybook configuration for interactive component docs
- Configuration & build:
- Dockerfile + docker-compose.yml + nginx/: local containerized build/test/deploy environment
- build.sh / configGenerator.js / farm.config.ts: build scripts & runtime environment RC generation
- . github/workflows: CI pipelines for release, Snyk scans, docs updates
- Vite & tsconfig files for bundling & type-checking

##### README for additional insights
- Confirms use of: Vite dev server, MUI, Redux, Formik-style wrappers, storybook, Docker, Docker-Compose, AWS-CDK deploy to port 80
- Lists environment inputs (CLIENT_ID, AUTH_API_BASE_URL, etc.), implying runtime calls to external Auth & App APIs

a. Main components
- Developer workstation: VS Code + Git ➔ local dev (Vite or Docker Compose + Nginx)
- CI/CD (GitHub Actions): tests, Snyk scan, build, CDK synth/deploy
- Frontend application:
- Presentation Layer (React + MUI, Components, Pages, Layouts, Providers)
- State layer (Redux store, RTK Query, authSlice, configSlice)
- Routing layer (Routes.tsx + layoutRouteConfig)
- Asset hosting & delivery: AWS S3 (static files) + CloudFront distribution
- External services:
- Authentication service (AUTH_API_BASE_URL)
- Application API service (APP_API_BASE_URL)
- Storybook: standalone component explorer (deployed or local)

b. Relationships & interactions
- Browser ➔ CloudFront ➔ S3 (serves index.html + JS/CSS bundles)
- React app in browser ➔ external Auth & App APIs via RTK Query hooks
- Redux store holds auth tokens/config, provided via Providers (useAuth, useConfig)
- CI pipelines push built assets & CDK templates to AWS; CDK deploy updates CloudFront/S3

c. Architectural patterns & design principles
- Component-driven architecture (Atomic/MUI-extended components, Storybook)
- Provider pattern for cross-cutting concerns (ThemeProvider, Auth, Notification, ErrorBoundary)
- Route-based code organization with layout composition (HeaderLayout vs MainLayout)
- Infrastructure-as-Code (AWS CDK) for reproducible deployments
- Containerization (Docker + Nginx) for environment parity

d. Key technologies & libraries
- React, TypeScript, Vite, MUI
- Redux Toolkit + RTK Query
- Storybook for UI development
- AWS CDK (TypeScript) targeting S3 + CloudFront
- Docker, Docker-Compose, Nginx
- GitHub Actions, Snyk, Husky, Prettier, ESLint

## Diagram (Mermaid)

```mermaid
graph TB
  %% Developer Environment
  subgraph "Developer Workstation"
    VSCode["VS Code + Git"]:::dev
    LocalDev["Local Dev (Vite / Docker Compose + Nginx)"]:::dev
  end

  %% CI/CD Pipeline
  subgraph "CI/CD (GitHub Actions)" 
    Release["release.yml"]:::ci
    Snyk["snyk.yaml"]:::ci
    UpdateDocs["update-docs.yml"]:::ci
  end

  %% AWS Infrastructure
  subgraph "AWS Production"
    CDKMain["cdk/main.ts"]:::infra
    CDKUtils["cdk/helper/utils.ts"]:::infra
    CDKTest["CloudfrontStaticWebsite.stack.test.ts"]:::infra
    S3Bucket["S3 Bucket (Static Assets)"]:::infra
    CloudFront["CloudFront CDN"]:::infra
  end

  %% Browser and Frontend Layers
  subgraph "Browser (React App)"
    subgraph "Presentation Layer" 
      Components["Components"]:::frontend
      Pages["Pages"]:::frontend
    end
    subgraph "Routing Layer"
      Routes["Routes.tsx"]:::frontend
      LayoutConfig["layoutRouteConfig.tsx"]:::frontend
      HeaderLayout["HeaderLayout.tsx"]:::frontend
      MainLayout["MainLayout.tsx"]:::frontend
    end
    subgraph "State Layer"
      Store["store.ts"]:::frontend
      ApiSlice["apiSlice.ts"]:::frontend
      AuthApi["authApiSlice.ts"]:::frontend
      AuthSlice["authSlice.ts"]:::frontend
      ConfigSlice["configSlice.ts"]:::frontend
      ConfigThunk["configThunk.ts"]:::frontend
      Hooks["hooks.ts"]:::frontend
    end
    subgraph "Providers"
      Theme["ThemeProvider.tsx"]:::frontend
      DeviceWidth["DeviceWidthProvider.tsx"]:::frontend
      ErrorBoundary["ErrorBoundary.tsx"]:::frontend
      Notification["NotificationProvider.tsx"]:::frontend
      OnlineStatus["OnlineStatusProvider.tsx"]:::frontend
    end
  end

  %% Storybook
  subgraph "Storybook"
    SBMain[".storybook/main.ts"]:::dev
    SBPrev[".storybook/preview.ts"]:::dev
    Stories["src/stories"]:::dev
  end

  %% External Services
  AuthAPI["Auth API Service"]:::external
  AppAPI["App API Service"]:::external

  %% Connections
  VSCode --> LocalDev
  VSCode --> Release
  VSCode --> Snyk
  VSCode --> UpdateDocs

  LocalDev --> Browser
  Release --> CDKMain
  Snyk --> CDKMain
  UpdateDocs --> CDKMain

  CDKMain --> CDKUtils
  CDKMain --> CDKTest
  CDKMain --> S3Bucket
  CDKMain --> CloudFront

  CloudFront --> S3Bucket
  CloudFront --> Browser
  Browser --> AuthAPI
  Browser --> AppAPI

  %% Click Events
  click Components "https://github.com/sourcefuse/react-boilerplate-ts-ui/tree/main/src/Components"
  click Pages "https://github.com/sourcefuse/react-boilerplate-ts-ui/tree/main/src/Pages"
  click HeaderLayout "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/Layouts/HeaderLayout/HeaderLayout.tsx"
  click MainLayout "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/Layouts/MainLayout/MainLayout.tsx"
  click Theme "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/Providers/theme/ThemeProvider.tsx"
  click DeviceWidth "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/Providers/DeviceWidthProvider.tsx"
  click ErrorBoundary "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/Providers/ErrorBoundary.tsx"
  click Notification "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/Providers/NotificationProvider.tsx"
  click OnlineStatus "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/Providers/OnlineStatusProvider.tsx"
  click Routes "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/Routes/Routes.tsx"
  click LayoutConfig "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/Routes/layoutRouteConfig.tsx"
  click Store "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/redux/store.ts"
  click ApiSlice "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/redux/apiSlice.ts"
  click AuthApi "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/redux/auth/authApiSlice.ts"
  click AuthSlice "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/redux/auth/authSlice.ts"
  click ConfigSlice "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/redux/config/configSlice.ts"
  click ConfigThunk "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/redux/config/configThunk.ts"
  click Hooks "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/src/redux/hooks.ts"
  click SBMain "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/.storybook/main.ts"
  click SBPrev "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/.storybook/preview.ts"
  click Stories "https://github.com/sourcefuse/react-boilerplate-ts-ui/tree/main/src/stories"
  click CDKMain "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/cdk/main.ts"
  click CDKUtils "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/cdk/helper/utils.ts"
  click CDKTest "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/cdk/__tests__/CloudfrontStaticWebsite.stack.test.ts"
  click Dockerfile "https://github.com/sourcefuse/react-boilerplate-ts-ui/tree/main/Dockerfile"
  click DockerCompose "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/docker-compose.yml"
  click Nginx "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/nginx/nginx.conf"
  click Release "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/.github/workflows/release.yml"
  click Snyk "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/.github/workflows/snyk.yaml"
  click UpdateDocs "https://github.com/sourcefuse/react-boilerplate-ts-ui/blob/main/.github/workflows/update-docs.yml"

  %% Styles
  classDef frontend fill:#e0f7fa,stroke:#006064,color:#006064;
  classDef dev fill:#e3f2fd,stroke:#0d47a1,color:#0d47a1;
  classDef ci fill:#e8f5e9,stroke:#1b5e20,color:#1b5e20;
  classDef infra fill:#f3e5f5,stroke:#4a148c,color:#4a148c;
  classDef external fill:#fff3e0,stroke:#e65100,color:#e65100;
```
