All work
Tierra Libre Run·Full-Stack Development

Nonprofit Trail Running Platform

Next.jsTypeScriptPlanetScaleDrizzle ORMClerkSanityResendOpen Source

Trail running is overwhelmingly white, and the barriers aren't just cultural. Race entries cost $100-$300, gear is expensive, and showing up alone to a 50K in the mountains is intimidating. I started Tierra Libre Run to sponsor athletes, fund race entries, match runners with mentors, and partner with race organizations to create space for runners of color on trails.

The fund application process alone has 12 stages: someone applies, we review, we approve or waitlist, they confirm within 72 hours, we register them for the race, we pair them with a mentor, they onboard into the community, they run the race, we close out their application. Each stage triggers different emails, updates different dashboards, and involves different people.

Nonprofits at this stage usually duct-tape things together with Google Forms, Airtable, and manual email. I tried that. It broke almost immediately. I needed a real platform — and since I'm the only engineer, I needed to build it myself.

I built a Next.js 16 application (App Router, server components, server actions) in TypeScript. The database is PlanetScale (MySQL) with Drizzle ORM for typed queries and migrations. Auth is Clerk. Content is Sanity. Email is Resend. Every piece of the stack lets a single engineer move fast without giving up reliability.

The hardest technical problem was the application lifecycle. I built a state machine in pure TypeScript — no external workflow library. The fund application moves through 12 stages (SUBMITTED → IN_REVIEW → AWAITING_CONFIRMATION → CONFIRMED → REGISTRATION_IN_PROGRESS → REGISTERED → ONBOARDING_IN_PROGRESS → ACTIVE_IN_PROGRAM → CLOSED) with branches for waitlisting, declining, no-shows, and dropping out. Every transition updates timestamps, creates or closes admin tasks, fires audit log events, and optionally triggers transactional emails.

The email system has four layers: an orchestrator for templated and custom emails, an email sender with live preview and personalization tokens, a broadcast system with audience segmentation, and full audit logging. Three layers of auth enforce permissions — Clerk middleware, layout-level guards, and server action checks. The user model distinguishes between BIPOC users and allies, enforced in code through a permissions function, not through UI hiding.

The platform now manages 15 race organization partners (Aravaipa Running, Brooks Running, Rainshadow Running, Northwest Trail Runs, and others) with 20+ routes, 10 database tables, 26 SQL migrations over 11 months, 7 Sanity content types, and 13 operational scripts — all maintained by a single contributor.

The entire platform is open source (MIT licensed) at github.com/laurosilvacom/tierralibrerun. I open-sourced it because the patterns — workflow engines, email systems, multi-step onboarding, admin tooling — are useful beyond nonprofits. And because if this organization outlasts me, someone else should be able to pick up the codebase and understand it.

Next.js 16TypeScriptPlanetScaleDrizzle ORMClerkSanityResendTailwind CSSRadix UIVercel