# team-pepe/pepe-constructor- architecture

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

- Interactive diagram: https://gitdiagram.com/team-pepe/pepe-constructor-
- Repository: https://github.com/team-pepe/pepe-constructor-

## Overview

##### Project type and purpose
- This is a full‑stack web application for managing construction works: user/role management, attendance (with geolocation), material requests, work‑zone tasks, and payment/report generation.
- Frontend: React + Vite + Tailwind + Radix UI + Leaflet/Turf.
- Backend: Node.js + Express + Prisma + PostgreSQL + JWT + PDFKit + Chart.js.

##### File structure
- Top‐level directories:
- backend/ — Express server, Prisma schema, migrations, controllers, routes, middleware, config, utilities
- frontend/ — Vite‐powered React app, global styles, UI components, page components, feature modules, services, hooks
- Configuration and build files:
- backend/.env‑example, package.json, prisma/schema.prisma, prisma/migrations
- frontend/.env.example, vite.config.js, tailwind.config.js, package.json
- Patterns:
- Backend follows MVC‑style separation (routes → controllers → utils/config)
- Frontend follows component‑based organization with feature folders, shared UI library, context/hooks

##### README for additional insights
- Modules: User/auth, attendance, materials, work zones/tasks, dashboard/reporting
- Goals: real‑time geolocation, PDF/chart generation, role‑based access, offline sync (future)

##### Detail but keep clarity
- Backend route group mapping to its controller and utility set
- Prisma schema as part of the Data layer, showing entities if desired
- Don’t overpopulate with every file—focus on logical modules and their interactions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["User Browser/Mobile Web"]:::external
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        AppShell["App Shell\n(App.jsx, main.jsx)"]:::frontend
        AuthFeature["Auth Module\n(src/features/auth)"]:::frontend
        AttendanceFeature["Attendance & Geolocation\n(src/components/ui/EmployeeMap,\nuse-mobile.js)"]:::frontend
        MaterialFeature["Material Requests & Inventory\n(AddMaterialDialog, InventoryCard,\nInventoryForm, MaterialRequestForm)"]:::frontend
        WorkZoneFeature["Work Zone Tasks & Material Assignment\n(WorkZoneMap components)"]:::frontend
        DashboardFeature["Dashboard & Reporting\n(src/pages/Dashboard)"]:::frontend
    end

    %% API Layer
    subgraph "Backend API Layer"
        direction TB
        AuthRouter["Auth Routes\n(authRouter.js)"]:::backend
        GeoRouter["Geo Routes\n(geo.js)"]:::backend
        MaterialsRouter["Materials Routes\n(materials.js)"]:::backend
        MaterialAssignRouter["Material Assignment Routes\n(materialAssignments.js)"]:::backend
        DashboardRouter["Dashboard Routes\n(dashboard.js,\ndashboardEmpleados.js)"]:::backend
        Controllers["Controllers\n(authController.js,\ngeoController.js)"]:::backend
        Middleware["Auth Middleware\n(authMiddleware.js)"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Prisma["Prisma ORM\n(schema.prisma)"]:::database
        Postgres["PostgreSQL"]:::database
        Prisma --> Postgres
    end

    %% External Services
    subgraph "External/Utility Services"
        direction TB
        GeoLib["Leaflet/Turf.js"]:::external
        PDFKit["PDFKit"]:::external
        ChartLib["Chart.js/Recharts"]:::external
    end

    %% Connections
    Browser -->|"loads"| AppShell
    AppShell -->|"routes to"| AuthFeature
    AppShell -->|"routes to"| AttendanceFeature
    AppShell -->|"routes to"| MaterialFeature
    AppShell -->|"routes to"| WorkZoneFeature
    AppShell -->|"routes to"| DashboardFeature

    AuthFeature -->|"/auth"| AuthRouter
    AttendanceFeature -->|"/geo"| GeoRouter
    MaterialFeature -->|"/materials"| MaterialsRouter
    MaterialFeature -->|"/materials/assign"| MaterialAssignRouter
    WorkZoneFeature -->|"/materials/assign"| MaterialAssignRouter
    DashboardFeature -->|"/dashboard"| DashboardRouter

    AuthRouter -->|calls| Controllers
    GeoRouter -->|calls| Controllers
    MaterialsRouter -->|calls| Controllers
    MaterialAssignRouter -->|calls| Controllers
    DashboardRouter -->|calls| Controllers

    Controllers -->|verifies JWT| Middleware
    Controllers -->|CRUD| Prisma
    Controllers -->|uses| GeoLib
    Controllers -->|generates PDF| PDFKit
    Controllers -->|renders charts| ChartLib

    %% Click Events
    click AuthFeature "https://github.com/team-pepe/pepe-constructor-/tree/main/frontend/src/features/auth"
    click AppShell "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/app/App.jsx"
    click AppShell "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/main.jsx"
    click AttendanceFeature "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/components/ui/EmployeeMap/EmployeeMap.jsx"
    click AttendanceFeature "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/hooks/use-mobile.js"
    click MaterialFeature "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/components/ui/AddMaterialDialog.jsx"
    click MaterialFeature "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/components/ui/InventoryCard.jsx"
    click MaterialFeature "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/components/ui/InventoryForm.jsx"
    click MaterialFeature "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/components/ui/MaterialRequestForm.jsx"
    click WorkZoneFeature "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/components/ui/WorkZoneMap/WorkZoneMap.jsx"
    click WorkZoneFeature "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/components/ui/WorkZoneMap/MaterialAssignmentModal.jsx"
    click WorkZoneFeature "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/components/ui/WorkZoneMap/UseMaterialsModal.jsx"
    click WorkZoneFeature "https://github.com/team-pepe/pepe-constructor-/blob/main/frontend/src/components/ui/WorkZoneMap/ViewMaterialsModal.jsx"
    click DashboardFeature "https://github.com/team-pepe/pepe-constructor-/tree/main/frontend/src/pages/Dashboard"
    click AuthRouter "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/src/routes/authRouter.js"
    click Controllers "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/src/controllers/authController.js"
    click Middleware "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/src/middleware/authMiddleware.js"
    click GeoRouter "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/src/routes/geo.js"
    click Controllers "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/src/controllers/geoController.js"
    click MaterialsRouter "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/src/routes/materials.js"
    click MaterialAssignRouter "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/src/routes/materialAssignments.js"
    click DashboardRouter "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/src/routes/dashboard.js"
    click DashboardRouter "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/src/routes/dashboardEmpleados.js"
    click Prisma "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/prisma/schema.prisma"
    click Prisma "https://github.com/team-pepe/pepe-constructor-/tree/main/backend/prisma/migrations/"
    click PDFKit "https://github.com/team-pepe/pepe-constructor-/blob/main/backend/src/utils/fileUtils.js"

    %% Styles
    classDef frontend fill:#e3f2fd,stroke:#90caf9,stroke-width:2px
    classDef backend fill:#ffebee,stroke:#e57373,stroke-width:2px
    classDef database fill:#e8f5e9,stroke:#66bb6a,stroke-width:2px
    classDef external fill:#fff3e0,stroke:#ffb74d,stroke-width:2px
```
