# talha5978/rr-tours-app architecture

> Architecture diagram of the GitHub repository talha5978/rr-tours-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/talha5978/rr-tours-app
- Repository: https://github.com/talha5978/rr-tours-app

## Overview

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: [`shared/src/services`](https://github.com/talha5978/rr-tours-app/tree/main/shared/src/services) (Domain services), [`front-panel/app/routes`](https://github.com/talha5978/rr-tours-app/tree/main/front-panel/app/routes) (Public routes), [`admin/app/routes`](https://github.com/talha5978/rr-tours-app/tree/main/admin/app/routes) (Admin routes), [`supabase/migrations/20260116170156_remote_schema.sql`](https://github.com/talha5978/rr-tours-app/blob/main/supabase/migrations/20260116170156_remote_schema.sql) (Supabase)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front_panel["front-panel"]
  node_front_root["Front app<br/>rr7 app<br/>[root.tsx]"]
  node_front_routes["Public routes<br/>route modules"]
  node_front_actions["Public actions<br/>mutations"]
  node_front_queries["Public queries<br/>read models"]
  node_front_ui["Public UI<br/>feature components"]
  node_front_shell["Front shell<br/>layout/entry<br/>[entry.client.tsx]"]
end

subgraph group_admin["admin"]
  node_admin_root["Admin app<br/>rr7 app<br/>[root.tsx]"]
  node_admin_routes["Admin routes<br/>route modules"]
  node_admin_actions["Admin actions<br/>mutations"]
  node_admin_queries["Admin queries<br/>read models"]
  node_admin_ui["Admin UI<br/>feature components"]
  node_admin_shell["Admin shell<br/>layout/entry<br/>[entry.client.tsx]"]
end

subgraph group_shared["shared"]
  node_shared_services["Domain services<br/>business logic"]
  node_shared_schemas["Schemas<br/>validation contracts"]
  node_shared_utils["Shared utils<br/>platform helpers"]
  node_shared_emails["Email templates<br/>transactional email"]
  node_shared_queries["Shared queries<br/>query layer"]
end

subgraph group_infra["infra"]
  node_supabase_db[("Supabase<br/>db/auth/storage")]
  node_external_services(("External services<br/>3rd-party APIs"))
end

node_front_shell -->|"boots"| node_front_root
node_front_root -->|"hosts"| node_front_routes
node_front_routes -->|"renders"| node_front_ui
node_front_routes -->|"reads"| node_front_queries
node_front_actions -->|"mutates via"| node_shared_services
node_front_routes -->|"invokes"| node_front_actions
node_admin_shell -->|"boots"| node_admin_root
node_admin_root -->|"hosts"| node_admin_routes
node_admin_routes -->|"renders"| node_admin_ui
node_admin_routes -->|"reads"| node_admin_queries
node_admin_actions -->|"mutates via"| node_shared_services
node_admin_routes -->|"invokes"| node_admin_actions
node_shared_services -->|"validates"| node_shared_schemas
node_shared_services -->|"depends on"| node_shared_utils
node_shared_services -->|"composes"| node_shared_emails
node_shared_queries -->|"reads"| node_supabase_db
node_shared_utils -->|"connects to"| node_supabase_db
node_shared_utils -->|"integrates"| node_external_services
node_shared_services -->|"calls"| node_external_services
node_front_queries -->|"reads"| node_supabase_db
node_admin_queries -->|"reads"| node_supabase_db
node_front_actions -->|"calls"| node_external_services
node_admin_actions -->|"calls"| node_external_services

click node_front_root "https://github.com/talha5978/rr-tours-app/blob/main/front-panel/app/root.tsx"
click node_front_routes "https://github.com/talha5978/rr-tours-app/tree/main/front-panel/app/routes"
click node_front_actions "https://github.com/talha5978/rr-tours-app/tree/main/front-panel/app/routes/_actions"
click node_front_queries "https://github.com/talha5978/rr-tours-app/tree/main/front-panel/app/queries"
click node_front_ui "https://github.com/talha5978/rr-tours-app/tree/main/front-panel/app/components"
click node_front_shell "https://github.com/talha5978/rr-tours-app/blob/main/front-panel/app/entry.client.tsx"
click node_admin_root "https://github.com/talha5978/rr-tours-app/blob/main/admin/app/root.tsx"
click node_admin_routes "https://github.com/talha5978/rr-tours-app/tree/main/admin/app/routes"
click node_admin_actions "https://github.com/talha5978/rr-tours-app/tree/main/admin/app/routes/_actions"
click node_admin_queries "https://github.com/talha5978/rr-tours-app/tree/main/admin/app/queries"
click node_admin_ui "https://github.com/talha5978/rr-tours-app/tree/main/admin/app/components"
click node_admin_shell "https://github.com/talha5978/rr-tours-app/blob/main/admin/app/entry.client.tsx"
click node_shared_services "https://github.com/talha5978/rr-tours-app/tree/main/shared/src/services"
click node_shared_schemas "https://github.com/talha5978/rr-tours-app/tree/main/shared/src/schemas"
click node_shared_utils "https://github.com/talha5978/rr-tours-app/tree/main/shared/src/utils"
click node_shared_emails "https://github.com/talha5978/rr-tours-app/tree/main/shared/src/emails"
click node_shared_queries "https://github.com/talha5978/rr-tours-app/tree/main/shared/src/queries"
click node_supabase_db "https://github.com/talha5978/rr-tours-app/blob/main/supabase/migrations/20260116170156_remote_schema.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_front_root,node_front_routes,node_front_actions,node_front_queries,node_front_ui,node_front_shell toneBlue
class node_admin_root,node_admin_routes,node_admin_actions,node_admin_queries,node_admin_ui,node_admin_shell toneAmber
class node_shared_services,node_shared_schemas,node_shared_utils,node_shared_emails,node_shared_queries toneMint
class node_supabase_db,node_external_services toneRose
```

## Components

### front-panel

Customer-facing React Router app

- [Front app](https://github.com/talha5978/rr-tours-app/blob/main/front-panel/app/root.tsx): rr7 app · Framework-mode React Router runtime and SSR boundary for the public site · `front-panel/app/root.tsx`
- [Public routes](https://github.com/talha5978/rr-tours-app/tree/main/front-panel/app/routes): route modules · Browsing, account, cart, booking, auth, payment, SEO, and content pages · `front-panel/app/routes`
- [Public actions](https://github.com/talha5978/rr-tours-app/tree/main/front-panel/app/routes/_actions): mutations · Client/server mutation endpoints for cart, reviews, auth, checkout, and booking flows · `front-panel/app/routes/_actions`
- [Public queries](https://github.com/talha5978/rr-tours-app/tree/main/front-panel/app/queries): read models · Feature-scoped data access for tours, bookings, cart, reviews, and content · `front-panel/app/queries`
- [Public UI](https://github.com/talha5978/rr-tours-app/tree/main/front-panel/app/components): feature components · Page composition for home, tour detail, booking, account, header/footer, SEO, and filters · `front-panel/app/components`
- [Front shell](https://github.com/talha5978/rr-tours-app/blob/main/front-panel/app/entry.client.tsx): layout/entry · 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](https://github.com/talha5978/rr-tours-app/blob/main/admin/app/root.tsx): rr7 app · Framework-mode React Router runtime and SSR boundary for operations · `admin/app/root.tsx`
- [Admin routes](https://github.com/talha5978/rr-tours-app/tree/main/admin/app/routes): route modules · Operational pages for bookings, tours, categories, cities, collections, coupons, tags, hero sections, auth, and dashboard · `admin/app/routes`
- [Admin actions](https://github.com/talha5978/rr-tours-app/tree/main/admin/app/routes/_actions): mutations · Back-office endpoints for logout, refunds, retries, exports, deletes, and confirmation email workflows · `admin/app/routes/_actions`
- [Admin queries](https://github.com/talha5978/rr-tours-app/tree/main/admin/app/queries): read models · Data access for booking management, content catalogs, filters, and dashboard stats · `admin/app/queries`
- [Admin UI](https://github.com/talha5978/rr-tours-app/tree/main/admin/app/components): feature components · Operational screens, dashboards, tour editors, tables, navigation, and shared UI primitives · `admin/app/components`
- [Admin shell](https://github.com/talha5978/rr-tours-app/blob/main/admin/app/entry.client.tsx): layout/entry · 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](https://github.com/talha5978/rr-tours-app/tree/main/shared/src/services): business logic · Core services for auth, bookings, checkout, cart, tours, reviews, coupons, media, emails, Stripe, cache, and dashboard stats · `shared/src/services`
- [Schemas](https://github.com/talha5978/rr-tours-app/tree/main/shared/src/schemas): validation contracts · Shared input and payload validation for auth, booking, filters, content, and profile flows · `shared/src/schemas`
- [Shared utils](https://github.com/talha5978/rr-tours-app/tree/main/shared/src/utils): platform helpers · Supabase, auth, Redis, image, cache-key, and general utility helpers · `shared/src/utils`
- [Email templates](https://github.com/talha5978/rr-tours-app/tree/main/shared/src/emails): transactional email · Reusable email components and templates for booking, inquiry, auth, and onboarding · `shared/src/emails`
- [Shared queries](https://github.com/talha5978/rr-tours-app/tree/main/shared/src/queries): query layer · Cross-app query helpers for auth and cache event reads · `shared/src/queries`

### infra

External services and backend boundary

- [Supabase](https://github.com/talha5978/rr-tours-app/blob/main/supabase/migrations/20260116170156_remote_schema.sql): db/auth/storage · Primary backend boundary with schema migrations and Supabase client/server helpers · `supabase/migrations/20260116170156_remote_schema.sql`
- **External services**: 3rd-party APIs · Stripe, Resend, Google reCAPTCHA, and Redis-backed cache infrastructure

## Connections

- 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
