How dawoodmdbr/tixora works
1. Overall shape
- Tixora is a single-page React storefront with a separate admin area, deployed as a Vite app on Vercel.
- The browser handles most UI and state, while a small /api layer provides server-only operations: order creation, payment verification, geo-based currency detection, and signed image uploads.
2. Client-side application shell
- src/main.tsx boots the app, mounts routing, global styling, and Vercel Analytics.
- src/App.tsx defines the route structure and shared layout concerns, with dedicated error and 404 pages for failure boundaries.
3. Public storefront routes
- Route-level pages in src/pages cover the customer journey: home, shop, product exploration, wishlist, checkout, login, and about.
- The homepage is composed from src/components/home, while the shop and product interactions rely on reusable UI in src/components/ui and src/components/layout.
4. Checkout flow
- Checkout is a multi-step wizard split across src/components/checkout: information, shipping, payment, review, and progress.
- The flow culminates in a manual payment handoff, not a gateway integration: customers are shown bank/WhatsApp payment details from src/lib/payment.ts, then the order is confirmed through backend order creation and later admin verification.
5. State management boundaries
- Zustand stores in src/store hold the main client state: cart, wishlist/UI, currency preference, and admin auth.
- Cart and currency are persisted in localStorage, so the storefront can resume across sessions without requiring server round trips.
6. Supabase as the primary data layer
- Supabase provides both Postgres storage and auth.
- The browser uses the anon key via src/lib/supabase.ts, while serverless functions use the service-role client from api/_lib/supabaseAdmin.ts.
- The critical tables are products, orders, and order_items; product reads/writes and all order persistence ultimately center on these tables.
7. Product catalog and admin CRUD
- Product data is not local mock data; it lives in Supabase and is consumed by storefront listing pages, recommendation widgets, and the admin product management screens.
- Admin product editing lives under src/pages/admin and src/components/admin, with product forms and detail modals coordinating CRUD and image management.
8. Cloudinary image pipeline
- Product images are hosted in Cloudinary, not in Supabase.
- The admin upload flow requests a signed upload payload from /api/cloudinary-sign.ts, which keeps Cloudinary secrets server-side while allowing the browser to upload assets directly.
9. Serverless backend functions
- /api/create-order.ts creates orders and order items, validates input, applies rate limiting, and sends a confirmation email.
- /api/verify-payment.ts is an admin-only endpoint that marks an order as paid and sends the follow-up verification email.
- /api/detect-location.ts uses Vercel geo/IP headers to choose a default currency.
- The functions share server-only helpers in api/_lib, especially rate limiting and the service-role Supabase client.
10. Admin access model
- Admin routes are protected by ProtectedRoute and Supabase auth.
- There is no public sign-up path in the app; admins are expected to be provisioned manually in Supabase.
- This means the admin panel is a gated operational interface, not a second public product surface.
11. Currency and localization behavior
- src/store/currencyStore.ts drives multi-currency display across the store, supporting several currencies with PKR as the base.
- Initial currency selection can come from geo-IP detection, with a manual override via the currency selector and persisted user choice afterward.
12. Data and UX composition
- Static category metadata lives in src/data/categories.ts, while shared type contracts are centralized in src/types and src/lib/database.types.ts.
- Product cards, modals, cart sidebar, navbar, and footer form the reusable shell around route pages, while motion-based effects add presentation polish but do not change the underlying architecture.
13. Operational boundaries and deployment
- vercel.json rewrites all non-API requests to index.html, which is what enables React Router deep links on refresh.
- api/tsconfig.json is separate from the frontend config because serverless functions run in a Node environment, distinct from the browser bundle.
14. Security and trust boundaries
- The frontend is allowed to talk directly to Supabase only where RLS permits it; order data should not be publicly writable/readable outside the serverless layer.
- Secrets such as the Supabase service role key, Resend API key, and Cloudinary secret remain server-only, while the public anon key and Cloudinary cloud name are intentionally exposed to the browser.
Main entry points: pages Public pages · App.tsx App shell · admin Admin UI · products.ts Product data
Components 21
Frontend app
React SPA, route shell, and customer-facing pages
- main · Mounts the React app, router, global styles, and analytics.
src/main.tsx - App shell · Defines the route tree, shared layout, and error boundaries.
src/App.tsx - Public pages · Customer-facing routes for home, shop, product exploration, wishlist, checkout, login, and about.
src/pages
Shared UI
Reusable storefront, checkout, and layout components
- Layout shell · Navbar, footer, cart sidebar, and policy modal around the storefront.
src/components/layout - Home sections · Hero, categories, best sellers, ticker, trust badges, and arrivals used on the landing page.
src/components/home - Catalog UI · Product cards, product modal, currency selector, and cursor/button effects used across browsing.
src/components/ui - Checkout flow · Multi-step checkout UI for information, shipping, payment, review, and progress.
src/components/checkout
Admin area
Protected operational screens and admin controls
- Admin pages · Protected admin screens for dashboard, analytics, orders, products, and layout.
src/pages/admin - Admin UI · Protected route guard plus product and order modals for CRUD and verification.
src/components/admin
State & data
Client stores, typed models, and catalog/payment helpers
- Cart store · Persistent cart state shared across the storefront.
src/store/cartStore.ts - Currency store · Manages currency selection, geo-based defaults, and persistence.
src/store/currencyStore.ts - UI store · Holds wishlist and other client UI state.
src/store/uiStore.ts - Admin auth · Tracks Supabase-backed admin session state.
src/store/adminAuthStore.ts - Supabase client · Public anon-key Supabase access for permitted reads and auth.
src/lib/supabase.ts - Product data · Product and catalog access helpers backed by Supabase and shared types.
src/lib/products.ts - Payment info · Bank and WhatsApp payment details shown during manual checkout.
src/lib/payment.ts
Serverless API
Vercel functions and server-only helpers
- Create order · Validates checkout payloads, rate-limits requests, persists orders, and sends confirmation email.
api/create-order.ts - Verify payment · Admin-only payment verification that marks orders paid and sends follow-up email.
api/verify-payment.ts - Detect location · Uses Vercel geo/IP headers to choose a default currency.
api/detect-location.ts - Cloudinary sign · Returns signed upload payloads so the browser can send images directly to Cloudinary.
api/cloudinary-sign.ts - API helpers · Shared rate limiting and service-role Supabase admin client.
api/_lib
Connections 26
- main → App shell: boots · Entry point mounts the routed application shell.
- main → Currency store: initializes · Currency state is loaded at startup for consistent pricing.
- App shell → Public pages: routes to · App shell exposes the customer-facing routes.
- App shell → Admin pages: routes to · App shell exposes protected admin routes.
- App shell → Layout shell: wraps · Shared layout composes the storefront chrome.
- Public pages → Home sections: uses · Homepage route is built from home sections.
- Public pages → Catalog UI: uses · Shop, wishlist, and product views rely on reusable catalog UI.
- Public pages → Checkout flow: uses · Checkout route assembles the multi-step wizard.
- Public pages → Cart store: reads/writes · Public shopping flows depend on cart state.
- Public pages → Currency store: reads/writes · Price display follows selected currency.
- Public pages → UI store: reads/writes · Wishlist and UI preferences live in client state.
- Admin pages → Admin UI: uses · Admin routes use guarded modals and route protection.
- Admin UI → Admin auth: checks · ProtectedRoute gates access on admin auth state.
- Catalog UI → Product data: renders · Product cards and modals consume catalog data.
- Home sections → Product data: highlights · Landing page sections surface catalog content.
- Checkout flow → Payment info: shows · Payment step presents manual payment instructions.
- Checkout flow → Create order: submits · Checkout finalizes by creating the order server-side.
- Admin UI → Verify payment: calls · Admin verification updates order payment status.
- Currency store → Detect location: seeds from · Initial currency can be inferred from geo/IP lookup.
- Admin UI → Cloudinary sign: requests · Image upload flow fetches signed Cloudinary parameters.
- Create order → API helpers: uses · Order function shares rate limiting and service-role access.
- Verify payment → API helpers: uses · Verification function shares server-only helpers.
- Cloudinary sign → API helpers: uses · Signing endpoint uses server-side Supabase/admin utilities as needed.
- Product data → Supabase client: queries · Catalog helpers read from Supabase.
- Product data → Payment info: coordinates with · Product flows meet checkout/payment presentation.
- Admin pages → Supabase client: authenticates · Admin screens depend on Supabase auth session state.