Architecture
System Diagram
┌─────────────────────────────────────────────────────────────────────────┐
│ myeasyguide.com │
│ Next.js 15.5 — Public Frontend │
│ │
│ Serves: Visitors, Travelers, Suppliers, Authors, Admins │
│ Port (dev): 3001 │
└──────────────┬──────────────────────────────┬───────────────────────────┘
│ │
│ NEXT_PUBLIC_API_BASE_URL │ NEXT_PUBLIC_POST_URL
│ (API calls + /api/v1 │ (direct CMS reads)
│ rewrites, proxied) │
▼ ▼
┌──────────────────────────────┐ ┌──────────────────────────────────────┐
│ api.myeasyguide.com │ │ cms.myeasyguide.com │
│ Express 5 — REST API │ │ Next.js 16 — CMS │
│ │ │ │
│ DB: myeasyguide_prod │ │ DB: cms_myeasyguide │
│ (PostgreSQL + Prisma 7) │ │ (PostgreSQL + Prisma 7) │
│ │ │ │
│ ■ Activities/departures │ │ ■ Posts / categories │
│ ■ Catalog (locations, │ │ ■ Authors / permissions │
│ categories, keywords, │ │ ■ AI generation (Claude) │
│ food, transport, etc.) │ │ ■ Media library / uploads │
│ ■ Users / suppliers / auth │ │ ■ Cities / countries / tags │
│ ■ Bookings / payments │ │ ■ Redirects / audit log │
│ ■ Reviews / wishlists │ │ ■ OpenAPI spec │
│ ■ Newsletter / inquiries │ │ │
│ ■ Payouts / revenue │ │ │
│ ■ Legal pages / media │ │ │
│ ■ Recombee / popularity │ │ │
└──────────────────────────────┘ └──────────────────────────────────────┘Data Flow
Guest-facing content
Activities, suppliers, bookings, payments, reviews — The frontend fetches commerce data from
api.myeasyguide.comviaNEXT_PUBLIC_API_BASE_URL. Next.jsrewrites()innext.config.tsproxy/api/v1/:path*to the Express backend and normalise duplicate/api//api/v1suffixes.Blog posts, travel guides, locations/countries — The frontend fetches content directly from
cms.myeasyguide.comviaNEXT_PUBLIC_POST_URL(defaulthttps://cms.myeasyguide.com). The CMS runs independently with its own database.Search — The search page queries both backends in parallel: CMS posts and Express activities.
Images — CMS uploads are served by the CMS, with resize (
?w=), LQIP (?blur) and a disk cache. The frontend proxies them through/uploads/cms/[...path]. Activity images use Cloudflare Images (and the frontendimageLoader).Sitemap —
next-sitemap+ custom scripts fetch CMS posts/locations to build sitemaps.Revalidation — When CMS publishes/updates a post, it calls the frontend
POST /api/revalidatewithx-revalidation-secretto refresh cached pages.
Admin content
- Platform admin — The frontend has admin routes under
app/admin/for activities, suppliers, users, bookings, revenue, payouts, legal pages, etc. via the Express API. - Content admin — The CMS has its own admin at
app/admin/for posts/categories/authors/media/redirects/AI generation.
URL Routing
The frontend uses a catch-all route [...slug]. Resolution order:
Request: /nepal/pokhara/trekking/everest-base-camp-trek-abc123
1. Exact CMS lookup by canonicalUrl (getPostByPath) → render post
2. Exact activity lookup by canonicalPath (getActivityByPath) → render activity
3. Category / country / city / location landing page
4. Trip-category page
5. 404Examples:
| URL | Resolves to |
|---|---|
/travel-guide/best-time-to-visit | CMS post (canonicalUrl) |
/nepal/pokhara/trekking/everest-base-camp-trek-123 | Activity (canonicalPath) |
/nepal | Country/location page |
/pokhara | City/location page |
/nepal/trekking | Category page |
/pokhara/trekking | Trip-category page |
The frontend's middleware applies the CMS Redirect table (301/302 via /api/redirects/resolve). Post-level canonical and urlHistory redirects are resolved by the catch-all route by full canonical path before rendering, so they are not guessed from bare slugs.
Database Independence
The API and CMS use completely separate PostgreSQL databases:
| Property | API | CMS |
|---|---|---|
| Database name | myeasyguide_prod | cms_myeasyguide |
| Host | localhost | localhost |
| Port | 5432 | 5432 |
There are no cross-database foreign keys or direct database-level communication. They share the same Postgres instance but operate on separate databases.
Key Architectural Decisions
Normalised catalog instead of flat activity columns
The API used to store location/category/type as flat fields on Activity. It now uses a normalised catalog:
- Location tree (
LocationType, parent/child,locationAncestorsdenormalised for filtering) - Category, Keyword
- FoodType / FoodFormat / DietaryRestriction
- TransportType, SuitabilityConcern, ActivityRestriction, MandatoryItem
This supports faceted filtering, reusable catalog management, and location hierarchies without duplicating text.
Why split the CMS from the API?
Blog management originally lived inside the Express API. As content needs grew:
- Blog CRUD competed with commerce endpoints for resources
- Editors needed rich text, scheduling, AI generation, media tools
- Content deployments were tied to API restarts
- Editors authenticated through the same system as suppliers
The CMS was extracted as a standalone Next.js app with its own database, admin UI, API layer, permissions, and scheduler.
Payments are fulfilled idempotently
Stripe webhooks and the frontend status poll can both confirm a booking. The confirm transaction uses a conditional updateMany on PENDING_PAYMENT so only one path wins and emails are sent once. Expired/cancelled sessions release the held departure spots.
Why not a monolith?
The project started as a monolith. The editorial extraction is part of splitting concerns. Future migrations may move more admin domains out of the Express API.