How ayushrai7/parkmate works
1. Overall shape
- ParkMate is a single Next.js 14 monolith: the same app serves the UI, API routes, authentication, booking logic, invoice handling, and owner/admin workflows.
- The main architectural boundary is between the browser-facing App Router pages/components and the server-side route handlers under src/app/api.
2. Client-facing application layers
- The app uses the Next.js App Router with page entrypoints for the main experiences: homepage, login, booking, invoice, owner dashboard, and auth callback.
- Most screens are composed from feature-specific React components in src/components/*, with a shared UI kit in src/components/ui built around Shadcn-style primitives.
3. Authentication and session management
- Authentication is centralized in NextAuth.js (src/app/api/auth/[...nextauth]/route.ts) with Google OAuth and Credentials sign-in flows.
- Sessions are JWT-based, and there is app-level protection via middleware.ts, which likely gates authenticated routes and role-specific access.
- Supporting auth utilities live in src/lib/auth.ts and src/lib/auth-utils.ts, with NextAuth type extensions in src/types/next-auth.d.ts.
4. Role-based architecture
- The system explicitly separates Users and Venue Owners.
- There are dedicated server endpoints for role assignment and onboarding, including api/auth/set-role, api/auth/signup/user, and api/owner.
- The UI mirrors this split with distinct flows and pages for login, booking, and owner management, so role is a first-class part of the navigation and authorization model.
5. Core booking flow
- Booking is handled through src/app/api/booking and src/app/api/booking/[bookingId], suggesting both creation and booking-level retrieval/update operations.
- The user-facing booking page uses dedicated components for searching venues, viewing venue cards, fare summary, and booking form submission.
- The backend likely coordinates slot selection, persistence, and status transitions such as Pending → Confirmed → Expired.
6. Payments and confirmation
- Payment processing is separated into src/app/api/payment, with Stripe as the external payment gateway.
- A dedicated webhook endpoint at src/app/api/webhook/stripe is used to confirm payment events server-side, which is important for reliable booking confirmation.
- This webhook boundary is the key integration point where external payment state is translated into internal booking state.
7. Invoice generation and storage
- After successful payment, the app exposes invoice functionality through src/app/api/invoice/upload, and a dedicated invoice page in the UI.
- The README indicates invoices are generated as PDFs and stored in AWS S3, with download access controlled through pre-signed URLs.
- The invoice UI is split into header, details, footer, layout, and download controls, indicating a document-centric rendering flow rather than a generic page.
8. Owner operations and venue management
- Owners have a separate dashboard under src/app/owner and APIs such as src/app/api/owner and src/app/api/venues.
- The owner interface includes venue creation, search/filtering, and booking tables, which suggests it is the administrative control plane for supply-side management.
- This is the main place where venue inventory and booking oversight are exposed to non-end-user operators.
9. Data layer and persistence
- The app uses Prisma ORM with a PostgreSQL database, likely hosted on Supabase as described in the README.
- The prisma/migrations history shows the schema evolved around NextAuth integration and a later merge of user/owner tables, reinforcing that identity and role data are tightly coupled in the DB model.
- src/lib/prisma.ts is the shared database client boundary used by route handlers and server-side logic.
10. Infrastructure and deployment boundaries
- The repository is containerized with a Dockerfile, and GitHub Actions (.github/workflows/deploy.yml) handles CI/CD deployment.
- The README indicates deployment to AWS EC2, with AWS S3 as an external storage dependency and UptimeRobot for availability monitoring.
- In architectural terms, the app is deployed as one web service container backed by managed external services: Postgres, Stripe, S3, and OAuth providers.
11. Shared app utilities
- src/lib/s3.ts encapsulates S3 integration, while src/lib/utils.ts and src/hooks/* support reusable client behavior.
- Global providers and UI helpers (src/components/Providers.tsx, toast hooks, mobile hooks) indicate the app is designed around a shared client runtime with server-rendered pages plus interactive client components.
12. Diagramming takeaway
- A good architecture diagram should show:
- Browser/UI → Next.js App Router pages/components
- Middleware/Auth guarding role-based access
- Next.js API routes for booking, payment, invoice, venues, and owner operations
- NextAuth + Google/Credentials for identity
- Prisma → PostgreSQL for persistence
- Stripe webhooks as an external event ingress
- S3 for invoice PDFs
- Docker/GitHub Actions/EC2 as the deployment path
Main entry points: layout.tsx App Router · prisma.ts Prisma DB · [...nextauth]/route.ts NextAuth · booking/route.ts Booking API
Components 23
Client App
Browser-facing App Router pages and shared React components.
- App Router · Top-level Next.js 14 application shell and route composition.
src/app/layout.tsx - Homepage · Public entry experience and marketing content.
src/app/homepage/page.tsx - Login · Authentication entrypoint with role and sign-in switching.
src/app/login/page.tsx - Booking · User booking flow for venue search, selection, and submission.
src/app/booking/page.tsx - Invoice · Invoice viewing and download experience.
src/app/invoice/page.tsx - Owner Dashboard · Venue-owner control plane for inventory and bookings.
src/app/owner/page.tsx - UI Kit · Reusable Shadcn-style primitives shared across screens.
src/components/ui/button.tsx - Auth UI · Login form, Google sign-in, and role selection UI.
src/components/login/Form.tsx - Booking UI · Venue search, cards, fare summary, and booking form.
src/components/booking/Form.tsx - Invoice UI · Invoice layout, metadata, and download controls.
src/components/invoice/InvoiceLayout.tsx - Owner UI · Owner dashboard controls for venues and booking tables.
src/components/owner/BookingsTable.tsx
Server Core
Next.js route handlers, auth, persistence, and integrations.
- Middleware · App-level protection for authenticated and role-based access.
middleware.ts - NextAuth · Central authentication route with Google and credentials flows.
src/app/api/auth/[...nextauth]/route.ts - Auth Routes · Session refresh, role setting, and user signup endpoints.
src/app/api/auth/set-role/route.ts - Booking API · Create and manage bookings by booking ID.
src/app/api/booking/route.ts - Payment API · Stripe-backed payment initiation and coordination.
src/app/api/payment/route.ts - Stripe Webhook · External payment confirmation events translated into booking state.
src/app/api/webhook/stripe/route.ts - Invoice API · Invoice generation and upload workflow.
src/app/api/invoice/upload/route.ts - Owner API · Owner onboarding and supply-side management endpoints.
src/app/api/owner/route.ts - Venues API · Venue listing and management access for owner workflows.
src/app/api/venues/route.ts - Prisma DB · Shared Prisma client and PostgreSQL-backed domain storage.
src/lib/prisma.ts
Delivery
Deployment and external services.
- S3 Storage · Invoice PDF storage and pre-signed download delivery.
src/lib/s3.ts - CI/CD · Container build and GitHub Actions deployment pipeline.
Dockerfile
Connections 23
- App Router → Homepage: routes to · App Router serves the public landing experience.
- App Router → Login: routes to · App Router serves the login flow.
- App Router → Booking: routes to · App Router serves the booking flow.
- App Router → Invoice: routes to · App Router serves invoice pages.
- App Router → Owner Dashboard: routes to · App Router serves the owner dashboard.
- Homepage → UI Kit: composes · Landing screen uses shared UI primitives.
- Login → Auth UI: composes · Login screen uses authentication-specific components.
- Booking → Booking UI: composes · Booking screen is built from booking feature components.
- Invoice → Invoice UI: composes · Invoice screen is built from document components.
- Owner Dashboard → Owner UI: composes · Owner dashboard uses admin components.
- Middleware → NextAuth: protects · Middleware relies on auth state and route/session checks.
- Auth UI → NextAuth: signs in via · Client auth flows initiate NextAuth sign-in.
- NextAuth → Prisma DB: reads/writes · Auth sessions and user records are persisted through Prisma.
- Auth Routes → NextAuth: extends · Role assignment and session refresh support the main auth system.
- Booking API → Prisma DB: persists · Bookings are created and updated in the database.
- Booking API → Payment API: hands off to · Booking flow leads into payment processing.
- Payment API → Stripe Webhook: confirms via · Webhook receives Stripe payment events for final confirmation.
- Stripe Webhook → Prisma DB: updates · Payment events translate into booking state changes.
- Invoice API → S3 Storage: stores · Generated invoice PDFs are uploaded to object storage.
- Invoice API → Prisma DB: records · Invoice metadata and linkage are persisted.
- Owner API → Prisma DB: manages · Owner onboarding and management operate on shared domain data.
- Venues API → Prisma DB: queries · Venue inventory and search data come from persistence.
- CI/CD → App Router: delivers · Containerized Next.js app is deployed through CI/CD.