Skip to content

smmariquit/comsci-128

Repository files navigation

UPLB CASA

UPLB CASA is a centralized accommodation management system for the University of the Philippines Los Baños. Designed to replace manual forms, fragmented email exchanges, and spreadsheets, UPLB CASA provides a unified digital platform that manages the entire lifecycle of student housing, assignments, occupancy, and billing.

CASA Live License Stars Last Commit

PWA Ready Offline DB 3D Maps

Tech Stack

Next.js Supabase Tailwind TypeScript Biome Lucide Swagger


3D Interactive Spatial Mapping

UPLB CASA features a fully interactive 3D spatial viewer built using MapLibre GL. The viewer constructs real-time 3D building models on-the-fly directly from OpenStreetMap building footprints via fill-extrusion layers.


Core System Architecture

Offline-First Housing Engine (PWA)

UPLB CASA is designed to work reliably in low-connectivity areas around UPLB.

  1. Service Worker (Serwist): Implements offline assets caching and fallback page routes (/offline).
  2. In-Browser PostgreSQL (PGlite): Mounts an IndexedDB-backed (idb://housing-offline-db) PostgreSQL instance directly inside the student's browser.
  3. Canvas Compression API: When online, the system automatically fetches all housing databases, converts heavy cover images into low-res JPEG base64 strings client-side, and stores them in the local PGlite instance to avoid offline network overhead.
sequenceDiagram
    autonumber
    actor User as Student/User
    participant App as Next.js PWA Client
    participant SW as Serwist Service Worker
    participant PGlite as In-Browser PGlite (IndexedDB)
    participant API as Supabase API (Backend)

    alt Device is Online
        App->>API: Fetch latest housing & room data
        API-->>App: Return JSON payload
        App->>App: Generate low-res base64 thumbnails (canvas API)
        App->>PGlite: Sync data (INSERT ON CONFLICT / DELETE obsolete)
        Note over PGlite: Data serialized to IndexedDB idb://housing-offline-db
    else Device is Offline
        User->>App: Open Housing Browser
        App->>SW: Intercept fetch requests
        SW-->>App: Serve static assets & cached scripts
        App->>PGlite: Query local PostgreSQL tables (housing & room)
        PGlite-->>App: Return local offline data (with base64 images)
        App-->>User: Display offline UI with full features
    end
Loading

Multi-Role Application & Approval Flow

Accommodations are managed through a two-tiered screening process to ensure full accountability and compliance with university policies.

graph TD
    %% Define Styles
    classDef init fill:#f5f3ef,stroke:#c9642a,stroke-width:2px,color:#2c1b0c;
    classDef state fill:#ffffff,stroke:#666666,stroke-width:1px,stroke-dasharray: 5 5,color:#111111;
    classDef success fill:#e6f4ea,stroke:#137333,stroke-width:2px,color:#137333;
    classDef danger fill:#fce8e6,stroke:#c5221f,stroke-width:2px,color:#c5221f;
    classDef process fill:#f1f3f4,stroke:#5f6368,stroke-width:1px,color:#202124;

    Start([Student submits application]) --> P1[Pending Manager Approval]
    
    P1 -->|Manager Rejects| R1[Rejected]
    P1 -->|Manager Reviews Docs Form 5, Payment, etc.| P2[Pending Admin Approval]
    
    P2 -->|Admin Rejects| R2[Rejected]
    P2 -->|Admin Grants Final Approval| Appr[Approved]
    
    Appr --> Assign[Manager / Admin assigns room unit]
    Assign --> Occupy[Occupancy tracking begins]
    
    class Start init;
    class P1,P2 state;
    class Appr,Occupy success;
    class R1,R2 danger;
    class Assign process;
Loading

Features

Core Infrastructure

  • Authentication: Role-based access control, secure signups, email OTP verification, and PKCE-based Google/UP Mail OAuth 2.0 flow via Supabase.
  • Immutable Audit Logs: full ledger tracking user activities (logins, application actions, approvals). Logs cannot be edited or deleted by any level of administration.
  • Reporting: Analytical tools to generate system-wide occupancy, financial, and applicant metrics exported directly to custom brand-styled PDF and CSV formats.
  • Notifications: Transactional emails powered by Resend via custom SMTP integration.

Role Capabilities & Portals

Role Route Primary Responsibilities
Student /student Browse housing listings (online/offline), submit applications, upload required docs (Form 5, Waiver, Contract, Receipt), and review Statement of Accounts (SOA).
Manager /manage Screen initial housing applications, review student documents, manage room occupancy/tenant assignments, and verify payment slips.
Admin / Landlord /admin Perform final application approval, manage dorm/room CRUD databases, define pricing rates, sign-off on verified payments, and export analytics reports.
System Admin /sys User administration, role overrides, system configuration modifications, and audit log analysis.

Screenshots & Portal Walkthrough

Landing & Login

  • Landing Page: Entry point displaying marketing overview and primary CTA.
  • Login Page: Secured credentials validation portal.
Landing Page Login Page
Landing Page Login Page

Student Portal (/student)

Student portal features dynamic offline DB synchronization status, housing catalogs, and local form complaints submission.

Student Dashboard Housing Browser Complaints Panel
Student Dashboard Housing Browser Complaints Panel

Manager Portal (/manage)

Managers review active listings, screen initial tenant applications, handle local complaint requests, and track staff/manager actions.

Manager Dashboard Accommodations Overview Application Reviews
Manager Dashboard Accommodations Application Reviews
Complaints Logs Manager Activity Logs
Complaints Logs Activity Logs

Admin / Landlord Portal (/admin)

Housing Administrators handle final tenant sign-off, room assignments, payments billing collections, database entries, and generate analytical reports.

Admin Dashboard Accommodations CRUD Billings Management
Admin Dashboard Accommodations CRUD Billings
Admin Audit Logs PDF/CSV Analytics Reports Room Layouts Users Directory
Audit Logs Reports Rooms Users

System Admin Portal (/sys)

Sysadmins manage user roles, overwrite system-wide variables, create property records, and evaluate immutable audit logs.

SysAdmin Dashboard System Config Properties & Dorms
SysAdmin Dashboard System Config Dorms Management
Immutable Audit Logs User Management
System Audit Logs User Directory

Technical Stack

Category Technology
Framework Next.js 16 (App Router, React 19)
Language TypeScript
Database Supabase (PostgreSQL) + Client-side PGlite (IndexedDB)
PWA Serwist (Service Worker)
Styling Tailwind CSS v4
Code Quality Biome (Linter & Formatter)
Deployment Vercel

Getting Started

Project Structure

src/app
├── (auth)/             # Auth-related routes (login, register)
├── (main)/             # Main application modules
│   ├── admin/          # Admin & Landlord dashboards
│   ├── manage/         # Manager (Dorm screening) tools
│   ├── student/        # Student portal & housing browser
│   └── sys/            # System Admin (Audit logs, roles)
├── api/                # Backend API route handlers
├── components/         # Shared UI components
├── lib/                # Core business logic
│   ├── data/           # Database fetchers & queries
│   ├── models/         # TypeScript types & schemas
│   └── services/       # Logic for applications, billing, etc.
├── globals.css         # Global Tailwind styles
├── layout.tsx          # Root application layout
└── page.tsx            # Landing page entry
public/             # Static assets (images, fonts, logos, map style)
scripts/            # Database seed and mock data scripts
docs/               # Technical documentation & OpenAPI specifications
srs.md              # Software Requirements Specification
biome.json          # Linter & formatter configuration

Installation

Clone the repository and install dependencies:

git clone https://github.com/smmariquit/comsci-128
cd comsci-128
npm install

Environment Setup

Create a .env.local file in the root directory:

NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key

Database Seeding

  1. Run the sql script in the Supabase SQL editor:
  scripts/mock-seed.sql
  1. Build the matching mock authentication credentials:
  npx tsx scripts/seed-auth-users.ts

Running Locally

Start the Next.js development server:

npm run dev

Open http://localhost:3000 in your browser.


Acknowledgements

This project was developed in partial fulfillment of the requirements for CMSC 128 (Introduction to Software Engineering) at the University of the Philippines Los Baños, Second Semester AY 2025–2026.

About

UPLB CASA: a Next.js + Supabase centralized accommodation management system that replaces manual forms and spreadsheets with a unified portal for student housing applications, room assignment, billing, and audit logs. Built for CMSC 128 (Software Engineering).

Topics

Resources

Stars

Watchers

Forks

Used by

Contributors

Languages