# joseph-1989/homecareexperts-next architecture

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

- Interactive diagram: https://gitdiagram.com/joseph-1989/homecareexperts-next
- Repository: https://github.com/joseph-1989/homecareexperts-next

## Overview

##### Project Type and Purpose
- This is a Next.js–based, TypeScript monorepo serving a multi-section web application (homepage, community, customer-support, property/service listings, user pages, admin panel). It’s primarily a frontend UI layer, using Apollo Client to fetch data from an external GraphQL backend. It also bundles responsive SCSS styling and i18n.

##### File-Structure Analysis
- Top-level folders:
- pages/ – Next.js route definitions (including pages/_admin for admin UI).
- apollo/ – GraphQL client setup, grouped by “admin” and “user” query/mutation modules.
- libs/ – Shared code: UI components (React), hooks, enums, types (GraphQL schemas, inputs), utilities, and auth helpers.
- public/ – Static assets (images, videos, localization JSON).
- scss/ – Global and per-page responsive style definitions for mobile/PC.
- Config/build files: next.config.js, next-i18next.config.js, tsconfig.json, docker-compose.yml, deploy.sh.

##### README Insights
- Bootstrapped via create-next-app: standard dev commands, SSR/SSG, API routes (although none under pages/api here).
- Emphasizes Next.js features (font optimization, dynamic routing) and Vercel deployment.

a. Main Components
- Client browser (User Agent)
- Next.js frontend server (SSR/SSG, static-file server)
- Apollo Client layer (in-browser/cache, fetch logic)
- External GraphQL API service
- Database (e.g., PostgreSQL/MySQL behind the GraphQL API)
- CDN or static‐file storage (serving public/ assets)
- Optional Auth service (JWT issuer/validator)
b. Relationships & Data Flows
1. User → HTTP(S) → Next.js server (renders pages SSR or serves static HTML/CSS/JS).
2. Next.js page/component → Apollo Client → GraphQL API → Database.
3. Client reads/writes via Apollo cache; invalidations flow back to UI.
4. Static assets (images, videos) served via CDN or Next.js public folder.
5. Localization JSON fetched by next-i18next at SSR time or client side.
c. Architectural Patterns
- Monorepo modularization (libs folder for shared code).
- Component-based UI (React + TSX in libs/components + pages).
- GraphQL client-server pattern (Apollo).
- SSR/SSG hybrid rendering (Next.js).
- Responsive design (SCSS mobile/PC splits).
d. Key Technologies
- Next.js (routing, SSR, static export)
- React + TypeScript (UI)
- Apollo Client (GraphQL queries/mutations in apollo/*)
- SCSS (responsive styling under scss/)
- next-i18next (i18n)
- Docker & docker-compose (containerization)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    subgraph "User Layer"
        UA["Client Browser<br/>(Next.js UI)"]:::ui
    end

    %% Frontend Server Layer
    subgraph "Next.js Frontend Server<br/>(SSR/SSG)" 
        NX["Next.js Server<br/>(React + TypeScript)"]:::ui

        subgraph "Route Definitions<br/>(pages/)" 
            PGS["pages/"]:::ui
        end

        subgraph "Apollo Client Layer<br/>(apollo/)" 
            AC1["client.ts"]:::datafetch
            AC2["store.ts"]:::datafetch
            ADM_Q["admin/query.ts"]:::datafetch
            ADM_M["admin/mutation.ts"]:::datafetch
            USR_Q["user/query.ts"]:::datafetch
            USR_M["user/mutation.ts"]:::datafetch
        end

        subgraph "Shared Libraries<br/>(libs/)"
            CMP["components/"]:::ui
            AUTH["auth/index.ts"]:::datafetch
            HOOK["hooks/useDeviceDetect.ts"]:::datafetch
            ENM["enums/"]:::datafetch
            TYP["types/"]:::datafetch
            UTIL1["utils.ts"]:::datafetch
            UTIL2["sweetAlert.ts"]:::datafetch
            UTIL3["config.ts"]:::datafetch
        end

        subgraph "Styling (SCSS)"
            GSCSS["app.scss"]:::ui
            MOB["mobile/"]:::ui
            PC["pc/"]:::ui
        end

        subgraph "Static Assets & Locales<br/>(public/)"
            IMG["img/"]:::infra
            VID["video/"]:::infra
            LOC["locales/"]:::infra
        end

        subgraph "Configurations"
            I18N["next-i18next.config.js"]:::infra
            NXCFG["next.config.js"]:::infra
            TSCFG["tsconfig.json"]:::infra
        end

        subgraph "Deployment"
            DC["docker-compose.yml"]:::infra
            DEP["deploy.sh"]:::infra
        end
    end

    %% Data Flow Layer
    UA -->|"HTTP(S) Request"| NX
    NX -->|"Uses Routes"| PGS
    NX -->|"Renders UI Components"| CMP
    NX -->|"Applies Styles"| GSCSS
    NX -->|"Loads Assets/Locales"| IMG
    NX -->|"Loads Assets/Locales"| VID
    NX -->|"Loads Locales"| LOC
    NX -->|"i18n Config"| I18N

    NX -->|"GraphQL Ops"| AC1
    NX -->|"GraphQL Ops"| AC2
    AC1 -->|"admin Q/M"| ADM_Q
    AC1 -->|"admin Q/M"| ADM_M
    AC1 -->|"user Q/M"| USR_Q
    AC1 -->|"user Q/M"| USR_M
    AC1 -->|"Auth Helpers"| AUTH
    AC1 -->|"Hooks"| HOOK
    AC1 -->|"Enums/Types"| ENM
    AC1 -->|"Enums/Types"| TYP
    AC1 -->|"Utils"| UTIL1
    AC1 -->|"Utils"| UTIL2
    AC1 -->|"Utils"| UTIL3

    %% External Services
    AC1 -->|"HTTP POST/GET"| GQLAPI["GraphQL API Service"]:::backend
    GQLAPI -->|"SQL Queries"| DB["Database (PostgreSQL/MySQL)"]:::backend
    AC1 -->|"Auth Validation"| AUTH_SVC["Auth Service (JWT)"]:::backend
    IMG -->|"CDN Storage"| CDN["CDN / Static Storage"]:::infra

    %% Styles
    classDef ui fill:#E8F4FD,stroke:#1E90FF,color:#000;
    classDef datafetch fill:#FEF4E8,stroke:#FFA500,color:#000;
    classDef backend fill:#F8E8E8,stroke:#FF4500,color:#000;
    classDef infra fill:#E8FDE8,stroke:#32CD32,color:#000;

    %% Click Events
    click PGS "https://github.com/joseph-1989/homecareexperts-next/tree/develop/pages/"
    click AC1 "https://github.com/joseph-1989/homecareexperts-next/blob/develop/apollo/client.ts"
    click AC2 "https://github.com/joseph-1989/homecareexperts-next/blob/develop/apollo/store.ts"
    click ADM_Q "https://github.com/joseph-1989/homecareexperts-next/blob/develop/apollo/admin/query.ts"
    click ADM_M "https://github.com/joseph-1989/homecareexperts-next/blob/develop/apollo/admin/mutation.ts"
    click USR_Q "https://github.com/joseph-1989/homecareexperts-next/blob/develop/apollo/user/query.ts"
    click USR_M "https://github.com/joseph-1989/homecareexperts-next/blob/develop/apollo/user/mutation.ts"
    click CMP "https://github.com/joseph-1989/homecareexperts-next/tree/develop/libs/components/"
    click AUTH "https://github.com/joseph-1989/homecareexperts-next/blob/develop/libs/auth/index.ts"
    click HOOK "https://github.com/joseph-1989/homecareexperts-next/blob/develop/libs/hooks/useDeviceDetect.ts"
    click ENM "https://github.com/joseph-1989/homecareexperts-next/tree/develop/libs/enums/"
    click TYP "https://github.com/joseph-1989/homecareexperts-next/tree/develop/libs/types/"
    click UTIL1 "https://github.com/joseph-1989/homecareexperts-next/blob/develop/libs/utils.ts"
    click UTIL2 "https://github.com/joseph-1989/homecareexperts-next/blob/develop/libs/sweetAlert.ts"
    click UTIL3 "https://github.com/joseph-1989/homecareexperts-next/blob/develop/libs/config.ts"
    click GSCSS "https://github.com/joseph-1989/homecareexperts-next/blob/develop/scss/app.scss"
    click MOB "https://github.com/joseph-1989/homecareexperts-next/tree/develop/scss/mobile/"
    click PC "https://github.com/joseph-1989/homecareexperts-next/tree/develop/scss/pc/"
    click IMG "https://github.com/joseph-1989/homecareexperts-next/tree/develop/public/img/"
    click VID "https://github.com/joseph-1989/homecareexperts-next/tree/develop/public/video/"
    click LOC "https://github.com/joseph-1989/homecareexperts-next/tree/develop/public/locales/"
    click I18N "https://github.com/joseph-1989/homecareexperts-next/blob/develop/next-i18next.config.js"
    click NXCFG "https://github.com/joseph-1989/homecareexperts-next/blob/develop/next.config.js"
    click TSCFG "https://github.com/joseph-1989/homecareexperts-next/blob/develop/tsconfig.json"
    click DC "https://github.com/joseph-1989/homecareexperts-next/blob/develop/docker-compose.yml"
    click DEP "https://github.com/joseph-1989/homecareexperts-next/blob/develop/deploy.sh"
```
