# benjiavdullahu/bidboard architecture

> Architecture diagram of the GitHub repository benjiavdullahu/bidboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/benjiavdullahu/bidboard
- Repository: https://github.com/benjiavdullahu/bidboard

## Overview

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: [`src/app/page.tsx`](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/page.tsx) (Leaderboard), [`src/lib/prisma.ts`](https://github.com/benjiavdullahu/bidboard/blob/main/src/lib/prisma.ts) (Prisma client), [`src/app/api/uploadthing/route.ts`](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/uploadthing/route.ts) (Upload API), [`src/app/api/env-check/route.ts`](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/env-check/route.ts) (Env check)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Next.js app"]
  node_page["Leaderboard<br/>page<br/>[page.tsx]"]
  node_layout["Shell<br/>layout<br/>[layout.tsx]"]
  node_providers["Providers<br/>[providers.tsx]"]
  node_styles["Global CSS<br/>styles<br/>[globals.css]"]
  node_test_upload_page["Upload test<br/>page<br/>[page.tsx]"]
  node_checkout_route["Create checkout<br/>api route<br/>[route.ts]"]
  node_stripe_webhook_route["Stripe webhook<br/>api route<br/>[route.ts]"]
  node_leaderboard_route["Leaderboard API<br/>api route<br/>[route.ts]"]
  node_update_logo_route["Update logo<br/>api route<br/>[route.ts]"]
  node_uploadthing_route["Upload API<br/>api route<br/>[route.ts]"]
  node_env_check_route["Env check<br/>api route<br/>[route.ts]"]
end

subgraph group_data["Data layer"]
  node_schema["Schema<br/>[schema.prisma]"]
  node_seed["Seed data<br/>prisma script<br/>[seed.ts]"]
  node_clear["Clear data<br/>prisma script<br/>[clear.ts]"]
  node_dev_db[("Dev DB<br/>sqlite database<br/>[dev.db]")]
end

subgraph group_infra["Integration layer"]
  node_uploadthing_core["Upload core<br/>upload config<br/>[core.ts]"]
  node_prisma_client["Prisma client<br/>orm client<br/>[prisma.ts]"]
  node_uploadthing_shared["Upload config<br/>shared util<br/>[uploadthing.ts]"]
end

node_layout -->|"wraps"| node_page
node_providers -->|"context"| node_page
node_styles -->|"styles"| node_page
node_page -.->|"polls"| node_leaderboard_route
node_page -->|"starts payment"| node_checkout_route
node_page -->|"uploads"| node_uploadthing_route
node_test_upload_page -->|"tests upload"| node_uploadthing_route
node_checkout_route -.->|"hands off"| node_stripe_webhook_route
node_stripe_webhook_route -->|"persists"| node_prisma_client
node_leaderboard_route -->|"reads"| node_prisma_client
node_update_logo_route -->|"updates"| node_prisma_client
node_uploadthing_route -->|"uses"| node_uploadthing_core
node_uploadthing_core -->|"shares config"| node_uploadthing_shared
node_prisma_client -->|"models"| node_schema
node_seed -->|"seeds"| node_schema
node_clear -->|"resets"| node_dev_db
node_prisma_client -->|"connects"| node_dev_db
node_env_check_route -->|"verifies db"| node_prisma_client
node_env_check_route -->|"verifies upload"| node_uploadthing_route
node_env_check_route -->|"verifies payments"| node_stripe_webhook_route

click node_page "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/page.tsx"
click node_layout "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/layout.tsx"
click node_providers "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/providers.tsx"
click node_styles "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/globals.css"
click node_test_upload_page "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/test-upload/page.tsx"
click node_checkout_route "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/create-checkout/route.ts"
click node_stripe_webhook_route "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/stripe-webhook/route.ts"
click node_leaderboard_route "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/leaderboard/route.ts"
click node_update_logo_route "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/update-logo/route.ts"
click node_uploadthing_route "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/uploadthing/route.ts"
click node_uploadthing_core "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/uploadthing/core.ts"
click node_env_check_route "https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/env-check/route.ts"
click node_prisma_client "https://github.com/benjiavdullahu/bidboard/blob/main/src/lib/prisma.ts"
click node_uploadthing_shared "https://github.com/benjiavdullahu/bidboard/blob/main/src/utils/uploadthing.ts"
click node_schema "https://github.com/benjiavdullahu/bidboard/blob/main/prisma/schema.prisma"
click node_seed "https://github.com/benjiavdullahu/bidboard/blob/main/prisma/seed.ts"
click node_clear "https://github.com/benjiavdullahu/bidboard/blob/main/prisma/clear.ts"
click node_dev_db "https://github.com/benjiavdullahu/bidboard/blob/main/prisma/dev.db"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_page,node_layout,node_providers,node_styles,node_test_upload_page,node_checkout_route,node_stripe_webhook_route,node_leaderboard_route,node_update_logo_route,node_uploadthing_route,node_env_check_route toneBlue
class node_schema,node_seed,node_clear,node_dev_db toneAmber
class node_uploadthing_core,node_prisma_client,node_uploadthing_shared toneMint
```

## Components

### Next.js app

UI shell, pages, and route handlers

- [Leaderboard](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/page.tsx): page · Main public leaderboard view · `src/app/page.tsx`
- [Shell](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/layout.tsx): layout · Shared app frame and document structure · `src/app/layout.tsx`
- [Providers](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/providers.tsx): client providers · Client-side app context wrapper · `src/app/providers.tsx`
- [Global CSS](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/globals.css): styles · Application-wide styling · `src/app/globals.css`
- [Upload test](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/test-upload/page.tsx): page · Utility page for verifying logo uploads · `src/app/test-upload/page.tsx`
- [Create checkout](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/create-checkout/route.ts): api route · Starts Stripe checkout for a leaderboard spot · `src/app/api/create-checkout/route.ts`
- [Stripe webhook](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/stripe-webhook/route.ts): api route · Receives payment events and confirms purchases · `src/app/api/stripe-webhook/route.ts`
- [Leaderboard API](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/leaderboard/route.ts): api route · Serves ranked leaderboard data · `src/app/api/leaderboard/route.ts`
- [Update logo](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/update-logo/route.ts): api route · Associates an uploaded logo with an entry · `src/app/api/update-logo/route.ts`
- [Upload API](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/uploadthing/route.ts): api route · UploadThing request handler · `src/app/api/uploadthing/route.ts`
- [Env check](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/env-check/route.ts): api route · Validates deployment environment and integration config · `src/app/api/env-check/route.ts`

### Data layer

Prisma schema, seed scripts, and local database

- [Schema](https://github.com/benjiavdullahu/bidboard/blob/main/prisma/schema.prisma): prisma schema · Database model definitions · `prisma/schema.prisma`
- [Seed data](https://github.com/benjiavdullahu/bidboard/blob/main/prisma/seed.ts): prisma script · Initial database population script · `prisma/seed.ts`
- [Clear data](https://github.com/benjiavdullahu/bidboard/blob/main/prisma/clear.ts): prisma script · Database reset/cleanup script · `prisma/clear.ts`
- [Dev DB](https://github.com/benjiavdullahu/bidboard/blob/main/prisma/dev.db): sqlite database · Local development database file · `prisma/dev.db`

### Integration layer

Shared server helpers and external service adapters

- [Upload core](https://github.com/benjiavdullahu/bidboard/blob/main/src/app/api/uploadthing/core.ts): upload config · UploadThing route configuration · `src/app/api/uploadthing/core.ts`
- [Prisma client](https://github.com/benjiavdullahu/bidboard/blob/main/src/lib/prisma.ts): orm client · Shared database client · `src/lib/prisma.ts`
- [Upload config](https://github.com/benjiavdullahu/bidboard/blob/main/src/utils/uploadthing.ts): shared util · Common UploadThing client-side/server-side settings · `src/utils/uploadthing.ts`

## Connections

- 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
