How talha5978/rr-tours-app works
1. Overall shape
- This is a monorepo with three main code areas: front-panel for the public customer site, admin for internal operations, and shared for cross-cutting domain logic. A separate supabase folder holds the database schema/migrations.
- The architecture is split by product surface, not by technical layer: each app owns its routes, UI, and request handlers, while shared centralizes reusable business logic.
2. Two independent React Router applications
- Both admin and front-panel are React Router v7 framework-mode apps with their own app/root.tsx, entry.client.tsx, entry.server.tsx, routes.ts, and route folders.
- This means each app has its own server-side rendering boundary, route loaders/actions, and deployment target. They are not a single SPA; they are two separately runnable web apps.
3. Front-panel responsibilities
- The public app serves browsing, booking, account, cart, reviews, auth, and content pages.
- Key route groups include tours, cities, collections, booking, cart, account, auth, payment callbacks, contact, FAQs, favourites, and miscellaneous legal pages.
- This app is the customer-facing system of record for user actions like adding to cart, checkout, review submission, and booking tracking.
4. Admin responsibilities
- The admin app focuses on operations: managing tours, categories, cities, collections, coupons, hero sections, tags, and bookings.
- It also contains booking-specific operational actions such as refunding payments, retrying Stripe checkout, exporting booking data, and sending confirmation emails.
- This is the back-office control plane for content and booking lifecycle management.
5. Route-centric server actions
- Both apps use route modules as the primary server boundary. There is a clear split between page routes and _actions routes.
- Page routes render UI and fetch data; action routes perform mutations or operational tasks such as login/logout, add-to-cart, booking updates, review CRUD, Stripe session handling, refunds, and email-triggering workflows.
- This pattern keeps mutations close to the feature area and avoids a separate backend service in the repository.
6. Shared domain layer
- shared/src/services contains the core business logic for domains such as auth, bookings, tours, reviews, coupons, categories, cities, collections, cart, checkout, emails, media, Stripe, cache, and dashboard stats.
- shared/src/schemas defines validation and input contracts for the same domains, so the apps can validate payloads consistently.
- shared/src/types holds shared TypeScript models for the domain, which suggests the apps are strongly coupled to a common data contract.
7. Data access and backend integration
- Supabase is the primary infrastructure boundary for auth, database, and likely storage. The repo includes Supabase migrations and both client/server Supabase helpers in shared/src/utils/supabase.
- shared/src/queries and the app-local app/queries files define read models used by the routes and components, keeping data-fetching logic separate from presentation.
- There is also Redis/cache support via shared/src/utils/redis.ts and cache-related services, which implies some reads or event invalidation are cached.
8. Authentication and authorization
- Auth is shared across apps through Supabase-based helpers and middleware, with server-side auth utilities and middleware abstractions in shared/src/middlewares and shared/src/utils/auth-utils.server.ts.
- The customer app supports email/password and Google login, while the admin app includes login/logout and protected operational routes.
- The architecture relies on route-level protection rather than a separate auth microservice.
9. Checkout, payments, and booking lifecycle
- The customer journey flows from browsing tours to cart, selecting dates/options, creating a checkout session, and completing payment through Stripe.
- The booking lifecycle continues in the admin app, where bookings can be updated, confirmed, refunded, exported, and used to send confirmation emails.
- This creates a two-stage system: customer-facing checkout and admin-facing fulfillment/exception handling.
10. Communication and external services
- External dependencies materially shaping the architecture are Stripe for payments, Resend for email delivery, Google reCAPTCHA for form protection, and Supabase for data/auth/storage.
- Email templates live in shared/src/emails, so transactional email content is centralized and reused by both apps.
- The public app also includes inquiry/contact flows, which likely route through shared email services.
11. UI composition and design system
- Each app has its own feature components, but both rely on a local UI primitives set under app/components/ui, indicating a shared design-system style built from shadcn/ui-style components.
- Feature components are organized by domain: tours, bookings, collections, dashboard, nav, SEO, theme, and loaders in admin; home, tour detail, booking, account, header/footer, and filters in front-panel.
- This separation helps diagram a clear “pages → feature components → UI primitives” stack.
12. SEO and content rendering
- The front-panel has explicit SEO components and pages for robots.txt, sitemap.xml, metadata, and structured data.
- Tour, city, and collection pages are content-heavy and likely server-rendered for discoverability, with meta details generated from shared utilities.
- SEO is therefore a first-class architectural concern on the public site, not just a UI add-on.
13. State, filtering, and dashboard logic
- The repo uses TanStack Query for client/server data caching and refetching, which is especially relevant for lists, dashboards, filters, and account pages.
- Utilities in each app support pagination, filter payload construction, and reset URLs, showing a list-driven architecture for tours, bookings, and reviews.
- The admin dashboard aggregates stats and recent bookings via shared service/query layers.
14. Deployment boundary
- The repository is designed to be deployed as separate services, typically one for front-panel and one for admin.
- Environment variables are split between client-safe VITE_ values and server-only secrets such as Supabase service role, Stripe secret key, Resend API key, and reCAPTCHA secret.
- That split is important architecturally: the browser-facing app only gets public variables, while privileged actions stay server-side.
15. What to draw in an architecture diagram
- Draw two top-level applications sharing one domain/service layer and one Supabase backend.
- Place route modules at the edge of each app, then show them calling shared services/schemas, which in turn integrate with Supabase, Stripe, Resend, Redis/cache, and reCAPTCHA.
- Keep admin and front-panel as separate deployment/runtime boundaries, with shared code reused but not serving as a separate runtime process.
Main entry points: services Domain services · app/routes Public routes · app/routes Admin routes · 20260116170156_remote_schema.sql Supabase
Components 19
front-panel
Customer-facing React Router app
- Front app · Framework-mode React Router runtime and SSR boundary for the public site
front-panel/app/root.tsx - Public routes · Browsing, account, cart, booking, auth, payment, SEO, and content pages
front-panel/app/routes - Public actions · Client/server mutation endpoints for cart, reviews, auth, checkout, and booking flows
front-panel/app/routes/_actions - Public queries · Feature-scoped data access for tours, bookings, cart, reviews, and content
front-panel/app/queries - Public UI · Page composition for home, tour detail, booking, account, header/footer, SEO, and filters
front-panel/app/components - Front shell · Client/server entry points and top-level layout for the public app
front-panel/app/entry.client.tsx
admin
Internal operations React Router app
- Admin app · Framework-mode React Router runtime and SSR boundary for operations
admin/app/root.tsx - Admin routes · Operational pages for bookings, tours, categories, cities, collections, coupons, tags, hero sections, auth, and dashboard
admin/app/routes - Admin actions · Back-office endpoints for logout, refunds, retries, exports, deletes, and confirmation email workflows
admin/app/routes/_actions - Admin queries · Data access for booking management, content catalogs, filters, and dashboard stats
admin/app/queries - Admin UI · Operational screens, dashboards, tour editors, tables, navigation, and shared UI primitives
admin/app/components - Admin shell · Client/server entry points and top-level layout for the admin app
admin/app/entry.client.tsx
shared
Cross-cutting domain layer reused by both apps
- Domain services · Core services for auth, bookings, checkout, cart, tours, reviews, coupons, media, emails, Stripe, cache, and dashboard stats
shared/src/services - Schemas · Shared input and payload validation for auth, booking, filters, content, and profile flows
shared/src/schemas - Shared utils · Supabase, auth, Redis, image, cache-key, and general utility helpers
shared/src/utils - Email templates · Reusable email components and templates for booking, inquiry, auth, and onboarding
shared/src/emails - Shared queries · Cross-app query helpers for auth and cache event reads
shared/src/queries
infra
External services and backend boundary
- Supabase · Primary backend boundary with schema migrations and Supabase client/server helpers
supabase/migrations/20260116170156_remote_schema.sql - External services · Stripe, Resend, Google reCAPTCHA, and Redis-backed cache infrastructure
Connections 23
- Front shell → Front app: boots · Entry points and layout initialize the public React Router app
- Front app → Public routes: hosts · The app root renders the public route tree
- Public routes → Public UI: renders · Routes compose feature components and local UI primitives
- Public routes → Public queries: reads · Page loaders and components consume public read models
- Public actions → Domain services: mutates via · Public mutations delegate business logic to shared services
- Public routes → Public actions: invokes · Route modules call action handlers for checkout, cart, reviews, and auth
- Admin shell → Admin app: boots · Entry points and layout initialize the admin React Router app
- Admin app → Admin routes: hosts · The app root renders the operational route tree
- Admin routes → Admin UI: renders · Admin pages assemble dashboards, forms, tables, and editors
- Admin routes → Admin queries: reads · Route loaders and screens consume operational read models
- Admin actions → Domain services: mutates via · Admin mutations delegate booking and content workflows to shared services
- Admin routes → Admin actions: invokes · Route modules call operational action handlers
- Domain services → Schemas: validates · Services enforce shared payload contracts
- Domain services → Shared utils: depends on · Domain logic uses auth, Supabase, cache, and utility helpers
- Domain services → Email templates: composes · Transactional workflows render shared email templates
- Shared queries → Supabase: reads · Shared queries pull data from the Supabase backend
- Shared utils → Supabase: connects to · Client/server helpers provide the database and auth boundary
- Shared utils → External services: integrates · Utilities wrap Redis, Stripe, and other service clients
- Domain services → External services: calls · Business workflows trigger payment, email, and captcha providers
- Public queries → Supabase: reads · Front-end loaders ultimately fetch from Supabase through query helpers
- Admin queries → Supabase: reads · Admin loaders ultimately fetch from Supabase through query helpers
- Public actions → External services: calls · Public mutations use Stripe, Resend, and reCAPTCHA
- Admin actions → External services: calls · Admin workflows use Stripe and email services for fulfillment and exceptions