Skip to content
SATANG.B
All workCase study
CMU Office of Research Administration · freelance

CMU Research Gallery

A public directory of Chiang Mai University researchers, with a private workspace where researchers manage their own profile and an admin portal for the office.

Role
Full-stack · backend, public site and researcher workspace
Stack
NestJS 11 · Fastify · Prisma 6 · PostgreSQL
CMU Research Gallery landing page
Problem
Researcher data had to match the university’s central system, and nothing could go public without the researcher’s consent under PDPA.
What I did
Synced from CMU Central weekly or on demand, built a two-step onboarding that asks for consent first, and an admin that logs every change.

Results

May → Nov 2026 · production deploy in Oct 2026
  • Database clean-up: tables 90 → 72, columns 1,233 → 797, unindexed foreign keys 37 → 0
  • 244 researchers and 64 research units imported, with no duplicate or malformed Scopus IDs

How it works

  1. 01

    Sync from CMU Central

    A weekly job on @nestjs/schedule that can also run on demand; every change is logged before and after.

  2. 02

    Consent before publishing

    Two-step onboarding: the privacy notice first, then the profile — with a live preview of the directory card before anything goes public.

  3. 03

    Safe uploads

    Files are checked by magic bytes, not extension, before they reach MinIO, and the API is rate-limited.

  4. 04

    Contract-first API

    The front-end client is generated from the backend’s Swagger with swagger-typescript-api.

What went wrong — and how I fixed it

Real problems from the commit history, not a highlight reel.

  1. 01
    Problem

    An earlier backfill left ~245 researchers public with no consent evidence.

    How I fixed it

    Hidden by default (fail closed) on import and sync, with a double check in public queries.

  2. 02
    Problem

    Client data arrived as Excel files.

    How I fixed it

    Convert to a committed JSON snapshot and import idempotently, validating Scopus IDs.

  3. 03
    Problem

    The CMU Central sync must never run twice at once.

    How I fixed it

    A scheduled job with a run lock and a 1-hour cooldown for manual runs.

  4. 04
    Problem

    Two sites each had their own cookie and keys.

    How I fixed it

    One shared session, Origin checked against an allow-list, and the dev login kept out of production.

Decisions & trade-offs

  • Dynamic roles

    RBAC configured from the admin, so each team sees only what it manages.

  • One backend, shared with the ORA site

    The directory and the ORA site share one API, one RBAC model and one audit log.

Screens

9 screens · click to enlarge
What I owned
  • NestJS API, Prisma and the sync jobs
  • The public directory
  • The researcher workspace and onboarding
  • The admin portal
Stack
  • NestJS 11
  • Fastify
  • Prisma 6
  • PostgreSQL
  • MinIO
  • Next.js 16
  • Tailwind
  • shadcn/ui
  • Tolgee