# somesh-debnath/pcms-frontend architecture

> Architecture diagram of the GitHub repository somesh-debnath/pcms-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/somesh-debnath/pcms-frontend
- Repository: https://github.com/somesh-debnath/pcms-frontend

## Overview

##### Main Components
- Client Application: This is the core React application found under the src/ directory. It includes:
- UI components (located in src/components and its subdirectories such as billing and ui).
- Pages (both Admin and User pages under src/pages).
- Routing, context, and interfaces (src/router, src/context, src/interfaces) that manage state, navigation, and type contracts.
- Utility functions in src/lib.
- Build and Configuration: Tools and settings specific to this project such as:
- Vite (vite.config.js), TypeScript (tsconfig.json), Tailwind CSS (tailwind.config.js) and PostCSS.
- ESLint configuration files (.eslintrc.js, eslint.config.js).
- Containerization and Deployment:
- Docker configurations: Separate Dockerfile definitions for development (docker/dev) and production (docker/prod) environments.
- Docker Compose files (docker-compose.yml and docker-compose.prod.yml) help orchestrate the containers.
- Nginx configuration in the nginx/ folder which likely sets up reverse proxy and static file serving in production.
- CI/CD and Deployment Scripts:
- GitHub workflows under .github/workflows (for linting, Docker publishing, S3 deployment).
- Deployment scripts in scripts/ (deploy.ts) and AWS-related configuration (aws/s3-policy.json).
- README scripts indicate how to deploy the built image to GitHub Container Registry and push to AWS S3.

##### Out Relationships and Interactions
- Frontend Application: The React app communicates with backend APIs (although they’re not part of this repo, services like AuthService, BillService, and PlansServices in src/services suggest RESTful calls) and handles routing and state management via Context and Router components.
- Build & Deployment: Local development is handled by Vite and npm scripts. The Docker configurations allow for isolated environments ensuring production readiness. CI/CD pipelines (GitHub workflows) automate linting, testing, container building, and publishing.
- Reverse Proxy: Nginx acts as the web server that routes requests—likely serving the static build output and possibly handling SSL termination or caching.
- Cloud Deployment: Deployment instructions mention AWS S3 for hosting static assets, meaning the final built artifacts are pushed to S3 for production.

##### Architectural Patterns & Key Technologies
- Component-Based UI: The project uses modular React components, pages, and context for managing state and UI routing.
- Separation of Concerns: Code is separated into UI, business logic (services), data management (context and interfaces), and configuration.
- Containerization: Docker is used to ensure consistency between development and production environments. The presence of separate configurations for dev and prod is a crucial design element.
- CI/CD Integration: GitHub workflows (e.g., lint, docker-publish, s3-deploy) are central to maintaining quality and streamlining deployments.
- Deployment Strategy: The use of AWS S3 for hosting static build files and GitHub Container Registry for Docker images is a key part of the deployment architecture.
- Modern Tooling: The project employs Vite for fast development builds and Tailwind CSS for styling, which influence how the frontend is built and deployed.

##### Elements
- Clear labels for every component:
- “React Frontend (src/)”
- “UI Components (components, pages)”
- “Routing & State Management (router, context)”
- “API Service Layer (services)”
- “Build Tools & Configurations (Vite, TypeScript, Tailwind CSS, ESLint)”
- “Containerization (Dockerfiles, Docker Compose)”
- “Reverse Proxy (Nginx)”
- “CI/CD Pipeline (GitHub workflows)”
- “Deployment Targets (AWS S3, GitHub Container Registry)”
- Data flow from the React application to external API endpoints.
- Process flow from code commit → CI/CD pipelines → Docker image build → deployment to AWS S3 or container runtime.
- Internal interactions between the UI components, services, context, and routing modules.
- Application logic components (e.g., blue for UI components, green for service layers).
- Infrastructure elements (e.g., orange for Docker, red for CI/CD tools, purple for cloud deployment).

##### Detailed Steps for the Principal Software Engineer
- Start sketching by placing the main “React Application” block in the center.
- Off to one side, add blocks for “Build Tools & Configurations” (Vite, TypeScript, Tailwind, ESLint) to show the dependencies during development.
- On another side, illustrate the containerization strategy:
- Separate blocks for “Development Docker Environment” (docker/dev) and “Production Docker Environment” (docker/prod).
- With the “Docker Compose” files that manage the overall container orchestration.
- Optionally, add notes indicating the role of AWS (S3 deployment) and GHCR (storage for Docker images).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Application Subgraph
    subgraph "Frontend Application"
        React["React Frontend (src/)"]:::react
        UI["UI Components (src/components)"]:::ui
        Pages["Pages (src/pages)"]:::ui
        Router["Routing & State Management (src/router,src/context,src/interfaces)"]:::react
        Util["Utility Functions (src/lib)"]:::react
        API["API Service Layer (src/services)"]:::service
    end

    %% Build Tools & Configurations
    Build["Build Tools & Configurations (Vite, TypeScript,Tailwind,ESLint)"]:::tool

    %% Containerization & Deployment Configurations
    subgraph "Containerization & Deployment"
        DockerDev["Development Docker (docker/dev/Dockerfile)"]:::infra
        DockerProd["Production Docker (docker/prod/Dockerfile)"]:::infra
        Compose["Docker Compose (docker-compose.yml, docker-compose.prod.yml)"]:::infra
    end

    %% Reverse Proxy
    Nginx["Reverse Proxy (nginx/default.conf)"]:::infra

    %% CI/CD Pipeline
    CICD["CI/CD Pipeline (.github/workflows)"]:::ci

    %% Deployment Scripts & AWS Configuration
    Deploy["Deployment Scripts & AWS (scripts/deploy.ts,aws/s3-policy.json)"]:::deploy

    %% External Backend APIs
    Backend["Backend APIs"]:::service

    %% Relationships for Frontend Application
    React -->|"composes"| UI
    React -->|"composes"| Pages
    React -->|"manages"| Router
    React -->|"utilizes"| Util
    React -->|"calls"| API
    API -->|"RESTcalls"| Backend

    %% Build Process Flow
    Build -->|"builds"| React

    %% Containerization Flow
    React -->|"packaged with"| DockerProd
    Build -->|"configured by"| Compose
    Compose --> DockerDev
    Compose --> DockerProd
    DockerProd -->|"served by"| Nginx

    %% CI/CD Flow
    CICD -->|"automates"| Build
    CICD -->|"orchestrates"| Compose
    CICD -->|"deploys to"| Deploy

    %% Click Events
    click React "https://github.com/somesh-debnath/pcms-frontend/tree/main/src/"
    click UI "https://github.com/somesh-debnath/pcms-frontend/tree/main/src/components/"
    click Pages "https://github.com/somesh-debnath/pcms-frontend/tree/main/src/pages/"
    click Router "https://github.com/somesh-debnath/pcms-frontend/tree/main/src/router/"
    click Util "https://github.com/somesh-debnath/pcms-frontend/tree/main/src/lib/"
    click API "https://github.com/somesh-debnath/pcms-frontend/tree/main/src/services/"
    click Build "https://github.com/somesh-debnath/pcms-frontend/blob/main/vite.config.js"
    click DockerDev "https://github.com/somesh-debnath/pcms-frontend/tree/main/docker/dev/Dockerfile"
    click DockerProd "https://github.com/somesh-debnath/pcms-frontend/tree/main/docker/prod/Dockerfile"
    click Compose "https://github.com/somesh-debnath/pcms-frontend/blob/main/docker-compose.yml"
    click Nginx "https://github.com/somesh-debnath/pcms-frontend/blob/main/nginx/default.conf"
    click CICD "https://github.com/somesh-debnath/pcms-frontend/tree/main/.github/workflows/"
    click Deploy "https://github.com/somesh-debnath/pcms-frontend/blob/main/scripts/deploy.ts"

    %% Styles
    classDef react fill:#bbdefb,stroke:#1e88e5,stroke-width:2px;
    classDef ui fill:#90caf9,stroke:#1565c0,stroke-width:2px;
    classDef service fill:#c8e6c9,stroke:#388e3c,stroke-width:2px;
    classDef tool fill:#a5d6a7,stroke:#2e7d32,stroke-width:2px;
    classDef infra fill:#ffe082,stroke:#f57f17,stroke-width:2px;
    classDef ci fill:#ef9a9a,stroke:#c62828,stroke-width:2px;
    classDef deploy fill:#ce93d8,stroke:#8e24aa,stroke-width:2px;
```
