






Royal Parking Services
British Columbia, Canada
Web application for a Canadian parking enforcement company that combines the public site with a client portal: violation lookup by plate, photo evidence and Stripe payments. It includes business management of permits, vehicles, saved cards and invoicing.
IncludesStripe paymentsClient portalPermit management




Overview
The challenge
Links
Private — client project
System architecture
The application is a single Next.js App Router deployment serving three audiences from one codebase, separated by route groups rather than by separate apps: a public marketing site and anonymous payment checkout, the credential flows on their own full-screen layout, and the authenticated client portal with its own sidebar shell. All three share one HTTP client, one Redux store and one Tailwind design system, with public-path carve-outs where the anonymous checkout must not inherit authenticated behaviour.
Application Architecture
- Next.js 15 App Router with three route groups: public, credentials and private dashboard.
- Server Components by default for marketing and article pages, with client components isolated to interactive surfaces.
- A single shared axios instance with request and response interceptors, plus a public-path allowlist so the anonymous checkout skips both token injection and 401 redirects.
- A four-step client-side checkout state machine held in one typed state object, with a separate 3-D Secure return route reconstructing state from URL parameters.
- Hybrid content: CMS with ISR for the blog, committed TypeScript modules for resources and service copy.
Platform Features
- Public notice lookup by licence plate or notice number through a single unified search term.
- Multi-notice selection with live total and per-status payability filtering.
- Lot rule display with signage photography, deduplicated per lot.
- Permit issuance with per-weekday time programs and a dynamic vehicle array.
- Debounced server-side permit-number availability checking.
- Saved payment cards with default-card selection and hosted invoice receipts.
- Contact form with phone-number normalisation and a dynamically imported map.
Data Model
- Notice — a twelve-value status lifecycle, four distinct amount fields, reduction expiry, repeat-offender flag, plus relations to officer, violation, lot, images and lot rules.
- Permit — type, validity period, holder, value, date range, parking lot relation, program schedule array and vehicle array.
- Company as the tenant root, carrying contract limits, pricing fields, billing period and admin profile.
- Invoice and PaymentMethod, Stripe-backed, with receipt URLs and card metadata.
- A consistent paginated envelope across list endpoints.
Authentication
- JWT Bearer
- Axios interceptors
- 401 auto-logout
- Route guard
- Surface disambiguation
- Open-redirect sanitisation
- Forgot / reset password
- Public-path exemptions
Infrastructure & deployment
Self-hosted on a Linux VPS behind PM2, deployed by Bitbucket Pipelines over SSH, with separate backend URLs, CMS credentials and Stripe keys per environment.
Hosting & Deploy
- Node 20 process managed by PM2 serving the Next.js production server on a dedicated port.
- Bitbucket Pipelines, branch-triggered: main deploys production, develop deploys staging, each piping a deploy script over SSH to a deployer account.
- The deploy script regenerates the environment file from scratch per deploy, installs, builds with a raised heap limit, then restarts or starts under PM2.
Secrets & Configuration
- All values come from Bitbucket deployment variables, with each validated as non-empty before being written.
- The script was refactored to pass variables by name through the SSH environment rather than positionally, after SSH argument flattening caused one empty value to shift every subsequent argument and silently corrupt the environment.
- The deploy-time environment flag distinguishes production from staging behaviour at runtime.
Delivery
- Next.js image optimization with AVIF and WebP, and a remote-pattern allowlist restricted to the CMS upload host.
- A shared multi-project CMS instance, with this site scoping its queries by project slug.
- PM2 process logs plus a per-application deployment log directory.
Built with
Two Stripe integrations coexist, each matched to its flow. The anonymous driver checkout uses PaymentIntents with the Payment Element; the authenticated portal stores cards through the tokenization API. Amount authority is entirely server-side in both.
Public Checkout
- One-off payment against one or more outstanding violation notices — no subscriptions, no marketplace, no split payments.
- The create-intent endpoint receives notice identifiers and a plate number and no amount; the returned client secret mounts the Payment Element.
- The intent is pinned to card server-side, which suppresses wallet prompts and save-card offers — an intentional choice for an anonymous one-off payment.
- Currency is CAD, formatted for the en-CA locale, with the Stripe Elements locale pinned to prevent browser-language leakage into an English-only site.
Strong Customer Authentication
- Confirmation runs with redirect-if-required: non-redirect payments resolve in place, redirect payments land on a dedicated return route.
- The return route retrieves the PaymentIntent to obtain canonical status rather than trusting the redirect status parameter.
- The confirm endpoint is idempotent by backend contract, so the synchronous and 3-D Secure return paths can both call it safely.
- Confirm re-validates notice identifiers and plate server-side, so parameters forwarded through the return URL are explicitly not a trust boundary.
Order States & Saved Cards
- Order state is driven by the notice status lifecycle — new, partial payment and paid in full, plus reminder and appeal states.
- Three statuses are non-payable online and are filtered before selection.
- Outcome surface: confirmation number plus optional hosted receipt URL on both the in-place success step and the return page.
- Portal saved cards use tokenization against a card element, posting only the token — card numbers never reach the application backend.
- A custom Stripe appearance theme matched to the brand palette across both flows.
Public Site & Checkout
- Marketing site: Home with animated stat counters and feature carousels, Services with anchor-linked sections, a dedicated mobile-pay page, About, Resources, Blog, article detail, Contact, Privacy Policy and Terms of Use.
- Public payment checkout: a four-step wizard plus a dedicated 3-D Secure return route, with evidence display, multi-notice selection and the Stripe Payment Element.
Client Portal
- Sign-in, forgot-password and reset-password flows.
- Permit issuance form with programs and multi-vehicle registration.
- Permit register with plate search, detail, edit and cancel dialogs, plus vehicle-count statistics.
- Saved card management, invoice history with hosted receipts, and company settings.
Content & Design System
- Five long-form resource articles and four blog posts authored as structured TypeScript data with a typed block model, rendered through one shared article component that also renders CMS-sourced HTML.
- A custom Tailwind token layer over daisyUI with reusable banner, FAQ, pagination and select primitives, a route-transition loader and a scroll-to-top control.
- Integrations delivered: Stripe across two flows, the CMS, a chat widget with per-route suppression, and an interactive map.