Benjamin Saenz

CSS Atlas

about this project

CSS Atlas is the web app that runs the day-to-day of the University of Maryland's College Success Scholars (CSS) program. Every week, team leaders need to know which of their scholars came to front desk and study session hours, who turned in their forms, and who needs a check-in before the weekly meeting. Before Atlas, that information was spread across Google Forms and spreadsheets. I've been in CSS for four years, as a scholar, a team leader, on the exec board, and now as Program Coordinator, and I lead development of Atlas with a small team of student developers. It's a Next.js frontend and an Express API on Railway, backed by Postgres on Supabase, plus two scheduled jobs that message team leaders on Slack. The app sits behind a UMD login and holds student records, so this page stands in for a demo: how the system fits together, the decisions behind it, the tests that check who can see what, and write-ups of bugs we shipped. No scholar data appears on this page.

The constraint behind almost every decision is that Atlas is built and kept running by undergraduates who rotate out every year or two, me included. So I care less about clever and more about whether the next student can read the code, change it, and tell when they've broken something. That's why the business logic is in TypeScript instead of database triggers, why attendance is computed when it's read instead of kept in sync, and why the decisions below are written down with what would make us change them. A lot of Atlas is written with AI coding agents, by me and by the team. That makes my job less about typing and more about scoping the work, reviewing it, and checking it against the real database instead of trusting what the code or the agent says it does.

The parts I'd point you to are the tests and the bug write-ups. Each write-up starts from a symptom in production and ends with the check that would have caught it. Two of them are the same bug: a scheduled job that started, did nothing, and exited without an error. We fixed it in one job in September and didn't notice the second job had it until November. The fix worked. What I missed was asking where else it applied.

how it fits together

CSS Atlas architecture Team leaders use a Next.js frontend, which signs them in with Supabase Auth and calls an Express API with their token. The API queries Postgres as that user, so row-level security filters every query. Scholars sign in at the front desk through Google Forms, which write to Postgres. Two scheduled jobs read Postgres with a service key and send Slack messages to team leaders. Railway Supabase Team leaders, staff browser Scholars sign in at the front desk Google Forms + Apps Script Next.js frontend Express API checks role, binds the user's token cron: sign-in check, every 5 min cron: reconciliation, daily Auth Postgres row-level security on every table Slack DMs to team leaders sign in user's token as the user sign-ins and forms service key

In words:

  1. Team leaders and staff sign in on the Next.js frontend through Supabase Auth.
  2. The frontend calls the Express API with the user's token. The API checks their role, then makes every database query as that user, so Postgres row-level security decides which rows come back.
  3. Scholars sign in and out at the front desk through Google Forms, which write those logs to Postgres. A public kiosk page logs foot traffic without a login.
  4. Two scheduled jobs have no user, so they use a service key. They compare sign-ins against assigned shifts and message the scholar's team leader on Slack.
  5. All four services live in one repo, each with its own Dockerfile. CI runs on every pull request and push.

decisions, and what would change them

These are short architecture decision records. Each one says what we picked, what we didn't, why, and what would make us switch.

1. Every database query runs as the logged-in user
Context
Atlas holds attendance, grades, and mentoring notes. The Express API checks roles on each route, but one forgotten check on one route would expose data.
Decision
The API verifies the user's token and keeps it for the length of the request (Node's AsyncLocalStorage). Every Supabase client it creates uses that token, so Postgres row-level security (RLS) filters every query as that user. Only the two scheduled jobs, which have no user, get the service key.
Instead of
Using the service key in the API and doing all checks in Express. That's simpler, but it's one layer, and a missed check is a leak.
Cost
Two places to update when a role changes. Our "act as another user" testing tool can't simulate RLS, because the token stays the developer's. We wrote that down in the auth runbook after it confused people.
Revisit if
The policies get complex enough that people stop understanding them. Then the logic should move into a few well-tested SQL functions.
2. Business logic lives in TypeScript, not SQL
Context
When we added assigned shifts, we needed rules like "minutes inside the shift, with a 15-minute grace window." I looked at database triggers, views, pre-computed tables, and a nightly job.
Decision
The database stores facts and enforces invariants: foreign keys, plus an exclusion constraint so a scholar can't be assigned two overlapping shifts. The rules themselves are plain TypeScript functions in the API, with unit tests.
Why
The next student will know TypeScript better than PL/pgSQL, and the grace-window rules were still changing. A rule in a trigger is hard to find, hard to test, and easy to break without noticing.
Cost
Slower than doing it in SQL. At one program's size, that doesn't matter.
Revisit if
A page gets slow enough that people notice, or Atlas serves more than one program.
3. Compute attendance when it's read, not keep it in sync
Context
We used to store weekly attendance totals in their own tables, filled in by a sync. Whenever the sync didn't run, the totals drifted away from the actual sign-ins, and the weekly memo showed the wrong numbers.
Decision
Compute weekly minutes from the raw sign-in logs every time they're read. The old total tables are frozen and renamed *_legacy. Excuses get their own table with one row per scholar, week, and session type.
Why
The weekly memo and the attendance page now share one calculation, so they can't disagree. A week of sign-ins is small enough to compute on every load.
Revisit if
Reads get slow. Then we'd add a cached table that's rebuilt from the logs, never edited by hand.
4. Alerts run as separate scheduled jobs, with a log that prevents duplicates
Context
Team leaders wanted to hear when a scholar missed an assigned shift. Attendance is computed when a page loads, so nothing happens at the moment someone doesn't show up.
Decision
Two Railway cron services: a sign-in check every 5 minutes and a reconciliation job once a day. Every message is recorded in notification_log under a unique key built from the shift and the date, so a retry or an overlapping run can't message someone twice. Messages are written as prompts ("hasn't shown up yet, check in with them"), not accusations, because a late scholar isn't necessarily absent.
Instead of
A timer inside the API server, which restarts with every deploy and would run once per server copy. Or a database trigger, which can't fire for someone who never signs in, because no row ever gets written.
Cost
Two more services to deploy and watch. A job that does nothing looks the same as a job with nothing to do. That cost us eight weeks once (postmortem below).
Revisit if
We need more than a few kinds of alerts. Then a small queue would beat more cron jobs.
5. One plain CI file, and fake keys in CI
Context
Our GitHub Actions workflow had broken YAML, duplicated environment variables, and a separate job that built our shared library and then threw the result away. Next.js also needs Supabase variables just to build.
Decision
One workflow file with the constants defined once at the top, dependency caching from the lockfile, and the shared library built inside each job that needs it. CI builds with placeholder keys. The real keys live only in Railway.
Instead of
Reusable composite actions plus uploading and downloading the build between jobs. An AI assistant proposed that, and I turned it down. It works well in big monorepos, but for our team it meant more files and more indirection for builds that are already fast.
Revisit if
CI takes more than about 10 minutes, we hit GitHub's free minutes, or the repo grows past 5 or 6 packages. Placeholder keys stop working once we add end-to-end tests that need a real staging database.
6. Ship fixes to production by cherry-picking
Context
The CI and cron fixes were merged into develop, which also had other work that wasn't ready for production.
Decision
Cut a fresh branch from main and cherry-pick only the fix commits onto it. Production merges need two approvals from senior developers plus the code owner.
Instead of
Merging develop into main, or opening a PR from the fix branch. Both would have carried unreviewed commits into production.
Revisit if
We move to feature flags or trunk-based development, so develop is always releasable.

postmortems

Blameless write-ups of things that went wrong in production. Each one ends with the check that would have caught it, and whether we have that check now.

A scheduled job that never ran, twice
Symptom
Five days after launch, notification_log still had zero rows. The sign-in job was "succeeding" every five minutes and sending nothing.
Root cause
Both jobs only call their main function if the running file's name ends in .js. That guard was left over from when the code was compiled first. In the containers, Bun runs the .ts source directly, so the guard was false. The process started, skipped the work, and exited cleanly with no logs.
First fix
September 23: I changed the sign-in job's guard to accept both extensions.
What I missed
The daily reconciliation job had the exact same guard. I didn't look. Its npm script also ran the compiled .js file with Node, where the guard is true, so running it locally worked fine and hid the problem. I found it on November 13 while auditing our Railway setup and reading each Dockerfile next to the code it runs. For about eight weeks, team leaders never got the daily "forgot to sign out" alerts. Nothing wrong was sent. The alerts were just missing.
Fix
Same one-line fix, plus one way to run each job: the npm scripts now run exactly what the Dockerfiles run. CI now builds both job images too, which it didn't before.
What would have caught it
A heartbeat: each job pings a monitor when it finishes, and we get an email when a ping doesn't arrive. Building the image only proves it builds. We don't have the heartbeat yet. It's next.
About 1 in 5 missed-shift alerts was wrong
Symptom
Some "hasn't shown up" alerts were about scholars who had signed in early and were still at the front desk.
How I measured it
I pulled all 1,265 alerts from the first three weeks and matched each one against the actual sign-in logs, after first removing our own test data. 19% were false alarms: the scholar had signed in early and was still there. About another quarter were real problems with the wrong label, like a scholar who came outside their scheduled hours or went to the other kind of session.
Root cause
The detector looked for a sign-in inside a window around the shift's start time. An early sign-in fell outside the window, so it counted as a miss. It never asked whether the scholar was actually present during the shift.
Fix
I rewrote the rules with program staff. Presence is now checked by overlap with the shift, with the same 15-minute grace for arriving late or leaving early. Arriving early is never penalized. "Outside hours" and "wrong session" are their own alert types, each with its own color, and there's one end-of-day digest instead of mid-shift pings. The spec is done and implementation is in progress.
What would have caught it
We tested every message type with seeded fake scholars, but never ran the detector against a week of real sign-ins before it messaged anyone. The new spec adds a shadow mode that runs new rules against past sign-ins before they message anyone. It isn't built yet.
Every PR blocked by a check that would never report
Symptom
Every pull request showed ci — Expected — Waiting for status to be reported (Required), forever. No workflow called ci was running.
Ruled out
Broken workflow YAML: the renamed jobs (Backend Test & Build, Frontend Test & Build) ran and reported normally. Old branch protection rules: the repo didn't have any.
Root cause
GitHub's newer repository Rulesets for main and develop required a status check named ci. When I renamed the jobs to something readable, nothing would ever report under the old name again, so GitHub waited indefinitely. I confirmed it by exporting both rulesets as JSON.
Fix
Removed the stale ci requirement from both rulesets.
What would have caught it
A rule in our PR checklist: if you rename a workflow or job, update the required checks in the same PR. Renaming a check is a settings change, not just a code change.

what runs on every change

On every pull request and every push to develop or main:

  • Backend: unit and integration tests, then a TypeScript build.
  • Frontend: tests, a script that fails on hard-coded colors that break dark mode, lint, and a production Next.js build.
  • Containers: builds all four images, starts the app with Docker Compose, and runs a smoke test: the health check responds, protected routes return 401 without a login, and CORS behaves.

The CI cleanup took the pipeline from five jobs to four and cut the shared-library build from three times per run to two. What CI still doesn't do: talk to a real database. Nothing in CI tests access control yet, so the next CI change is running the RLS tests against a throwaway Supabase instance on every PR.

Code on GitHub · Developer handbook · cssatlas.org