How braidpay/code-sample-consultation works
Project type and purpose
• This is a monolithic full-stack web application built with Next.js’s App Router.
• Purpose: a consultation-booking front end with integrated payment processing via BraidPay.
• Key functionality: UI pages for browsing and booking consultations, client-side polling of payment status, serverless API routes for checking payment status and receiving BraidPay webhooks.
File structure
• Top-level:
• app/ ← Next.js App Router
– page.tsx ← main booking page (React Server/Client components)
– layout.tsx ← global layout
– globals.css ← global styles
– api/ ← serverless endpoints
· check-payment-status/route.ts
· webhook/route.ts
• components/ui/ ← Shadcn UI primitives organized by component
• hooks/ ← custom React Hooks (use-mobile, use-toast)
• lib/utils.ts ← shared utilities
• config files: next.config.js/ts, tailwind.config.js/ts, postcss.config.mjs, tsconfig.json
• package.json + lockfile
• public/ ← static assets
README
• Confirms Next.js + Shadcn UI + Tailwind CSS + BraidPay integration.
• Describes serverless webhook and polling for real-time payment updates.
• Deployment target: Vercel (serverless functions).
a. Main components:
• Client (Browser / Mobile)
• Next.js application (deployed on Vercel or similar)
• Frontend (React + Shadcn UI + Tailwind)
• Serverless API routes
· /api/check-payment-status
· /api/webhook
• External service: BraidPay
• (Optional) CDN / Edge network
b. Relationships & interactions:
1. User → Browser → Next.js Frontend (SSR/Client)
2. Frontend → BraidPay Checkout (redirect to hosted payment page)
3. BraidPay → Browser (checkout page) → User completes payment
4. BraidPay → Next.js /api/webhook (POST webhook)
5. Frontend polls /api/check-payment-status → Next.js reads stored status (in-memory or persistent store)
c. Architectural patterns & principles:
• Monolithic front+back but logically separated layers
• Serverless functions for event-driven webhook handling
• Client polling pattern for real-time updates
• Component-based UI with Shadcn primitives
• CSS utility framework (Tailwind) for styling consistency
d. Key technologies:
• Next.js (App Router, React Server/Client components)
• Shadcn UI (components/ui/)
• Tailwind CSS (tailwind.config.ts)
• Vercel or any serverless platform
• BraidPay API & Webhooks
• TypeScript
Elements
• Browser (Client)
• Next.js Frontend (SSR/CSR)
• API Routes (check-payment-status, webhook)
• BraidPay Service
• Blue for UI components
• Green for serverless/API
• Orange for external services
Detailed capture of essential elements
• Storage or in-memory state if payment status is cached (you may note “Redis” or “in-memory”).
• If using Vercel, illustrate “Vercel Edge CDN → Next.js Functions → BraidPay”.