How maaz2022/reseller-portall works
Project type and purpose
• This is a full-stack, serverless web application (“Reseller Portal”) built on Next.js 14 with React and TypeScript.
• It provides free and premium user dashboards, product listing, shopping cart, payment flows via Stripe, and user authentication via Firebase.
File-structure analysis
Top-level folders and files reveal:
• app/
• app/api/... → Next.js API routes (serverless functions) for payments and products
• app/components/ → shared React UI components (Navbar, ProductGallery, StripePaymentForm, etc.)
• app/dashboard, premium-dashboard, signup, login, payment pages → routing structure
• app/context/ → React Context providers (AuthContext, CartContext)
• lib/ → Firebase client (lib/firebase.ts), Firebase Admin (lib/firebase-admin.ts), utility helpers
• public/ → static assets
• next.config.js, middleware.ts → build/deployment config and custom routing/auth middleware
• tailwind.config.js, postcss.config.mjs → styling engine setup
README insights
• Tech stack: Next.js, React, TypeScript, Tailwind, shadcn/ui, Firebase Auth & Firestore, Zod for validation, Stripe payment.
• High-level flow: user sign-up → dashboard (free/premium) → product browsing → cart → checkout → payment intent → payment confirmation → success page.
Main components
a. Client (Browser)
• Next.js pages (React UI)
• shadcn/ui + Tailwind CSS for styling
• Stripe.js for payment UI
• React Contexts for Auth & Cart state
b. Next.js Serverless Layer
• API route: /api/create-payment-intent
• API route: /api/verify-payment
• API route: /api/verify-payment-status
• API route: /api/products (list, details)
• Middleware.ts for auth-guard / route protection
• Zod validation on incoming requests
c. Firebase
• Firebase Authentication (client + admin SDK)
• Firestore database (users, products, orders/payments)
d. Stripe (external payment service)
• PaymentIntents, webhooks (if used)—Next.js functions call Stripe SDK
e. Hosting/Deployment
• Vercel or equivalent (serverless function hosting + static content)
Relationships and data-flow
• Browser → Next.js pages → fetch(“/api/products”) → Next.js API → Firestore read → returns product data
• Browser (cart/checkout) → POST “/api/create-payment-intent” → API → Stripe SDK → returns client secret → Browser + Stripe.js → confirmCardPayment → Stripe → webhook or direct confirm → Browser calls “/api/verify-payment-status” → API → update Firestore order status
• Browser registration/login → Firebase Auth client SDK → Next.js AuthContext → on success writes user record to Firestore via Admin SDK in protected API route if needed
• Protected pages (dashboard, premium-dashboard) guarded by middleware.ts checking Firebase token via Admin SDK
Architectural patterns and principles
• File-based routing (Next.js app directory)
• Serverless functions for backend logic (zero-server management)
• Separation of concerns: UI components, data-access (lib/firebase, lib/firebase-admin), business logic in API routes
• Context API for global state (authentication, shopping cart)
• API layer with input validation (Zod)
• External services (Firebase, Stripe) as pluggable components