How haddybhaiya/countryside works
Purpose and Runtime
Countryside is a full-stack rural-hospitality property marketplace and booking system. It serves customer discovery/checkout, host property operations, and administrator analytics under role-based access control. The primary runtime is a React 18/TypeScript Vite SPA in frontend/src/main.tsx, deployed with Vercel configuration in frontend/vercel.json.
Application Composition and Entry Points
frontend/src/App.tsx composes the application experience, while page-level route targets live in frontend/src/pages/. Public flows include landing, exploration, property detail, checkout, confirmation, and trips; protected workspace flows include host and admin dashboards. Route guards in frontend/src/routes/ProtectedRoute.tsx and frontend/src/routes/GuestRoute.tsx establish authentication boundaries.
Identity, Roles, and Shared State
Authentication and user/session state are centralized through frontend/src/context/AuthContext.tsx, with application-wide state in frontend/src/context/AppContext.tsx. Client-side RBAC logic is defined in frontend/src/lib/rbac.ts; it separates customer, host, and admin capabilities before users reach role-specific pages such as frontend/src/pages/HostDashboardPage.tsx and frontend/src/pages/AdminPage.tsx.
Property Discovery and Host Management
Customers browse and inspect inventory through frontend/src/components/ExploreView.tsx and frontend/src/components/DetailView.tsx. Hosts manage inventory through frontend/src/components/AdminPropertyManagement.tsx and the host dashboard page. Property operations are isolated behind frontend/src/services/property.service.ts, which communicates with the InsForge/Supabase-compatible client in frontend/src/lib/insforge.ts. Persistent property schema and ownership/RLS changes are captured in migrations/20260711165801_properties-schema.sql and migrations/20260713000001_host-property-rls.sql.
Booking and Payment Flow
Checkout starts in frontend/src/pages/CheckoutPage.tsx / frontend/src/components/CheckoutView.tsx, where pricing and availability are converted into booking operations through frontend/src/services/booking.service.ts. Booking persistence and conflict-control constraints belong to migrations/20260712162218_bookings-schema.sql. Stripe payment handling crosses a trust boundary: the browser uses Stripe configuration, while webhook verification/finalization is handled by the serverless endpoint functions/stripe-webhook/index.ts. A mock checkout path exists at frontend/src/pages/StripeMockCheckout.tsx; successful completion routes to frontend/src/pages/ConfirmationPage.tsx.
Admin Operations and Analytics
Administrative controls are composed in frontend/src/components/AdminConsole.tsx, with user/property operations in frontend/src/components/AdminUserManagement.tsx and frontend/src/components/AdminPropertyManagement.tsx. Analytics data is aggregated for dashboard visualizations through frontend/src/hooks/useAdminAnalytics.ts, rendered by frontend/src/components/admin/AdminDashboardOverview.tsx and frontend/src/components/admin/AdminDetailedAnalytics.tsx, and exportable via frontend/src/utils/exportCsv.ts.
Backend, Data, and Delivery Boundaries
InsForge provides PostgreSQL, Auth, and Storage behind the Supabase-compatible client. Database evolution is SQL-migration driven, including profile/role setup in migrations/20260712170713_profiles-schema.sql and role-policy fixes in migrations/20260713000002_fix-rls-roles.sql. Stripe is the external payment service; Vercel hosts the frontend and serverless webhook. CI is defined in .github/workflows/ci.yml.
Main entry points: App.tsx App and routes · insforge.ts InsForge client · ProtectedRoute.tsx Route guards · CheckoutPage.tsx Checkout
Components 21
React SPA
Customer, host, and admin application.
- SPA entry
frontend/src/main.tsx - App and routes
frontend/src/App.tsx - Route guards · Protects authenticated and guest-only routes.
frontend/src/routes/ProtectedRoute.tsx - Auth session · Central user and session state.
frontend/src/context/AuthContext.tsx - Role capabilities
frontend/src/lib/rbac.ts - Property discovery
frontend/src/components/ExploreView.tsx - Checkout
frontend/src/pages/CheckoutPage.tsx - Host property operations
frontend/src/pages/HostDashboardPage.tsx - Admin operations
frontend/src/components/AdminConsole.tsx - Admin analytics · Aggregates dashboard data and supports CSV export.
frontend/src/hooks/useAdminAnalytics.ts
Application Services
- Booking service · Creates bookings after pricing and availability checks.
frontend/src/services/booking.service.ts - Property service
frontend/src/services/property.service.ts - InsForge client
frontend/src/lib/insforge.ts
Platform & Delivery
- InsForge · Provides PostgreSQL, Auth, and Storage.
- Property schema and RLS · Defines property ownership and host access controls.
migrations/20260713000001_host-property-rls.sql - Booking constraints · Persists bookings and conflict controls.
migrations/20260712162218_bookings-schema.sql - Profiles and role policies · Establishes profiles, roles, and corrected RLS policies.
migrations/20260713000002_fix-rls-roles.sql - Stripe
- Stripe webhook · Verifies payment webhooks and finalizes bookings.
functions/stripe-webhook/index.ts - Vercel deployment · Hosts the SPA and webhook endpoint.
frontend/vercel.json - CI pipeline
.github/workflows/ci.yml
Connections 25
- SPA entry → App and routes: mounts
- App and routes → Route guards: applies
- Route guards → Auth session: reads session
- Route guards → Role capabilities: enforces roles
- App and routes → Property discovery: public routes
- App and routes → Checkout: checkout route
- App and routes → Host property operations: host route
- App and routes → Admin operations: admin route
- Property discovery → Property service: loads inventory
- Host property operations → Property service: manages inventory
- Checkout → Booking service: creates booking
- Admin operations → Admin analytics: shows metrics
- Property service → InsForge client: uses
- Booking service → InsForge client: uses
- Auth session → InsForge client: authenticates with
- InsForge client → InsForge: accesses
- Property schema and RLS → InsForge: evolves database
- Booking constraints → InsForge: evolves database
- Profiles and role policies → InsForge: defines access policies
- Checkout → Stripe: initiates payment
- Stripe → Stripe webhook: payment event
- Stripe webhook → InsForge: finalizes booking
- Vercel deployment → SPA entry: serves SPA
- Vercel deployment → Stripe webhook: runs endpoint
- CI pipeline → Vercel deployment: validates delivery