How kalprajsinh/testimonialspace works
Project type and purpose
• Full-stack web application (“TestimonialSpace”) built on Next.js (App Router).
• Frontend hosts pages, components, and client logic.
• Backend lives in two forms:
– Next.js “app/api/…” serverless routes for edge-deployed business logic.
– A separate Node/Express service in the backend/ directory that encapsulates database access, routing, and Zod validation.
• Authentication via Clerk (see clerk-nextjs.txt).
• Deployed to Vercel, serving both static assets (public/) and serverless functions.
File structure
• app/
– UI pages: e.g. app/(auth)/sign-in, app/dashboard/page.tsx
– Shared React components under app/components/
– Serverless API routes under app/api/pro and app/api/standard (route.js)
• backend/
– API entrypoint (backend/api/index.js) connecting to router.js
– Routes under backend/routes/router.js
– Database module under backend/database/database.js
– Zod schemas under backend/zod/zod.js
– Vercel config (backend/vercel.json) for serverless deployment
• public/
– Static JS, HTML, images served via CDN
• Config files: next.config.ts, middleware.ts, tsconfig.json
Key architectural insights from README
• Standard Next.js setup with app directory.
• Uses next/font for font optimization.
• Encouraged deployment on Vercel.
a. Client (Browser)
b. Vercel CDN / Edge Network
c. Next.js Frontend (React UI)
d. Next.js Serverless API routes (app/api/**)
e. Separate Backend Service (Express + Router + Zod)
f. Database (e.g. PostgreSQL or other SQL)
g. Authentication Service (Clerk)
h. Static Asset Store (public/)
Relationships and data flow
• Browser <–> Vercel CDN – serves UI pages, static assets (public/).
• Browser – calls Next.js API endpoints (/api/pro, /api/standard).
• Next.js Serverless Routes – either import & invoke backend modules directly (monorepo), or proxy requests to the separate backend service.
• Backend Service – accepts HTTP from serverless routes, runs business logic, applies Zod validation, queries/updates the database.
• Backend Service – calls out to Clerk for auth checks (token validation).
• Database returns data to Backend → Next.js API → Browser UI.
Architectural patterns & design principles
• Monorepo separation: UI vs. business logic vs. data layer
• Serverless functions for API (scalable, per‐endpoint)
• MVC-like layering:
– Controller: Next.js routes or Express router
– Model: database.js module
– Validation: Zod schemas
• Edge/CDN caching for static assets & optimized fonts via next/font
Technologies & frameworks
• Frontend: Next.js (App Router), React, TypeScript
• API: Next.js serverless routes, Express in backend/
• Validation: Zod
• Database: SQL (via backend/database/database.js)
• Auth: Clerk
• Deployment: Vercel (with custom vercel.json for backend)
• Clear component labels