# sebas99032/lerm-antropometria-portal architecture

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

- Interactive diagram: https://gitdiagram.com/sebas99032/lerm-antropometria-portal
- Repository: https://github.com/sebas99032/lerm-antropometria-portal

## Overview

##### Project type and purpose
- This is a single-page web application (SPA) built with React and TypeScript.
- It serves as a role-based dashboard and form-submission tool (Admin, Assistant, Evaluator, Public) that interacts with an external API for authentication, data retrieval, and form storage.
- The app uses shadcn-ui (a Radix-based component library) and Tailwind CSS for styling, bundled by Vite.

##### File structure
- Top-level entries:
- package.json / bun.lockb / lock files – Node dependency management and lock versions
- vite.config.ts / tsconfig*.json / tailwind.config.ts – build, TypeScript, and CSS config
- public/index.html – HTML entry point and static assets (robots.txt)
- src/ contains everything in the running app:
- main.tsx & index.css – SPA entry point and global styles
- components/ – shared UI and layout components, including ProtectedRoute and Header
- components/ui/ – shadcn-ui wrappers for low-level UI primitives (buttons, dialogs, forms, etc.)
- contexts/AuthContext.tsx – holds user state & token, protects routes
- hooks/ – custom React hooks (mobile detection, toasts)
- lib/ – pure-TS modules (mockData, utils)
- pages/ – route/page components (dashboards, forms, login, 404)

##### README for additional insights
- It confirms the tech stack: Vite, TypeScript, React, shadcn-ui, Tailwind CSS.
- Deployment is handled through the Lovable platform; no in-repo backend.
- Development uses npm scripts: `npm run dev`, `npm run build`.

a. Main components
- Browser / User Agent (Chrome, Safari, etc.)
- React SPA (App shell)
- UI Component Library (shadcn-ui + Tailwind CSS)
- State Management & Routing (React Context + React Router via ProtectedRoute)
- Data Layer / API Client (fetch or axios calls in utils/hooks)
- External Services:
- Authentication/API server (hosted outside the repo via Lovable or custom backend)
- Analytics / Logging (optional)
- Build & Deployment Pipeline (Vite dev server, Node.js/npm, Lovable publish)

b. Relationships & data flow
1. User loads index.html → Vite dev server / static hosting → serves compiled JS/CSS
2. App initializes: main.tsx renders App.tsx, sets up AuthContext and Router
3. User navigates to a page → ProtectedRoute checks AuthContext → either redirects to Login or renders page component
4. Page components dispatch API calls (via utils or custom hooks) → requests go over HTTP to external API
5. Responses update Context or component state → UI components re-render with new data
6. User actions may trigger client-side state changes (toasts, local UI updates) before/after API calls

c. Architectural patterns & principles
- Component-based UI (React + shadcn-ui)
- Separation of concerns: UI components vs page/route logic vs data fetching vs state context
- Single Source of Truth for auth state via React Context
- Custom hooks for cross-cutting concerns (toasts, device detection)
- Unidirectional data flow (React state → props → UI)

d. Key technologies/frameworks
- React + TypeScript
- Vite (bundler, dev server)
- Tailwind CSS + shadcn-ui for styling and prebuilt components
- React Router (via ProtectedRoute) for client-side routing
- Node.js / npm for local development and build tasks
- Lovable platform for CI/CD and hosting

##### Detail without over-complication
- Logical tier (UI, routing, state, data access, external API).
- Where custom code lives (contexts, hooks, lib) vs. off-the-shelf frameworks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Actors
    User(["User"]):::actor
    Browser(["Browser"]):::frontend

    %% Build & Deployment
    subgraph "Build & Deployment"
        Package["package.json / lock files"]:::infra
        Vite["vite.config.ts"]:::infra
        TSConfig["tsconfig*.json"]:::infra
        Lovable["Lovable Platform"]:::infra
    end

    %% Static Hosting
    StaticHost["Static Host (Vite Dev Server / CDN)"]:::infra

    %% Client Runtime
    subgraph "React SPA"
        Main["main.tsx → App.tsx"]:::frontend

        subgraph "UI Component Library"
            shadcn["shadcn-ui Components"]:::ui
            Tailwind["Tailwind CSS"]:::ui
        end

        subgraph "Layout & Routing"
            Header["Header"]:::frontend
            ProtectedRoute["ProtectedRoute"]:::frontend
        end

        AuthContext["AuthContext"]:::frontend

        subgraph "Custom Hooks"
            useMobile["use-mobile"]:::data
            useToast["use-toast"]:::data
        end

        subgraph "Data Layer / API Utilities"
            Utils["utils.ts"]:::data
            MockData["mockData.ts"]:::data
        end

        subgraph "Pages / Routes"
            Login["Login"]:::frontend
            IndexPage["Index"]:::frontend
            AdminDash["AdminDashboard"]:::frontend
            AssistantDash["AssistantDashboard"]:::frontend
            EvaluatorDash["EvaluatorDashboard"]:::frontend
            EvaluatedList["EvaluatedList"]:::frontend
            AnthroForm["AnthropometryForm"]:::frontend
            PublicForm["PublicForm"]:::frontend
            NotFound["NotFound"]:::frontend
        end
    end

    %% External API
    API["External API Server"]:::external

    %% Flows
    User --> Browser
    Browser -->|loads index.html| StaticHost
    StaticHost -->|serves HTML/CSS/JS| Browser
    Browser --> ReactApp[/"React SPA Runtime"/]:::frontend
    ReactApp --> Main

    Main --> shadcn
    Main --> Tailwind
    Main --> Header
    Main --> ProtectedRoute
    Main --> AuthContext
    Main --> useMobile
    Main --> useToast
    Main --> Utils
    Main --> MockData
    Main --> Login
    Main --> IndexPage
    Main --> AdminDash
    Main --> AssistantDash
    Main --> EvaluatorDash
    Main --> EvaluatedList
    Main --> AnthroForm
    Main --> PublicForm
    Main --> NotFound

    ProtectedRoute --> AuthContext
    Login --> Utils
    IndexPage --> Utils
    AdminDash --> Utils
    AssistantDash --> Utils
    EvaluatorDash --> Utils
    EvaluatedList --> Utils
    AnthroForm --> Utils
    PublicForm --> Utils

    Utils -->|HTTP calls| API
    AuthContext -->|auth requests| API
    API -->|responses| Utils
    API -->|auth state| AuthContext

    Package --> Vite
    Package --> TSConfig
    Package --> StaticHost
    StaticHost --> Lovable

    %% Click Events
    click Main "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/main.tsx"
    click Main "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/App.tsx"
    click shadcn "https://github.com/sebas99032/lerm-antropometria-portal/tree/main/src/components/ui/"
    click Tailwind "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/tailwind.config.ts"
    click Header "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/components/Header.tsx"
    click ProtectedRoute "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/components/ProtectedRoute.tsx"
    click AuthContext "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/contexts/AuthContext.tsx"
    click useMobile "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/hooks/use-mobile.tsx"
    click useToast "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/hooks/use-toast.ts"
    click Utils "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/lib/utils.ts"
    click MockData "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/lib/mockData.ts"
    click Login "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/pages/Login.tsx"
    click IndexPage "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/pages/Index.tsx"
    click AdminDash "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/pages/AdminDashboard.tsx"
    click AssistantDash "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/pages/AssistantDashboard.tsx"
    click EvaluatorDash "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/pages/EvaluatorDashboard.tsx"
    click EvaluatedList "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/pages/EvaluatedList.tsx"
    click AnthroForm "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/pages/AnthropometryForm.tsx"
    click PublicForm "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/pages/PublicForm.tsx"
    click NotFound "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/pages/NotFound.tsx"
    click StaticHost "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/public/index.html"
    click StaticHost "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/src/index.css"
    click Vite "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/vite.config.ts"
    click TSConfig "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/tsconfig.json"
    click Package "https://github.com/sebas99032/lerm-antropometria-portal/blob/main/package.json"

    %% Styles
    classDef actor fill:#f9f,stroke:#333,stroke-width:1px
    classDef frontend fill:#bbdefb,stroke:#036,stroke-width:1px
    classDef ui fill:#c8e6c9,stroke:#2e7d32,stroke-width:1px
    classDef data fill:#ffe0b2,stroke:#e65100,stroke-width:1px
    classDef infra fill:#e0e0e0,stroke:#424242,stroke-width:1px
    classDef external fill:#ffcdd2,stroke:#b71c1c,stroke-width:1px
```
