# limense/educa-attendance-system architecture

> Architecture diagram of the GitHub repository limense/educa-attendance-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/limense/educa-attendance-system
- Repository: https://github.com/limense/educa-attendance-system

## Overview

##### Project type and purpose
- This is a full-stack Next.js web application for managing employees and attendances, with Supabase as the database and auth provider.
- Features include login/auth, admin and employee dashboards, CRUD operations for employees, attendance tracking, diagnostics, and system settings.

##### File structure
- src/app – Next.js App Router pages and API routes:
- app/api/employee/create/route.ts – backend API endpoint
- app/auth, app/dashboard, app/employees, etc. – page routes
- src/components – reusable React UI components organized by domain (admin, employees, ui)
- src/hooks – custom React hooks encapsulating data fetching and state logic
- src/services – business logic layer (attendance.service, employee.service, auth.service, etc.)
- src/repositories – data access layer (employee.repository)
- src/lib/supabase – Supabase client and server modules for database/auth integration
- database & scripts – SQL files and TS script for setting up/migrating the PostgreSQL database and RLS, Supabase auth integration
- config files – next.config.ts, tailwind.config.js, postcss.config.mjs, ESLint/TSConfig

##### README
- Confirms Next.js project bootstrapped with create-next-app

##### Key advice
- Be very detailed: include each layer and module group
- Authentication flow separately
- Both client-side and server-side database access

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        BROWSER["Browser"]:::external
        NEXT_PAGES["Next.js Frontend Pages & Layout"]:::frontend
        UI_COMPONENTS["UI Components"]:::frontend
        HOOKS["Custom Hooks"]:::business
        SERVICES_C["Services Layer"]:::business
        REPOSITORIES["Repositories Layer"]:::data
        SUPA_CLIENT["Supabase Client SDK"]:::external
    end

    %% Server Side
    subgraph "Server Side"
        API_ROUTES["API Routes"]:::backend
        SUPA_SERVER["Supabase Server SDK"]:::backend
        SUPA_ADMIN["Supabase Admin SDK"]:::backend
        DB_MIGRATIONS["Database Migration & RLS Scripts"]:::infra
        AUTH_SCRIPTS["Auth Integration Scripts & Tests"]:::infra
    end

    %% External Systems
    SUPA_AUTH["Supabase Auth"]:::external
    POSTGRES["PostgreSQL Database"]:::db

    %% Data Flow
    BROWSER -->|"loads pages"| NEXT_PAGES
    NEXT_PAGES -->|"renders UIs"| UI_COMPONENTS
    UI_COMPONENTS -->|"calls hooks"| HOOKS
    HOOKS -->|"invoke services"| SERVICES_C
    SERVICES_C -->|"access data"| REPOSITORIES
    REPOSITORIES -->|"queries via client SDK"| SUPA_CLIENT
    SUPA_CLIENT -->|"reads/writes"| POSTGRES

    NEXT_PAGES -->|"calls endpoints"| API_ROUTES
    API_ROUTES -->|"uses server SDK"| SUPA_SERVER
    SUPA_SERVER -->|"queries"| POSTGRES

    AUTH_SCRIPTS -->|"setup Auth"| SUPA_AUTH
    DB_MIGRATIONS -->|"define RLS/migrations"| POSTGRES
    SUPA_ADMIN -->|"privileged ops"| POSTGRES

    %% Authentication Flow
    BROWSER -->|"user signin/signup"| SUPA_AUTH
    SUPA_AUTH -->|"issues JWT"| BROWSER

    %% Click Events
    click BROWSER "https://github.com/limense/educa-attendance-system/blob/main/src/app/page.tsx"
    click NEXT_PAGES "https://github.com/limense/educa-attendance-system/tree/main/src/app/(layout.tsx, globals.css, homepage.tsx, auth/, dashboard/, employees/, diagnostic/, setup-auth/, test-supabase/, testing/)"
    click API_ROUTES "https://github.com/limense/educa-attendance-system/tree/main/src/app/api"
    click SUPA_SERVER "https://github.com/limense/educa-attendance-system/blob/main/src/lib/supabase/server.ts"
    click SUPA_CLIENT "https://github.com/limense/educa-attendance-system/blob/main/src/lib/supabase/client.ts"
    click SUPA_ADMIN "https://github.com/limense/educa-attendance-system/blob/main/src/lib/supabase/admin.ts"
    click UI_COMPONENTS "https://github.com/limense/educa-attendance-system/tree/main/src/components"
    click HOOKS "https://github.com/limense/educa-attendance-system/tree/main/src/hooks"
    click SERVICES_C "https://github.com/limense/educa-attendance-system/tree/main/src/services"
    click REPOSITORIES "https://github.com/limense/educa-attendance-system/blob/main/src/repositories/employee.repository.ts"
    click DB_MIGRATIONS "https://github.com/limense/educa-attendance-system/tree/main/database/Separados/*"
    click AUTH_SCRIPTS "https://github.com/limense/educa-attendance-system/blob/main/scripts/apply-auth-integration.sql"

    %% Styling
    classDef frontend fill:#D0E8FF,stroke:#3B82F6,color:#1E40AF
    classDef business fill:#DEF7EC,stroke:#10B981,color:#065F46
    classDef data fill:#FEF3C7,stroke:#F59E0B,color:#92400E
    classDef db fill:#EDE9FE,stroke:#8B5CF6,color:#5B21B6
    classDef external fill:#F3F4F6,stroke:#6B7280,color:#374151
    classDef backend fill:#FEE2E2,stroke:#EF4444,color:#991B1B
    classDef infra fill:#E0E7FF,stroke:#6366F1,color:#3730A3
```
