# faroog25/construction-management-app architecture

> Architecture diagram of the GitHub repository faroog25/construction-management-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/faroog25/construction-management-app
- Repository: https://github.com/faroog25/construction-management-app

## Overview

##### Project type and purpose
- This is a single-page application (SPA) front-end only, built with React 18, TypeScript, and Vite.
- It consumes one or more RESTful APIs (via the `services/` layer) to power a Construction Management Assistant UI (clients, projects, tasks, equipment, documents, team).
- It uses React Router for navigation, React Query for data fetching/caching, React Hook Form + Zod for form validation, Tailwind CSS + shadcn/ui for styling and components, plus contexts for theming and i18n.

##### File structure
- Top-level “src” divides into:
- `pages/`: route components (e.g. `Projects.tsx`, `ClientProfile.tsx`)
- `components/`: reusable UI and domain widgets (GanttChart, Navbar, Modals, `ui/` primitives)
- `services/`: functions that wrap HTTP calls to backend endpoints
- `hooks/`: custom React hooks (use-mobile, use-toast, useTaskWorkers)
- `contexts/`: global React contexts for Theme and Language
- `lib/` & `utils/`: pure utilities and Zod validation schemas
- `data/`: mock or static JSON (e.g. API docs)
- entrypoints & configs: `main.tsx`, `App.tsx`, `vite.config.ts`, Tailwind, ESLint, TS configs.

##### README insights
- Confirms technology choices and high-level features (React Query, shadcn/ui, Tailwind, Zod).
- Mentions routing and data-fetching stacks, responsive design, dark mode, type safety.

##### Main components & interactions (
a. Presentation Layer
- Pages (React Router routes)
- UI Components (shadcn/ui primitives + domain components under `components/`)
b. State & Context
- React Query cache & QueryClient (data caching)
- ThemeContext & LanguageContext (global state)
c. Service Layer
- `services/*.ts` modules → HTTP client (in `services/api.ts`) → backend REST API
d. Utilities & Validation
- Zod schemas in `lib/validations` used in form components via React Hook Form
- Helper functions in `lib/utils.ts` & `utils/`
e. Build & Tooling
- Vite dev server & bundler
- Tailwind PostCSS pipeline
- ESLint / TS checks

Flow example:
User clicks “New Project” → Page component opens `<NewProjectModal>` → React Hook Form + Zod validate inputs → onSubmit calls `projectService.create(...)` → `api.ts` issues HTTP POST → server responds → React Query invalidates project list query → UI updates.

##### Architectural patterns & design principles
- Component-based UI (shadcn/ui + custom)
- Layered separation: Presentation ↔ State/Context ↔ Services ↔ API
- Unidirectional data flow (React Query & hooks)
- Type safety end-to-end (TypeScript + Zod + typed service responses)
- Theming & Localization via Context

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend SPA"
        subgraph "Presentation Layer"
            Pages["Pages\n(React Router)"]:::presentation
            Components["UI Components\n(shadcn/ui + domain)"]:::presentation
        end

        subgraph "State & Context"
            QueryClient["React Query\n(QueryClient)"]:::state
            ThemeContext["ThemeContext"]:::state
            LanguageContext["LanguageContext"]:::state
            Hooks["Custom Hooks"]:::state
        end

        subgraph "Services"
            APIClient["api.ts\n(HTTP client)"]:::service
            DomainServices["Domain Services\n(services/*.ts)"]:::service
        end

        subgraph "Utilities & Validation"
            Validations["Zod Schemas\n(lib/validations)"]:::utils
            Utils["Utility Functions\n(lib/utils & utils/)"]:::utils
            MockData["Mock & Static Data\n(data/)"]:::utils
        end

        subgraph "Entrypoints"
            Main["main.tsx\n(Application Bootstrap)"]:::presentation
            App["App.tsx\n(Routing Entrypoint)"]:::presentation
        end
    end

    BackendAPI["Backend REST API"]:::external

    Build["Build & Tooling"]:::build

    Main --> App
    App --> Pages
    Pages --> Components
    Pages --> QueryClient
    Components --> Hooks
    Hooks --> QueryClient
    QueryClient --> DomainServices
    DomainServices --> APIClient
    APIClient --> BackendAPI
    Validations --> Components
    Validations --> Pages
    Utils --> DomainServices
    MockData --> Components
    Build --> Main

    classDef presentation fill:#cce5ff,stroke:#4da3ff,color:#000;
    classDef state fill:#d4edda,stroke:#28a745,color:#000;
    classDef service fill:#ffe5b4,stroke:#ff9800,color:#000;
    classDef utils fill:#e6e6fa,stroke:#9370db,color:#000;
    classDef external fill:#f0f0f0,stroke:#6c757d,color:#000;
    classDef build fill:#fff3cd,stroke:#ffc107,color:#000;

    click Pages "https://github.com/faroog25/construction-management-app/tree/main/src/pages"
    click Components "https://github.com/faroog25/construction-management-app/tree/main/src/components"
    click APIClient "https://github.com/faroog25/construction-management-app/blob/main/src/services/api.ts"
    click DomainServices "https://github.com/faroog25/construction-management-app/tree/main/src/services"
    click ThemeContext "https://github.com/faroog25/construction-management-app/blob/main/src/contexts/ThemeContext.tsx"
    click LanguageContext "https://github.com/faroog25/construction-management-app/blob/main/src/contexts/LanguageContext.tsx"
    click Hooks "https://github.com/faroog25/construction-management-app/tree/main/src/hooks"
    click Validations "https://github.com/faroog25/construction-management-app/tree/main/src/lib/validations"
    click Utils "https://github.com/faroog25/construction-management-app/blob/main/src/lib/utils.ts"
    click MockData "https://github.com/faroog25/construction-management-app/tree/main/src/data"
    click App "https://github.com/faroog25/construction-management-app/blob/main/src/App.tsx"
    click Main "https://github.com/faroog25/construction-management-app/blob/main/src/main.tsx"
    click Build "https://github.com/faroog25/construction-management-app/blob/main/vite.config.ts"
    click Build "https://github.com/faroog25/construction-management-app/blob/main/tailwind.config.ts"
    click Build "https://github.com/faroog25/construction-management-app/blob/main/eslint.config.js"
    click Build "https://github.com/faroog25/construction-management-app/blob/main/tsconfig.json"
    click Build "https://github.com/faroog25/construction-management-app/blob/main/postcss.config.js"
```
