# akoclantoy/yayay architecture

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

- Interactive diagram: https://gitdiagram.com/akoclantoy/yayay
- Repository: https://github.com/akoclantoy/yayay

## Overview

EcoRewards is a community recycling rewards platform. Residents register, identify themselves with a QR card, earn points from recorded recycling, and spend points on rewards; staff scan and record collections, while administrators manage users, catalogs, and program operations. The graph includes the documented pickup, AI, and engagement capabilities. Some portal-to-API connections are described only at the product level in the README; those links use that documentation rather than implying unsampled implementation details.

Main entry points: [`src/lib/db.ts`](https://github.com/akoclantoy/yayay/blob/main/src/lib/db.ts) (Application database), [`src/app/api/rewards/route.ts`](https://github.com/akoclantoy/yayay/blob/main/src/app/api/rewards/route.ts) (Rewards and redemptions), [`src/app/resident`](https://github.com/akoclantoy/yayay/tree/main/src/app/resident) (Resident portal), [`src/app/api/auth/register/route.ts`](https://github.com/akoclantoy/yayay/blob/main/src/app/api/auth/register/route.ts) (Registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_registration["Registration<br/>[route.ts]"]
  node_auth["Sign-in<br/>[auth.ts]"]
  node_auth_validation["Auth validation<br/>[auth.ts]"]
  node_session_guard["Session and roles<br/>[api-auth.ts]"]
end

subgraph group_recycling["Collection and impact"]
  node_staff_portal["Staff portal"]
  node_qr_scan["QR scanning<br/>[page.tsx]"]
  node_record_collection["Record collection<br/>[page.tsx]"]
  node_recycling_api["Recycling records API<br/>[route.ts]"]
  node_recycling_service["Points and impact<br/>[recycling.ts]"]
  node_pickup["Pickup requests<br/>[route.ts]"]
  node_ai["AI recycling tools"]
end

subgraph group_resident["Resident rewards"]
  node_resident_portal["Resident portal"]
  node_rewards_api["Rewards and redemptions<br/>[route.ts]"]
  node_gcash["GCash redemption"]
end

subgraph group_operations["Program operations"]
  node_admin_portal["Admin portal"]
  node_announcements["Announcements API<br/>[route.ts]"]
  node_database[("Application database<br/>[db.ts]")]
end

node_public(("Residents and staff"))
node_gemini{{"Google Gemini"}}

node_public -->|"registers"| node_registration
node_registration -->|"validates with"| node_auth_validation
node_registration -->|"creates account"| node_database
node_registration -->|"emails verification"| node_auth
node_public -->|"signs in"| node_auth
node_auth -->|"authenticates against"| node_database
node_auth -->|"validates with"| node_auth_validation
node_resident_portal -->|"serves residents"| node_public
node_staff_portal -->|"serves staff"| node_public
node_staff_portal -->|"offers scanning"| node_qr_scan
node_qr_scan -->|"identifies resident"| node_record_collection
node_record_collection -->|"records collection"| node_recycling_api
node_recycling_api -->|"checks access"| node_session_guard
node_recycling_api -->|"delegates records"| node_recycling_service
node_recycling_api -->|"reads and writes"| node_database
node_recycling_service -->|"reads and writes"| node_database
node_resident_portal -->|"requests pickup"| node_pickup
node_resident_portal -->|"uses assistant"| node_ai
node_ai -.->|"calls optionally"| node_gemini
node_resident_portal -->|"redeems points"| node_rewards_api
node_rewards_api -->|"checks roles"| node_session_guard
node_rewards_api -->|"reads and writes"| node_database
node_rewards_api -->|"handles GCash"| node_gcash
node_admin_portal -->|"manages notices"| node_announcements
node_announcements -->|"reads and writes"| node_database
node_admin_portal -->|"oversees redemptions"| node_rewards_api
node_pickup -->|"reads and writes"| node_database

click node_registration "https://github.com/akoclantoy/yayay/blob/main/src/app/api/auth/register/route.ts"
click node_auth "https://github.com/akoclantoy/yayay/blob/main/src/auth.ts"
click node_auth_validation "https://github.com/akoclantoy/yayay/blob/main/src/lib/validators/auth.ts"
click node_session_guard "https://github.com/akoclantoy/yayay/blob/main/src/lib/api-auth.ts"
click node_resident_portal "https://github.com/akoclantoy/yayay/tree/main/src/app/resident"
click node_staff_portal "https://github.com/akoclantoy/yayay/tree/main/src/app/staff"
click node_qr_scan "https://github.com/akoclantoy/yayay/blob/main/src/app/staff/scan/page.tsx"
click node_record_collection "https://github.com/akoclantoy/yayay/blob/main/src/app/staff/record/page.tsx"
click node_recycling_api "https://github.com/akoclantoy/yayay/blob/main/src/app/api/recycling/route.ts"
click node_recycling_service "https://github.com/akoclantoy/yayay/blob/main/src/lib/services/recycling.ts"
click node_pickup "https://github.com/akoclantoy/yayay/blob/main/src/app/api/pickup/route.ts"
click node_ai "https://github.com/akoclantoy/yayay/tree/main/src/app/api/ai"
click node_rewards_api "https://github.com/akoclantoy/yayay/blob/main/src/app/api/rewards/route.ts"
click node_gcash "https://github.com/akoclantoy/yayay/blob/main/src/lib/gcash-redemption.ts"
click node_admin_portal "https://github.com/akoclantoy/yayay/tree/main/src/app/admin"
click node_announcements "https://github.com/akoclantoy/yayay/blob/main/src/app/api/announcements/route.ts"
click node_database "https://github.com/akoclantoy/yayay/blob/main/src/lib/db.ts"

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_registration,node_auth,node_auth_validation,node_session_guard toneBlue
class node_staff_portal,node_qr_scan,node_record_collection,node_recycling_api,node_recycling_service,node_pickup,node_ai toneAmber
class node_resident_portal,node_rewards_api,node_gcash toneMint
class node_admin_portal,node_announcements,node_database toneRose
class node_public,node_gemini toneIndigo
```

## Components

### Identity and access

- [Registration](https://github.com/akoclantoy/yayay/blob/main/src/app/api/auth/register/route.ts): `src/app/api/auth/register/route.ts`
- [Sign-in](https://github.com/akoclantoy/yayay/blob/main/src/auth.ts): `src/auth.ts`
- [Auth validation](https://github.com/akoclantoy/yayay/blob/main/src/lib/validators/auth.ts): `src/lib/validators/auth.ts`
- [Session and roles](https://github.com/akoclantoy/yayay/blob/main/src/lib/api-auth.ts): `src/lib/api-auth.ts`

### Collection and impact

- [Staff portal](https://github.com/akoclantoy/yayay/tree/main/src/app/staff): `src/app/staff`
- [QR scanning](https://github.com/akoclantoy/yayay/blob/main/src/app/staff/scan/page.tsx): `src/app/staff/scan/page.tsx`
- [Record collection](https://github.com/akoclantoy/yayay/blob/main/src/app/staff/record/page.tsx): `src/app/staff/record/page.tsx`
- [Recycling records API](https://github.com/akoclantoy/yayay/blob/main/src/app/api/recycling/route.ts): `src/app/api/recycling/route.ts`
- [Points and impact](https://github.com/akoclantoy/yayay/blob/main/src/lib/services/recycling.ts): `src/lib/services/recycling.ts`
- [Pickup requests](https://github.com/akoclantoy/yayay/blob/main/src/app/api/pickup/route.ts): `src/app/api/pickup/route.ts`
- [AI recycling tools](https://github.com/akoclantoy/yayay/tree/main/src/app/api/ai): `src/app/api/ai`

### Resident rewards

- [Resident portal](https://github.com/akoclantoy/yayay/tree/main/src/app/resident): `src/app/resident`
- [Rewards and redemptions](https://github.com/akoclantoy/yayay/blob/main/src/app/api/rewards/route.ts): `src/app/api/rewards/route.ts`
- [GCash redemption](https://github.com/akoclantoy/yayay/blob/main/src/lib/gcash-redemption.ts): `src/lib/gcash-redemption.ts`

### Program operations

- [Admin portal](https://github.com/akoclantoy/yayay/tree/main/src/app/admin): `src/app/admin`
- [Announcements API](https://github.com/akoclantoy/yayay/blob/main/src/app/api/announcements/route.ts): `src/app/api/announcements/route.ts`
- [Application database](https://github.com/akoclantoy/yayay/blob/main/src/lib/db.ts): `src/lib/db.ts`

### Other components

- **Residents and staff**
- **Google Gemini**

## Connections

- Residents and staff → Registration: registers (evidence: `README.md`)
- Registration → Auth validation: validates with (evidence: `src/app/api/auth/register/route.ts`)
- Registration → Application database: creates account (evidence: `src/app/api/auth/register/route.ts`)
- Registration → Sign-in: emails verification (evidence: `src/app/api/auth/register/route.ts`)
- Residents and staff → Sign-in: signs in (evidence: `README.md`)
- Sign-in → Application database: authenticates against (evidence: `src/auth.ts`)
- Sign-in → Auth validation: validates with (evidence: `src/auth.ts`)
- Resident portal → Residents and staff: serves residents (evidence: `README.md`)
- Staff portal → Residents and staff: serves staff (evidence: `README.md`)
- Staff portal → QR scanning: offers scanning (evidence: `README.md`)
- QR scanning → Record collection: identifies resident (evidence: `README.md`)
- Record collection → Recycling records API: records collection (evidence: `README.md`)
- Recycling records API → Session and roles: checks access (evidence: `src/app/api/recycling/route.ts`)
- Recycling records API → Points and impact: delegates records (evidence: `src/app/api/recycling/route.ts`)
- Recycling records API → Application database: reads and writes (evidence: `src/app/api/recycling/route.ts`)
- Points and impact → Application database: reads and writes (evidence: `src/lib/services/recycling.ts`)
- Resident portal → Pickup requests: requests pickup (evidence: `README.md`)
- Resident portal → AI recycling tools: uses assistant (evidence: `README.md`)
- AI recycling tools → Google Gemini: calls optionally (evidence: `README.md`)
- Resident portal → Rewards and redemptions: redeems points (evidence: `README.md`)
- Rewards and redemptions → Session and roles: checks roles (evidence: `src/app/api/rewards/route.ts`)
- Rewards and redemptions → Application database: reads and writes (evidence: `src/app/api/rewards/route.ts`)
- Rewards and redemptions → GCash redemption: handles GCash (evidence: `src/app/api/rewards/route.ts`)
- Admin portal → Announcements API: manages notices (evidence: `README.md`)
- Announcements API → Application database: reads and writes (evidence: `src/app/api/announcements/route.ts`)
- Admin portal → Rewards and redemptions: oversees redemptions (evidence: `README.md`)
- Pickup requests → Application database: reads and writes (evidence: `src/app/api/pickup/route.ts`)
