# bytecodx/nec-scs architecture

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

- Interactive diagram: https://gitdiagram.com/bytecodx/nec-scs
- Repository: https://github.com/bytecodx/nec-scs

## Overview

NEC-SCS is a campus achievement and certificate-verification portal with student, faculty, HOD, and administrator experiences. The principal workflow is student certificate submission, faculty review, and—when approved—an achievement appearing in the student wallet with points awarded. The graph also captures role-based access, administration, notifications, and private certificate-file handling. Evidence is limited: the README only names the product, and many listed routes and subsystems were not excerpted; those features are included where the tree or source index supports them, without assuming their internal calls.

Main entry points: [`lib/db/store.ts`](https://github.com/bytecodx/nec-scs/blob/main/lib/db/store.ts) (Application data store), [`actions/reviews.ts`](https://github.com/bytecodx/nec-scs/blob/main/actions/reviews.ts) (Review actions), [`lib/auth/session.ts`](https://github.com/bytecodx/nec-scs/blob/main/lib/auth/session.ts) (Session and roles), [`lib/storage/client.ts`](https://github.com/bytecodx/nec-scs/blob/main/lib/storage/client.ts) (File validation and signing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and roles"]
  node_login["Sign-in page<br/>[page.tsx]"]
  node_authactions["Authentication actions<br/>[auth.ts]"]
  node_session["Session and roles<br/>[session.ts]"]
end

subgraph group_certificates["Certificate workflow"]
  node_student_submit["Certificate submission"]
  node_student_routes["Student portal<br/>[page.tsx]"]
  node_storage["File validation and signing<br/>[client.ts]"]
  node_download["File download route<br/>[route.ts]"]
  node_reviewqueue["Faculty review queue<br/>[page.tsx]"]
  node_reviewworkbench["Review workbench"]
  node_reviewactions["Review actions<br/>[reviews.ts]"]
  node_reviewrules["Review validation<br/>[review.ts]"]
  node_wallet["Achievement wallet<br/>[page.tsx]"]
  node_notifications["Notifications<br/>[dispatcher.ts]"]
end

subgraph group_campus["Campus operations"]
  node_adminportal["Admin portal<br/>[page.tsx]"]
  node_adminactions["Administration actions<br/>[admin.ts]"]
  node_departments["Department management<br/>[page.tsx]"]
  node_facultyportal["Faculty dashboard<br/>[page.tsx]"]
  node_hodportal["HOD portal<br/>[page.tsx]"]
  node_reports["Reports and analytics<br/>[page.tsx]"]
end

subgraph group_platform["Data and services"]
  node_store[("Application data store<br/>[store.ts]")]
  node_supabase[("Supabase storage")]
  node_audit["Audit logging<br/>[logger.ts]"]
  node_types["Domain data types<br/>[database.types.ts]"]
end

node_visitor(("Portal user"))

node_visitor -->|"signs in"| node_login
node_login -->|"submits credentials"| node_authactions
node_visitor -.->|"submits certificate"| node_student_routes
node_student_routes -.->|"renders form"| node_student_submit
node_student_submit -.->|"validates file"| node_storage
node_storage -->|"checks duplicate hash"| node_store
node_storage -->|"creates signed URL"| node_supabase
node_storage -->|"fallback proxy URL"| node_download
node_download -->|"checks current user"| node_session
node_reviewqueue -.->|"uses workbench"| node_reviewworkbench
node_reviewworkbench -.->|"submits review"| node_reviewactions
node_reviewactions -->|"requires reviewer role"| node_session
node_reviewactions -->|"reads and updates records"| node_store
node_reviewactions -->|"validates review data"| node_reviewrules
node_reviewactions -->|"sends outcome notice"| node_notifications
node_reviewactions -->|"records audit events"| node_audit
node_wallet -->|"gets current user"| node_session
node_wallet -->|"reads approved certificates"| node_store
node_facultyportal -->|"gets current user"| node_session
node_facultyportal -->|"reads department records"| node_store
node_adminportal -->|"gets current user"| node_session
node_adminportal -->|"reads campus records"| node_store
node_departments -->|"updates department"| node_adminactions
node_adminactions -.->|"administers records"| node_store
node_hodportal -.->|"accesses reporting data"| node_store
node_reports -.->|"uses reporting data"| node_store
node_store -.->|"uses domain records"| node_types

click node_login "https://github.com/bytecodx/nec-scs/blob/main/app/(auth)/login/page.tsx"
click node_authactions "https://github.com/bytecodx/nec-scs/blob/main/actions/auth.ts"
click node_session "https://github.com/bytecodx/nec-scs/blob/main/lib/auth/session.ts"
click node_student_submit "https://github.com/bytecodx/nec-scs/blob/main/components/forms/SubmitCertificateForm.tsx"
click node_student_routes "https://github.com/bytecodx/nec-scs/blob/main/app/student/submit/page.tsx"
click node_storage "https://github.com/bytecodx/nec-scs/blob/main/lib/storage/client.ts"
click node_download "https://github.com/bytecodx/nec-scs/blob/main/app/api/files/download/route.ts"
click node_reviewqueue "https://github.com/bytecodx/nec-scs/blob/main/app/faculty/reviews/page.tsx"
click node_reviewworkbench "https://github.com/bytecodx/nec-scs/blob/main/components/certificates/ReviewWorkbench.tsx"
click node_reviewactions "https://github.com/bytecodx/nec-scs/blob/main/actions/reviews.ts"
click node_reviewrules "https://github.com/bytecodx/nec-scs/blob/main/lib/validators/review.ts"
click node_wallet "https://github.com/bytecodx/nec-scs/blob/main/app/student/achievements/page.tsx"
click node_notifications "https://github.com/bytecodx/nec-scs/blob/main/lib/notifications/dispatcher.ts"
click node_adminportal "https://github.com/bytecodx/nec-scs/blob/main/app/admin/dashboard/page.tsx"
click node_adminactions "https://github.com/bytecodx/nec-scs/blob/main/actions/admin.ts"
click node_departments "https://github.com/bytecodx/nec-scs/blob/main/app/admin/departments/page.tsx"
click node_facultyportal "https://github.com/bytecodx/nec-scs/blob/main/app/faculty/dashboard/page.tsx"
click node_hodportal "https://github.com/bytecodx/nec-scs/blob/main/app/hod/dashboard/page.tsx"
click node_reports "https://github.com/bytecodx/nec-scs/blob/main/app/admin/reports/page.tsx"
click node_store "https://github.com/bytecodx/nec-scs/blob/main/lib/db/store.ts"
click node_audit "https://github.com/bytecodx/nec-scs/blob/main/lib/audit/logger.ts"
click node_types "https://github.com/bytecodx/nec-scs/blob/main/types/database.types.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_login,node_authactions,node_session,node_visitor toneBlue
class node_student_submit,node_student_routes,node_storage,node_download,node_reviewqueue,node_reviewworkbench,node_reviewactions,node_reviewrules,node_wallet,node_notifications toneAmber
class node_adminportal,node_adminactions,node_departments,node_facultyportal,node_hodportal,node_reports toneMint
class node_store,node_supabase,node_audit,node_types toneRose
```

## Components

### Access and roles

- [Sign-in page](https://github.com/bytecodx/nec-scs/blob/main/app/(auth)/login/page.tsx): `app/(auth)/login/page.tsx`
- [Authentication actions](https://github.com/bytecodx/nec-scs/blob/main/actions/auth.ts): `actions/auth.ts`
- [Session and roles](https://github.com/bytecodx/nec-scs/blob/main/lib/auth/session.ts): `lib/auth/session.ts`

### Certificate workflow

- [Certificate submission](https://github.com/bytecodx/nec-scs/blob/main/components/forms/SubmitCertificateForm.tsx): `components/forms/SubmitCertificateForm.tsx`
- [Student portal](https://github.com/bytecodx/nec-scs/blob/main/app/student/submit/page.tsx): `app/student/submit/page.tsx`
- [File validation and signing](https://github.com/bytecodx/nec-scs/blob/main/lib/storage/client.ts): `lib/storage/client.ts`
- [File download route](https://github.com/bytecodx/nec-scs/blob/main/app/api/files/download/route.ts): `app/api/files/download/route.ts`
- [Faculty review queue](https://github.com/bytecodx/nec-scs/blob/main/app/faculty/reviews/page.tsx): `app/faculty/reviews/page.tsx`
- [Review workbench](https://github.com/bytecodx/nec-scs/blob/main/components/certificates/ReviewWorkbench.tsx): `components/certificates/ReviewWorkbench.tsx`
- [Review actions](https://github.com/bytecodx/nec-scs/blob/main/actions/reviews.ts): `actions/reviews.ts`
- [Review validation](https://github.com/bytecodx/nec-scs/blob/main/lib/validators/review.ts): `lib/validators/review.ts`
- [Achievement wallet](https://github.com/bytecodx/nec-scs/blob/main/app/student/achievements/page.tsx): `app/student/achievements/page.tsx`
- [Notifications](https://github.com/bytecodx/nec-scs/blob/main/lib/notifications/dispatcher.ts): `lib/notifications/dispatcher.ts`

### Campus operations

- [Admin portal](https://github.com/bytecodx/nec-scs/blob/main/app/admin/dashboard/page.tsx): `app/admin/dashboard/page.tsx`
- [Administration actions](https://github.com/bytecodx/nec-scs/blob/main/actions/admin.ts): `actions/admin.ts`
- [Department management](https://github.com/bytecodx/nec-scs/blob/main/app/admin/departments/page.tsx): `app/admin/departments/page.tsx`
- [Faculty dashboard](https://github.com/bytecodx/nec-scs/blob/main/app/faculty/dashboard/page.tsx): `app/faculty/dashboard/page.tsx`
- [HOD portal](https://github.com/bytecodx/nec-scs/blob/main/app/hod/dashboard/page.tsx): `app/hod/dashboard/page.tsx`
- [Reports and analytics](https://github.com/bytecodx/nec-scs/blob/main/app/admin/reports/page.tsx): `app/admin/reports/page.tsx`

### Data and services

- [Application data store](https://github.com/bytecodx/nec-scs/blob/main/lib/db/store.ts): `lib/db/store.ts`
- **Supabase storage**
- [Audit logging](https://github.com/bytecodx/nec-scs/blob/main/lib/audit/logger.ts): `lib/audit/logger.ts`
- [Domain data types](https://github.com/bytecodx/nec-scs/blob/main/types/database.types.ts): `types/database.types.ts`

### Other components

- **Portal user**

## Connections

- Portal user → Sign-in page: signs in (evidence: `app/(auth)/login/page.tsx`)
- Sign-in page → Authentication actions: submits credentials (evidence: `app/(auth)/login/page.tsx`)
- Portal user → Student portal: submits certificate
- Student portal → Certificate submission: renders form
- Certificate submission → File validation and signing: validates file
- File validation and signing → Application data store: checks duplicate hash (evidence: `lib/storage/client.ts`)
- File validation and signing → Supabase storage: creates signed URL (evidence: `lib/storage/client.ts`)
- File validation and signing → File download route: fallback proxy URL (evidence: `lib/storage/client.ts`)
- File download route → Session and roles: checks current user (evidence: `app/api/files/download/route.ts`)
- Faculty review queue → Review workbench: uses workbench
- Review workbench → Review actions: submits review
- Review actions → Session and roles: requires reviewer role (evidence: `actions/reviews.ts`)
- Review actions → Application data store: reads and updates records (evidence: `actions/reviews.ts`)
- Review actions → Review validation: validates review data (evidence: `actions/reviews.ts`)
- Review actions → Notifications: sends outcome notice (evidence: `actions/reviews.ts`)
- Review actions → Audit logging: records audit events (evidence: `actions/reviews.ts`)
- Achievement wallet → Session and roles: gets current user (evidence: `app/student/achievements/page.tsx`)
- Achievement wallet → Application data store: reads approved certificates (evidence: `app/student/achievements/page.tsx`)
- Faculty dashboard → Session and roles: gets current user (evidence: `app/faculty/dashboard/page.tsx`)
- Faculty dashboard → Application data store: reads department records (evidence: `app/faculty/dashboard/page.tsx`)
- Admin portal → Session and roles: gets current user (evidence: `app/admin/dashboard/page.tsx`)
- Admin portal → Application data store: reads campus records (evidence: `app/admin/dashboard/page.tsx`)
- Department management → Administration actions: updates department (evidence: `app/admin/departments/page.tsx`)
- Administration actions → Application data store: administers records
- HOD portal → Application data store: accesses reporting data
- Reports and analytics → Application data store: uses reporting data
- Application data store → Domain data types: uses domain records
