# mazfreelance/attendance-system architecture

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

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

## Overview

This repository combines a Laravel API backend with a Next.js dashboard frontend. The evident user workflow is signing in through the frontend, sending authenticated API requests, and receiving user/session data; the backend validates credentials and issues or revokes Sanctum tokens. The tree also shows dashboard, profile, and admin screens, plus role middleware and user role checks. Their detailed routing and data flows are not established by the excerpts, so those links are omitted. The README describes Laravel generally, not additional application-specific capabilities.

Main entry points: [`bootstrap/app.php`](https://github.com/mazfreelance/attendance-system/blob/main/bootstrap/app.php) (Application bootstrap), [`frontend/lib/api.ts`](https://github.com/mazfreelance/attendance-system/blob/main/frontend/lib/api.ts) (API client), [`routes/api.php`](https://github.com/mazfreelance/attendance-system/blob/main/routes/api.php) (API routes), [`app/Http/Controllers/Api/AuthController.php`](https://github.com/mazfreelance/attendance-system/blob/main/app/Http/Controllers/Api/AuthController.php) (Auth controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_login["Login screen<br/>[page.tsx]"]
  node_dashboard["Dashboard screens<br/>[page.tsx]"]
  node_admin["Admin screen<br/>[page.tsx]"]
  node_profile["Profile screen<br/>[page.tsx]"]
  node_auth_context["Auth context<br/>[AuthContext.tsx]"]
  node_auth_service["Auth service<br/>[auth.ts]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_backend["Backend API"]
  node_api_routes["API routes<br/>[api.php]"]
  node_auth_controller["Auth controller<br/>[AuthController.php]"]
  node_app_bootstrap["Application bootstrap<br/>[app.php]"]
  node_http_entry["HTTP entry point<br/>[index.php]"]
end

subgraph group_identity["Identity and access"]
  node_user_model["User model<br/>[User.php]"]
  node_role_middleware["Role middleware"]
end

node_user(("User"))

node_user -.->|"uses"| node_login
node_auth_service -->|"sends requests"| node_api_client
node_api_client -->|"stores token"| node_user
node_api_routes -->|"routes to"| node_auth_controller
node_auth_controller -->|"queries and issues tokens"| node_user_model
node_http_entry -->|"loads"| node_app_bootstrap
node_app_bootstrap -->|"registers"| node_api_routes
node_app_bootstrap -->|"aliases"| node_role_middleware

click node_login "https://github.com/mazfreelance/attendance-system/blob/main/frontend/app/login/page.tsx"
click node_dashboard "https://github.com/mazfreelance/attendance-system/blob/main/frontend/app/dashboard/page.tsx"
click node_admin "https://github.com/mazfreelance/attendance-system/blob/main/frontend/app/dashboard/admin/page.tsx"
click node_profile "https://github.com/mazfreelance/attendance-system/blob/main/frontend/app/dashboard/profile/page.tsx"
click node_auth_context "https://github.com/mazfreelance/attendance-system/blob/main/frontend/contexts/AuthContext.tsx"
click node_auth_service "https://github.com/mazfreelance/attendance-system/blob/main/frontend/lib/auth.ts"
click node_api_client "https://github.com/mazfreelance/attendance-system/blob/main/frontend/lib/api.ts"
click node_api_routes "https://github.com/mazfreelance/attendance-system/blob/main/routes/api.php"
click node_auth_controller "https://github.com/mazfreelance/attendance-system/blob/main/app/Http/Controllers/Api/AuthController.php"
click node_user_model "https://github.com/mazfreelance/attendance-system/blob/main/app/Models/User.php"
click node_role_middleware "https://github.com/mazfreelance/attendance-system/blob/main/app/Http/Middleware/EnsureUserHasRole.php"
click node_app_bootstrap "https://github.com/mazfreelance/attendance-system/blob/main/bootstrap/app.php"
click node_http_entry "https://github.com/mazfreelance/attendance-system/blob/main/public/index.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_login,node_dashboard,node_admin,node_profile,node_auth_context,node_auth_service,node_api_client,node_user toneBlue
class node_api_routes,node_auth_controller,node_app_bootstrap,node_http_entry toneAmber
class node_user_model,node_role_middleware toneMint
```

## Components

### Frontend

- [Login screen](https://github.com/mazfreelance/attendance-system/blob/main/frontend/app/login/page.tsx): `frontend/app/login/page.tsx`
- [Dashboard screens](https://github.com/mazfreelance/attendance-system/blob/main/frontend/app/dashboard/page.tsx): `frontend/app/dashboard/page.tsx`
- [Admin screen](https://github.com/mazfreelance/attendance-system/blob/main/frontend/app/dashboard/admin/page.tsx): `frontend/app/dashboard/admin/page.tsx`
- [Profile screen](https://github.com/mazfreelance/attendance-system/blob/main/frontend/app/dashboard/profile/page.tsx): `frontend/app/dashboard/profile/page.tsx`
- [Auth context](https://github.com/mazfreelance/attendance-system/blob/main/frontend/contexts/AuthContext.tsx): `frontend/contexts/AuthContext.tsx`
- [Auth service](https://github.com/mazfreelance/attendance-system/blob/main/frontend/lib/auth.ts): `frontend/lib/auth.ts`
- [API client](https://github.com/mazfreelance/attendance-system/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`

### Backend API

- [API routes](https://github.com/mazfreelance/attendance-system/blob/main/routes/api.php): `routes/api.php`
- [Auth controller](https://github.com/mazfreelance/attendance-system/blob/main/app/Http/Controllers/Api/AuthController.php): `app/Http/Controllers/Api/AuthController.php`
- [Application bootstrap](https://github.com/mazfreelance/attendance-system/blob/main/bootstrap/app.php): `bootstrap/app.php`
- [HTTP entry point](https://github.com/mazfreelance/attendance-system/blob/main/public/index.php): `public/index.php`

### Identity and access

- [User model](https://github.com/mazfreelance/attendance-system/blob/main/app/Models/User.php): `app/Models/User.php`
- [Role middleware](https://github.com/mazfreelance/attendance-system/blob/main/app/Http/Middleware/EnsureUserHasRole.php): `app/Http/Middleware/EnsureUserHasRole.php`

### Other components

- **User**

## Connections

- User → Login screen: uses
- Auth service → API client: sends requests (evidence: `frontend/lib/auth.ts`)
- API client → User: stores token (evidence: `frontend/lib/api.ts`)
- API routes → Auth controller: routes to (evidence: `routes/api.php`)
- Auth controller → User model: queries and issues tokens (evidence: `app/Http/Controllers/Api/AuthController.php`)
- HTTP entry point → Application bootstrap: loads (evidence: `public/index.php`)
- Application bootstrap → API routes: registers (evidence: `bootstrap/app.php`)
- Application bootstrap → Role middleware: aliases (evidence: `bootstrap/app.php`)
