How benjiavdullahu/bidboard works
1. High-level shape
- BIDBOARD is a Next.js 15 App Router application that combines a public leaderboard UI with server-side APIs for payments, ranking data, and logo uploads.
- The architecture is split into a thin presentation layer in src/app and a set of route handlers under src/app/api that own all state-changing operations.
2. Presentation layer
- src/app/page.tsx is the main product surface for viewing and interacting with the leaderboard.
- src/app/test-upload/page.tsx appears to be a separate utility page for verifying the logo upload flow.
- src/app/layout.tsx, src/app/providers.tsx, and src/app/globals.css define the shared shell, global styling, and client-side providers.
3. Core backend boundary
- Server logic is exposed exclusively through Next.js route handlers:
- create-checkout
- stripe-webhook
- leaderboard
- update-logo
- uploadthing
- env-check
- This keeps the browser-facing UI separate from the mutation and integration points.
4. Payments flow
- The payment path starts at src/app/api/create-checkout/route.ts, which likely creates a Stripe Checkout session for a chosen leaderboard spot.
- Stripe then calls src/app/api/stripe-webhook/route.ts after checkout events complete.
- The webhook is the authoritative point where paid purchases are confirmed and persisted.
5. Ranking/data flow
- The leaderboard is stored in the database and read through src/app/api/leaderboard/route.ts.
- The README says the UI refreshes every 5 seconds, so the frontend likely polls this endpoint rather than using push-based realtime infrastructure.
- The ranking logic is centered on payment amount: higher spend means a higher position.
6. Database layer
- Prisma is the ORM layer, with the shared client in src/lib/prisma.ts.
- The schema lives in prisma/schema.prisma, and there are explicit seed/cleanup scripts in prisma/seed.ts and prisma/clear.ts.
- The repo includes prisma/dev.db, which suggests local SQLite for development, even though the README positions PostgreSQL as the intended production database.
7. Media and logo uploads
- Logo handling is separated from payments and ranking via UploadThing integration.
- src/app/api/uploadthing/core.ts and src/app/api/uploadthing/route.ts provide the upload backend, while src/utils/uploadthing.ts holds shared upload configuration.
- src/app/api/update-logo/route.ts likely links an uploaded image URL to an existing leaderboard entry.
8. Operational/configuration boundary
- src/app/api/env-check/route.ts is an explicit environment validation endpoint, probably used to verify Stripe/database/upload configuration before deployment or during setup.
- DEPLOY_CHECKLIST.md, SETUP.md, setup.js, and vercel.json indicate this app is meant to be deployed to Vercel with attention to webhook and env-var correctness.
9. External services
- Stripe is the main external payment system and webhook source.
- UploadThing is the external file upload service for logos.
- The database is abstracted through Prisma and is expected to be a relational store, most likely PostgreSQL in production.
10. Deployment/runtime model
- The app runs as a server-rendered Next.js deployment on Vercel, with API routes handling all backend interactions in the same runtime boundary as the frontend.
- There is no separate backend service in this repo; the full system is a single deployable web application with embedded APIs.
11. Primary data lifecycle
- User selects a spot on the UI → frontend requests checkout creation → Stripe processes payment → Stripe webhook confirms payment → Prisma persists/updates the record → leaderboard endpoint serves updated rankings → frontend refreshes the view.
12. What to draw in an architecture diagram
- Show one client app connected to three main backend concerns: payments (Stripe), uploads (UploadThing), and persistence (Prisma/database).
- Put leaderboard as a read path from database to UI, and create-checkout + stripe-webhook as the write path that controls ranking changes.
- Keep update-logo as a separate mutation path tied to uploaded media, not to payment processing.
Main entry points: page.tsx Leaderboard · prisma.ts Prisma client · uploadthing/route.ts Upload API · env-check/route.ts Env check
Components 18
Next.js app
UI shell, pages, and route handlers
- Leaderboard · Main public leaderboard view
src/app/page.tsx - Shell · Shared app frame and document structure
src/app/layout.tsx - Providers · Client-side app context wrapper
src/app/providers.tsx - Global CSS · Application-wide styling
src/app/globals.css - Upload test · Utility page for verifying logo uploads
src/app/test-upload/page.tsx - Create checkout · Starts Stripe checkout for a leaderboard spot
src/app/api/create-checkout/route.ts - Stripe webhook · Receives payment events and confirms purchases
src/app/api/stripe-webhook/route.ts - Leaderboard API · Serves ranked leaderboard data
src/app/api/leaderboard/route.ts - Update logo · Associates an uploaded logo with an entry
src/app/api/update-logo/route.ts - Upload API · UploadThing request handler
src/app/api/uploadthing/route.ts - Env check · Validates deployment environment and integration config
src/app/api/env-check/route.ts
Data layer
Prisma schema, seed scripts, and local database
- Schema · Database model definitions
prisma/schema.prisma - Seed data · Initial database population script
prisma/seed.ts - Clear data · Database reset/cleanup script
prisma/clear.ts - Dev DB · Local development database file
prisma/dev.db
Integration layer
Shared server helpers and external service adapters
- Upload core · UploadThing route configuration
src/app/api/uploadthing/core.ts - Prisma client · Shared database client
src/lib/prisma.ts - Upload config · Common UploadThing client-side/server-side settings
src/utils/uploadthing.ts
Connections 20
- Shell → Leaderboard: wraps · Provides shared app shell for the main UI
- Providers → Leaderboard: context · Supplies client-side providers to the leaderboard page
- Global CSS → Leaderboard: styles · Global CSS applied to the UI
- Leaderboard → Leaderboard API: polls · Refreshes leaderboard data on an interval
- Leaderboard → Create checkout: starts payment · Requests checkout session creation for a spot
- Leaderboard → Upload API: uploads · Uses upload backend for logo media
- Upload test → Upload API: tests upload · Verifies the logo upload flow
- Create checkout → Stripe webhook: hands off · Stripe completes payment asynchronously via webhook
- Stripe webhook → Prisma client: persists · Writes confirmed purchase state to the database
- Leaderboard API → Prisma client: reads · Loads ranked data from persistence
- Update logo → Prisma client: updates · Attaches uploaded logo details to an entry
- Upload API → Upload core: uses · Route handler delegates to UploadThing core config
- Upload core → Upload config: shares config · Uses shared upload settings and helpers
- Prisma client → Schema: models · Client is generated from the Prisma schema
- Seed data → Schema: seeds · Populates data according to the schema
- Clear data → Dev DB: resets · Clears local development database contents
- Prisma client → Dev DB: connects · Local development database target
- Env check → Prisma client: verifies db · Checks that database access is configured
- Env check → Upload API: verifies upload · Checks upload integration readiness
- Env check → Stripe webhook: verifies payments · Checks Stripe-related configuration