# leomssilva/ediaristas architecture

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

- Interactive diagram: https://gitdiagram.com/leomssilva/ediaristas
- Repository: https://github.com/leomssilva/ediaristas

## Overview

##### Project type and purpose
- This is a React/Next.js single-page application (with server-side rendering via Next.js) built in TypeScript.
- Purpose: allow end users to search for and view “diaristas” (cleaning professionals) in their city, displaying user information, search results, and contextual feedback.

##### File structure
- Top-level config and metadata:
- package.json, tsconfig.json, next-env.d.ts
- public/ – static assets (fonts, images)
- Source code under src/:
- src/pages/ – Next.js routing (SSR pages, _app.tsx wrapper, index.tsx)
- src/data/ – data/types/hooks/services
– @types/UserInterface.ts – data models
– hooks/pages/useIndex.ts – custom hook for index page data fetching
– services/ApiService.ts – HTTP client abstraction (Axios)
– services/ValidationService.ts – business-rule validation
- src/ui/ – presentational layer
– components/ – component library organized by concern:
· data-display (PageTitle, UserInformation)
· feedback (SafeEnvironment)
· inputs (TextField, TextFieldMask)
· surfaces (Header, Footer)
– styles/ – global CSS, per-page styles, theme definitions (theme.ts)

##### README for additional insights
- Confirms tech stack: Next.js, React, TypeScript, Material-UI, react-input-mask, Axios.

##### Main components
a. Client Layer (Browser)
– Renders UI, executes React code, either CSR or SSR from Next.js.
b. Next.js Server / Runtime
– Provides SSR entrypoint via pages/_app.tsx and pages/index.tsx.
c. Data Layer
– React hooks under src/data/hooks -> controls data fetching & state.
d. Service Layer
– ApiService (wraps Axios) calls external REST API to fetch diaristas and user info.
– ValidationService handles front-end validations.
e. UI Layer
– Atomic/presentational components (TextField, PageTitle, Header, Footer, etc.)
– Styles (CSS modules, theme)
f. External Services
– Third-party API endpoint (hosted separately) that returns diarista data.
g. Static Assets
– Fonts and images served from public/

##### Relationships and interactions
- User (Browser) ➔ navigates to Next.js page (index.tsx)
- Next.js SSR/runtime loads the page ➔ invokes custom hook useIndex
- useIndex ➔ calls ApiService.fetch(...) ➔ sends HTTP request to External API
- External API ➔ returns JSON ➔ ApiService resolves promise ➔ hook updates state
- index.tsx ➔ passes data to UI components (UserInformation, PageTitle, SafeEnvironment, etc.)
- UI components read theme & styles, render DOM
- Browser displays final UI; user interactions (e.g., form input) ➔ ValidationService on input events
- Static assets (fonts, images) loaded by Browser from public/

##### Architectural patterns and design principles
- Layered architecture: separation of concerns between UI, data, and services
- Component-based UI driven by React/Material-UI
- Custom React hooks for data orchestration
- Service abstraction (ApiService) decouples HTTP details from UI logic
- File organization follows feature grouping and Next.js conventions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Browser (Client)"]:::external

    %% Next.js Server / Runtime
    subgraph "Next.js Server / Runtime"
        _app["_app.tsx"]:::data
        PageIndex["index.tsx"]:::data
    end

    %% Data Layer
    subgraph "Data Layer (React Hooks)"
        useIndex["useIndex.ts"]:::data
    end

    %% Service Layer
    subgraph "Service Layer"
        ApiService["ApiService.ts"]:::service
        ValidationService["ValidationService.ts"]:::service
    end

    %% UI Layer
    subgraph "UI Layer (Presentational Components)"
        subgraph "Data Display"
            PageTitle["PageTitle"]:::ui
            UserInformation["UserInformation"]:::ui
        end
        subgraph "Feedback"
            SafeEnvironment["SafeEnvironment"]:::ui
        end
        subgraph "Inputs"
            TextField["TextField"]:::ui
            TextFieldMask["TextFieldMask"]:::ui
        end
        subgraph "Surfaces"
            Header["Header"]:::ui
            Footer["Footer"]:::ui
        end
    end

    %% Styles & Theme
    subgraph "Styles & Theme"
        Globals["globals.css"]:::service
        AppStyle["_app style.tsx"]:::service
        IndexStyle["index style.tsx"]:::service
        Theme["theme.ts"]:::service
    end

    %% Static Assets
    PublicAssets["public/"]:::external

    %% External API
    ExternalAPI[(External API)]:::external

    %% Connections
    Browser -->|"navigate()"| PageIndex
    _app -->|"wraps page"| PageIndex
    PageIndex -->|"useIndex()"| useIndex
    useIndex -->|"fetchDiaristas()"| ApiService
    ApiService -->|"GET /diaristas?city=..."| ExternalAPI
    ExternalAPI -->|"JSON data"| ApiService
    ApiService -->|"Promise resolves"| useIndex
    useIndex -->|"data props"| PageIndex
    PageIndex -->|"props"| PageTitle
    PageIndex -->|"props"| UserInformation
    PageIndex -->|"props"| SafeEnvironment
    PageIndex -->|"props"| TextField
    PageIndex -->|"props"| TextFieldMask
    PageIndex -->|"props"| Header
    PageIndex -->|"props"| Footer
    TextField -->|"validateInput()"| ValidationService
    TextFieldMask -->|"validateInput()"| ValidationService
    Theme -->|"applies"| PageTitle
    Theme -->|"applies"| UserInformation
    Theme -->|"applies"| SafeEnvironment
    Theme -->|"applies"| TextField
    Theme -->|"applies"| TextFieldMask
    Theme -->|"applies"| Header
    Theme -->|"applies"| Footer
    Globals -->|"global CSS"| Browser
    AppStyle -->|"page styles"| PageIndex
    IndexStyle -->|"page styles"| PageIndex
    Browser -->|"load fonts/images"| PublicAssets

    %% Click Events
    click _app "https://github.com/leomssilva/ediaristas/blob/main/src/pages/_app.tsx"
    click PageIndex "https://github.com/leomssilva/ediaristas/blob/main/src/pages/index.tsx"
    click useIndex "https://github.com/leomssilva/ediaristas/blob/main/src/data/hooks/pages/useIndex.ts"
    click ApiService "https://github.com/leomssilva/ediaristas/blob/main/src/data/services/ApiService.ts"
    click ValidationService "https://github.com/leomssilva/ediaristas/blob/main/src/data/services/ValidationService.ts"
    click PageTitle "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/data-display/PageTitle/index.tsx"
    click PageTitle "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/data-display/PageTitle/style.tsx"
    click UserInformation "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/data-display/UserInformation/index.tsx"
    click UserInformation "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/data-display/UserInformation/style.tsx"
    click SafeEnvironment "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/feedback/SafeEnvironment/index.tsx"
    click SafeEnvironment "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/feedback/SafeEnvironment/style.tsx"
    click TextField "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/inputs/TextField/index.tsx"
    click TextField "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/inputs/TextField/style.tsx"
    click TextFieldMask "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/inputs/TextFieldMask/index.tsx"
    click TextFieldMask "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/inputs/TextFieldMask/style.tsx"
    click Header "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/surfaces/Header/index.tsx"
    click Header "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/surfaces/Header/style.tsx"
    click Footer "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/surfaces/Footer/index.tsx"
    click Footer "https://github.com/leomssilva/ediaristas/blob/main/src/ui/components/surfaces/Footer/style.tsx"
    click Globals "https://github.com/leomssilva/ediaristas/blob/main/src/ui/styles/globals.css"
    click AppStyle "https://github.com/leomssilva/ediaristas/blob/main/src/ui/styles/pages/_app/style.tsx"
    click IndexStyle "https://github.com/leomssilva/ediaristas/blob/main/src/ui/styles/pages/index/style.tsx"
    click Theme "https://github.com/leomssilva/ediaristas/blob/main/src/ui/themes/theme.ts"
    click PublicAssets "https://github.com/leomssilva/ediaristas/tree/main/public/"
    click PublicAssets "https://github.com/leomssilva/ediaristas/blob/main/public/fonts/tw-icons/css/treinaweb-icons.css"
    click PublicAssets "https://github.com/leomssilva/ediaristas/tree/main/public/img/home"
    click PublicAssets "https://github.com/leomssilva/ediaristas/tree/main/public/img/logos"

    %% Styles
    classDef ui fill:#AEDFF7,stroke:#333,stroke-width:1px
    classDef data fill:#A1E49E,stroke:#333,stroke-width:1px
    classDef service fill:#F5B26B,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
