# trbureiyan/devurityweb architecture

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

- Interactive diagram: https://gitdiagram.com/trbureiyan/devurityweb
- Repository: https://github.com/trbureiyan/devurityweb

## Overview

#### Purpose and entry points
DevurityWeb is a single Next.js platform for Devurity’s public presence and internal member operations: projects, content updates, profiles, membership administration, and QR attendance. App Router pages begin at `app/page.tsx`; global composition is in `app/layout.tsx`; request-wide authorization starts in `middleware.ts`.

#### Presentation and route boundary
Server-rendered public routes cover institutional content, projects, updates, gallery, and auth. Protected routes group internal role-specific areas: admin, content manager, project leader, and profile pages.
- `app/projects/page.tsx`
- `app/updates/[slug]/page.tsx`
- `app/(protected)/admin/layout.tsx`
- `app/(protected)/profile/[id]/page.tsx`

Client components provide interactive page behavior while routes remain the primary SSR/SEO boundary.
- `components/projects/ProjectsPageClient.tsx`
- `components/updates/UpdatesPageClient.tsx`
- `components/admin/AdminDashboardClient.tsx`

#### Authentication, authorization, and request security
Custom JWT authentication is verified in edge-compatible code; middleware applies RBAC before protected pages are reached. Auth route handlers implement login, refresh, registration approval/token flow, profile access, and password recovery. State is exposed to the UI through an auth context/hooks layer.
- `middleware.ts`
- `lib/auth/middleware.ts`
- `lib/auth/jwt-edge.ts`
- `app/api/auth/login/route.ts`
- `contexts/AuthContext.tsx`

Mutating flows are protected by double-submit CSRF, while login attempts are rate limited. ALTCHA challenge handling protects applicable public interactions.
- `lib/csrf.ts`
- `lib/rateLimit.ts`
- `app/api/altcha/challenge/route.ts`

#### API and business operations
Route handlers under `app/api` are the server boundary for browser mutations and client-driven reads. Domains include users/admin, projects, skills, updates, attendance, QR issuance, and contact.
- `app/api/admin/users/[id]/role/route.ts`
- `app/api/projects/[id]/route.ts`
- `app/api/asistencia/route.ts`
- `app/api/qr-dinamico/route.ts`

The attendance flow generates dynamic QR data, accepts attendance submissions, and supports administrative review/export.
- `app/api/qr-dinamico/route.ts`
- `app/api/asistencia/route.ts`
- `app/api/admin/attendances/export/route.ts`

#### Data-access architecture
Server Components and handlers consume domain data modules, which delegate persistence to repositories; repositories isolate Prisma/PostgreSQL access. This is the principal data boundary and keeps database queries out of UI and API orchestration.
- `lib/data/projects.ts`
- `lib/data/updates.ts`
- `repositories/projects/projects.repositories.ts`
- `repositories/users/users.repositories.ts`
- `lib/postgresDriver.ts`

Public data can be cached through Next server caching/tag mechanisms.
- `lib/cache-tags.ts`
- `lib/data/landing.ts`

#### Persistence, deployment, and integrations
PostgreSQL is modeled with Prisma, including seeded reference/domain data for roles, programs, skills, projects, and updates.
- `prisma/schema.prisma`
- `prisma/seed.ts`
- `prisma/seeders/01-roles.ts`

The runtime is Next.js 15/React 19 with TypeScript, deployed for Vercel serverless execution and edge middleware. Email-backed recovery and operational notifications are abstracted behind:
- `lib/email.ts`
- `vercel.json`

Main entry points: [`app/api/projects/[id]/route.ts`](https://github.com/trbureiyan/devurityweb/blob/main/app/api/projects/%5Bid%5D/route.ts) (API route handlers), [`lib/data/projects.ts`](https://github.com/trbureiyan/devurityweb/blob/main/lib/data/projects.ts) (Domain data modules), [`app/page.tsx`](https://github.com/trbureiyan/devurityweb/blob/main/app/page.tsx) (App Router pages), [`components/projects/ProjectsPageClient.tsx`](https://github.com/trbureiyan/devurityweb/blob/main/components/projects/ProjectsPageClient.tsx) (Client page components)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Next.js web app"]
  node_pages["App Router pages<br/>SSR route layer<br/>[page.tsx]"]
  node_protected_layout["Protected layouts<br/>role route boundary<br/>[layout.tsx]"]
  node_interactive_ui["Client page components<br/>React client UI"]
  node_auth_context["Auth context<br/>client auth state<br/>[AuthContext.tsx]"]
end

subgraph group_security["Identity &amp; security"]
  node_middleware{{"Request middleware<br/>RBAC gateway<br/>[middleware.ts]"}}
  node_edge_auth["Edge JWT auth<br/>auth verification<br/>[jwt-edge.ts]"]
  node_auth_api["Auth handlers<br/>authentication API<br/>[route.ts]"]
  node_request_protection["CSRF, rate limit &amp; ALTCHA<br/>mutation protection<br/>[csrf.ts]"]
end

subgraph group_server["Server operations"]
  node_api["API route handlers<br/>browser server boundary<br/>[route.ts]"]
  node_attendance["QR attendance flow<br/>attendance operations<br/>[route.ts]"]
  node_email["Email service<br/>notification adapter<br/>[email.ts]"]
end

subgraph group_data["Data &amp; persistence"]
  node_data_modules["Domain data modules<br/>data service layer<br/>[projects.ts]"]
  node_cache["Server cache tags<br/>Next cache layer<br/>[cache-tags.ts]"]
  node_repositories["Repositories<br/>persistence abstraction"]
  node_prisma["Prisma data model<br/>ORM schema<br/>[schema.prisma]"]
  node_postgres[("PostgreSQL<br/>primary database<br/>[postgresDriver.ts]")]
end

node_vercel{{"Vercel runtime<br/>serverless deployment<br/>[vercel.json]"}}

node_vercel -->|"edge execution"| node_middleware
node_middleware -->|"verifies JWT"| node_edge_auth
node_middleware -->|"permits roles"| node_protected_layout
node_pages -->|"protected routes"| node_protected_layout
node_pages -->|"hydrates"| node_interactive_ui
node_interactive_ui -->|"reads session"| node_auth_context
node_interactive_ui -->|"client reads &amp; mutations"| node_api
node_auth_context -->|"login &amp; refresh"| node_auth_api
node_auth_api -->|"rate limited"| node_request_protection
node_api -->|"protects mutations"| node_request_protection
node_api -->|"attendance endpoints"| node_attendance
node_pages -->|"server reads"| node_data_modules
node_api -->|"domain operations"| node_data_modules
node_data_modules -.->|"tagged public data"| node_cache
node_data_modules -->|"persists through"| node_repositories
node_repositories -->|"queries via"| node_prisma
node_prisma -->|"models"| node_postgres
node_auth_api -->|"recovery notifications"| node_email
node_attendance -->|"records &amp; exports"| node_repositories

click node_middleware "https://github.com/trbureiyan/devurityweb/blob/main/middleware.ts"
click node_edge_auth "https://github.com/trbureiyan/devurityweb/blob/main/lib/auth/jwt-edge.ts"
click node_pages "https://github.com/trbureiyan/devurityweb/blob/main/app/page.tsx"
click node_protected_layout "https://github.com/trbureiyan/devurityweb/blob/main/app/(protected)/admin/layout.tsx"
click node_interactive_ui "https://github.com/trbureiyan/devurityweb/blob/main/components/projects/ProjectsPageClient.tsx"
click node_auth_context "https://github.com/trbureiyan/devurityweb/blob/main/contexts/AuthContext.tsx"
click node_api "https://github.com/trbureiyan/devurityweb/blob/main/app/api/projects/%5Bid%5D/route.ts"
click node_auth_api "https://github.com/trbureiyan/devurityweb/blob/main/app/api/auth/login/route.ts"
click node_request_protection "https://github.com/trbureiyan/devurityweb/blob/main/lib/csrf.ts"
click node_attendance "https://github.com/trbureiyan/devurityweb/blob/main/app/api/qr-dinamico/route.ts"
click node_data_modules "https://github.com/trbureiyan/devurityweb/blob/main/lib/data/projects.ts"
click node_cache "https://github.com/trbureiyan/devurityweb/blob/main/lib/cache-tags.ts"
click node_repositories "https://github.com/trbureiyan/devurityweb/blob/main/repositories/projects/projects.repositories.ts"
click node_prisma "https://github.com/trbureiyan/devurityweb/blob/main/prisma/schema.prisma"
click node_postgres "https://github.com/trbureiyan/devurityweb/blob/main/lib/postgresDriver.ts"
click node_email "https://github.com/trbureiyan/devurityweb/blob/main/lib/email.ts"
click node_vercel "https://github.com/trbureiyan/devurityweb/blob/main/vercel.json"

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_pages,node_protected_layout,node_interactive_ui,node_auth_context toneBlue
class node_middleware,node_edge_auth,node_auth_api,node_request_protection toneAmber
class node_api,node_attendance,node_email toneMint
class node_data_modules,node_cache,node_repositories,node_prisma,node_postgres toneRose
class node_vercel toneNeutral
```

## Components

### Next.js web app

- [App Router pages](https://github.com/trbureiyan/devurityweb/blob/main/app/page.tsx): SSR route layer · Public and protected SEO-facing routes. · `app/page.tsx`
- [Protected layouts](https://github.com/trbureiyan/devurityweb/blob/main/app/(protected)/admin/layout.tsx): role route boundary · `app/(protected)/admin/layout.tsx`
- [Client page components](https://github.com/trbureiyan/devurityweb/blob/main/components/projects/ProjectsPageClient.tsx): React client UI · `components/projects/ProjectsPageClient.tsx`
- [Auth context](https://github.com/trbureiyan/devurityweb/blob/main/contexts/AuthContext.tsx): client auth state · `contexts/AuthContext.tsx`

### Identity & security

- [Request middleware](https://github.com/trbureiyan/devurityweb/blob/main/middleware.ts): RBAC gateway · Guards protected requests before pages load. · `middleware.ts`
- [Edge JWT auth](https://github.com/trbureiyan/devurityweb/blob/main/lib/auth/jwt-edge.ts): auth verification · `lib/auth/jwt-edge.ts`
- [Auth handlers](https://github.com/trbureiyan/devurityweb/blob/main/app/api/auth/login/route.ts): authentication API · Implements login, refresh, approval, profiles, and recovery. · `app/api/auth/login/route.ts`
- [CSRF, rate limit & ALTCHA](https://github.com/trbureiyan/devurityweb/blob/main/lib/csrf.ts): mutation protection · `lib/csrf.ts`

### Server operations

- [API route handlers](https://github.com/trbureiyan/devurityweb/blob/main/app/api/projects/%5Bid%5D/route.ts): browser server boundary · Serves auth, admin, projects, updates, attendance, QR, and contact operations. · `app/api/projects/[id]/route.ts`
- [QR attendance flow](https://github.com/trbureiyan/devurityweb/blob/main/app/api/qr-dinamico/route.ts): attendance operations · Issues dynamic QR data and records attendance. · `app/api/qr-dinamico/route.ts`
- [Email service](https://github.com/trbureiyan/devurityweb/blob/main/lib/email.ts): notification adapter · Supports password recovery and operational notifications. · `lib/email.ts`

### Data & persistence

- [Domain data modules](https://github.com/trbureiyan/devurityweb/blob/main/lib/data/projects.ts): data service layer · Shared server reads for pages and handlers. · `lib/data/projects.ts`
- [Server cache tags](https://github.com/trbureiyan/devurityweb/blob/main/lib/cache-tags.ts): Next cache layer · `lib/cache-tags.ts`
- [Repositories](https://github.com/trbureiyan/devurityweb/blob/main/repositories/projects/projects.repositories.ts): persistence abstraction · Isolates database access from UI and API orchestration. · `repositories/projects/projects.repositories.ts`
- [Prisma data model](https://github.com/trbureiyan/devurityweb/blob/main/prisma/schema.prisma): ORM schema · `prisma/schema.prisma`
- [PostgreSQL](https://github.com/trbureiyan/devurityweb/blob/main/lib/postgresDriver.ts): primary database · `lib/postgresDriver.ts`

### Other components

- [Vercel runtime](https://github.com/trbureiyan/devurityweb/blob/main/vercel.json): serverless deployment · Runs Next.js serverless handlers and edge middleware. · `vercel.json`

## Connections

- Vercel runtime → Request middleware: edge execution
- Request middleware → Edge JWT auth: verifies JWT
- Request middleware → Protected layouts: permits roles
- App Router pages → Protected layouts: protected routes
- App Router pages → Client page components: hydrates
- Client page components → Auth context: reads session
- Client page components → API route handlers: client reads & mutations
- Auth context → Auth handlers: login & refresh
- Auth handlers → CSRF, rate limit & ALTCHA: rate limited
- API route handlers → CSRF, rate limit & ALTCHA: protects mutations
- API route handlers → QR attendance flow: attendance endpoints
- App Router pages → Domain data modules: server reads
- API route handlers → Domain data modules: domain operations
- Domain data modules → Server cache tags: tagged public data
- Domain data modules → Repositories: persists through
- Repositories → Prisma data model: queries via
- Prisma data model → PostgreSQL: models
- Auth handlers → Email service: recovery notifications
- QR attendance flow → Repositories: records & exports
