How codenamed22/agora works
Purpose and Entry Points
ShardUp is a Next.js community platform for membership, applications, resources, events, learning programs, peer accountability, and competitive programming. The App Router is rooted at app/layout.tsx and app/page.tsx; public feature routes sit under app/, while authenticated flows use app/(protected)/layout.tsx. Operational endpoints are Auth.js at app/api/auth/[...nextauth]/route.ts and deployment health checks at app/api/health/route.ts.
Identity, Membership, and Authorization
Auth.js provides Google OAuth plus development-only login support, configured in auth.ts and exposed through app/api/auth/[...nextauth]/route.ts. Route/layout protection and server-side role/status decisions form the boundary between public visitors, applicants, active members, and admins: app/(protected)/layout.tsx, lib/access.ts, and lib/guards.ts. The join/application workflow enters at app/(auth)/join/page.tsx, is submitted through app/(protected)/apply/actions.ts, and is administered under app/(protected)/admin/cohort/.
Persistent Domain Layer
PostgreSQL is the system of record, accessed through Prisma’s shared client and adapter: lib/prisma.ts, lib/prisma-adapter.ts, and prisma/schema.prisma. Schema migrations encode evolving domains including applications/cohorts, events/RSVPs, profiles/badges, teaching boards, practice, contests, nudges, and notifications under prisma/migrations/. Domain services centralize query and mutation rules rather than leaving them solely in pages, notably lib/members.ts, lib/events.ts, and lib/contest.ts.
Community Content and Engagement
Public/member-facing sections expose directory profiles, badges, a curated bookshelf, events, notifications, and peer nudges. Primary route boundaries are app/members/, app/badges/, app/bookshelf/, app/events/, app/notifications/, and app/nudges/. Server actions mutate state close to route ownership—for example app/events/actions.ts, app/notifications/actions.ts, and app/nudges/actions.ts—with domain policy in lib/events.ts, lib/notifications.ts, and lib/nudges.ts. Event RSVP and contest registration are restricted to active members.
Learning, Teaching, and Collaborative Boards
The platform serves practice problems, structured design practice, masterclasses, and teaching sessions. Core routes are app/practice/, app/problems/, app/masterclass/, and app/(protected)/admin/teaching/; shared learning behavior lives in lib/practice.ts and lib/teaching.ts. Excalidraw-backed board views are mounted through app/boards/[boardId]/page.tsx and app/boards/excalidraw-board.tsx, with teaching/masterclass board routes providing contextual access.
Submission Judging and Contest Lifecycle
Practice and contest submissions flow from problem route actions—app/problems/[slug]/actions.ts and app/contests/[slug]/actions.ts—into a provider-abstracted judge: lib/judge/index.ts, lib/judge/core.ts, and lib/judge/piston.ts. The fake provider supports deterministic tests; production calls a separately self-hosted Piston API, authenticated by a reverse-proxy bearer key. Contest administration (app/(protected)/admin/contests/actions.ts) creates/publishes contests and finalizes standings/ratings; lib/contest.ts calculates scoring and ratings, publishes finalized problems into practice, and assigns tier badges.
Administration and Deployment Boundaries
Admins manage badges, cohorts, contests, events, problems, and teaching through app/(protected)/admin/; each domain owns server actions, e.g. app/(protected)/admin/problems/actions.ts and app/(protected)/admin/contests/actions.ts. Runtime deployment is Vercel/Next.js server functions backed by externally hosted PostgreSQL and Piston; local Postgres is defined in docker-compose.yml. Piston hosting guidance and bootstrap infrastructure are retained in docs/oracle-piston.md and infra/oracle-piston-cloud-init.yaml.
Main entry points: prisma.ts Prisma data access · actions.ts Problem & contest actions · access.ts Access guards · layout.tsx Protected layout
Components 19
Identity & Access
- Protected layout · Authenticated member and admin route boundary.
app/(protected)/layout.tsx - Auth.js · Google OAuth and development login configuration.
auth.ts - Auth endpoint
app/api/auth/[...nextauth]/route.ts - Access guards · Enforces role and membership-status decisions.
lib/access.ts
Community Workflows
- Public routes · Marketing and public community entry points.
- Join & cohort workflow · Applications are submitted by members and reviewed by admins.
app/(auth)/join/page.tsx - Admin operations · Manages cohorts, badges, events, problems, contests, and teaching.
- Community engagement · Members, badges, bookshelf, events, notifications, and nudges.
- Engagement services · Applies event, notification, and nudge policy.
lib/events.ts
Learning & Competition
- Practice & masterclasses · Practice problems, design practice, and masterclass experiences.
- Teaching administration
- Collaborative boards · Board views are linked from teaching and masterclass contexts.
app/boards/[boardId]/page.tsx - Problem & contest actions · Accepts practice submissions and contest registrations.
app/problems/[slug]/actions.ts - Judge abstraction · Selects deterministic fake or production execution providers.
lib/judge/index.ts - Contest lifecycle · Scores contests, updates ratings, awards tiers, and publishes practice problems.
lib/contest.ts
Data & Runtime
- Self-hosted Piston · Production judge backend protected by reverse-proxy bearer authentication.
- Prisma data access · Shared PostgreSQL client and Auth.js adapter.
lib/prisma.ts - PostgreSQL · Stores membership, content, learning, contest, and notification domains.
prisma/schema.prisma - Health endpoint · Deployment health check.
app/api/health/route.ts
Connections 19
- Public routes → Join & cohort workflow: join
- Auth endpoint → Auth.js: uses
- Auth.js → Prisma data access: adapter
- Protected layout → Access guards: enforces
- Access guards → Prisma data access: checks roles and status
- Join & cohort workflow → Protected layout: submits application
- Admin operations → Access guards: admin authorization
- Admin operations → Prisma data access: manages domains
- Community engagement → Engagement services: actions and policy
- Engagement services → Prisma data access: persists engagement
- Practice & masterclasses → Problem & contest actions: submits solutions
- Teaching administration → Collaborative boards: contextual access
- Practice & masterclasses → Collaborative boards: masterclass access
- Problem & contest actions → Judge abstraction: judges code
- Problem & contest actions → Contest lifecycle: registration and scoring
- Judge abstraction → Self-hosted Piston: production provider
- Contest lifecycle → Prisma data access: standings, ratings, badges
- Prisma data access → PostgreSQL: reads and writes
- Health endpoint → PostgreSQL: checks availability