How ranjith1089/saloon_management works
Purpose and Deployment
A full-stack, multi-branch salon/spa operations SaaS: staff-facing operations, POS, customer portal, public booking widget, growth tooling, and administration. The React SPA is deployed to Vercel; the Express API and PostgreSQL run on Railway. Primary entry points are frontend/src/main.tsx, frontend/src/App.tsx, backend/src/server.ts, and backend/src/app.ts.
Frontend Route and UI Boundary
React/Vite provides distinct public, authenticated operational, and customer-portal experiences. frontend/src/App.tsx owns route composition; frontend/src/layouts/DashboardLayout.tsx frames protected back-office screens, while frontend/src/pages/PublicBooking.tsx implements the unauthenticated/embed-capable /book/:branchId flow. Guards in frontend/src/components/ProtectedRoute.tsx and frontend/src/components/RoleGuard.tsx enforce client-side navigation constraints.
API Composition and Request Pipeline
Express routers expose versioned resource APIs and dispatch to thin controllers, then services. backend/src/routes/index.ts is the API aggregation point; controllers in backend/src/controllers/ translate requests, while domain logic resides in backend/src/services/. Authentication, validation, authorization/scoping, and consistent error handling form the request boundary through backend/src/middlewares/auth.ts, backend/src/middlewares/validate.ts, and backend/src/middlewares/errorHandler.ts. Public booking/inquiry routes remain intentionally unauthenticated but are rate-limited at the application level.
Identity, Roles, and Scope
JWT access/refresh authentication and bcrypt-backed credentials support ADMIN, MANAGER, STAFF, and CUSTOMER roles. backend/src/services/auth.service.ts owns auth behavior; backend/src/services/access-control.service.ts manages permission policy; backend/src/utils/scope.ts applies server-side ownership and staff/branch visibility restrictions. Frontend session state and token persistence are centralized in frontend/src/store/authStore.ts and HTTP interception in frontend/src/services/api.ts.
Booking-to-Revenue Operations
Booking is the central operational lifecycle, including scheduled and walk-in customers, staff assignment, status changes, payment collection, discounts, memberships, and referral effects. backend/src/services/booking.service.ts is the transactional authority, including concurrency protection for booking creation. The operational UI spans frontend/src/pages/Bookings.tsx, calendar/staff-grid components, and frontend/src/pages/Sales.tsx, where a unified ticket can combine products, services, and pending bookings. Finance, commission, and reporting consume finalized booking/sale data via backend/src/services/finance.service.ts, backend/src/services/commission.service.ts, and backend/src/services/report.service.ts.
Catalog, Branch, and Customer Domains
Multi-branch separation governs staff, schedules, service pricing, tax/payment configuration, inventory stock, and reporting. The persistence contract is centralized in backend/prisma/schema.prisma; branch, catalog, product-stock, membership, coupon, and customer business rules are separated across backend/src/services/branch.service.ts, backend/src/services/product.service.ts, and backend/src/services/membership.service.ts. Prisma migrations establish the evolving PostgreSQL schema under backend/prisma/migrations/.
External Integrations and Runtime Operations
Node.js 20/TypeScript runs the Express backend; React 18/Vite/Tailwind runs the browser application. Prisma connects to Railway PostgreSQL. Cloudinary handles branding/staff media via backend/src/config/cloudinary.ts; Meta WhatsApp Cloud API is integrated through backend/src/config/whatsapp.ts and backend/src/services/whatsapp.service.ts, primarily for notifications and test sends. Deployment initialization uses backend/prisma/bootstrap.ts before migrations/seeding, with Railway configuration in backend/railway.json and Vercel configuration in vercel.json.
Main entry points: App.tsx Routes & app shell · app.ts API application · schema.prisma Prisma data model · index.ts Versioned API routes
Components 19
React SPA
Vercel-hosted staff, customer, and public experiences.
- SPA entry
frontend/src/main.tsx - Routes & app shell · Separates public, operational, and customer portal routes.
frontend/src/App.tsx - Back-office dashboard
frontend/src/layouts/DashboardLayout.tsx - Public booking widget · Embed-capable branch booking flow.
frontend/src/pages/PublicBooking.tsx - Booking & sales UI · Manages bookings, calendar work, and unified sales tickets.
frontend/src/pages/Bookings.tsx - Client auth boundary · Persists tokens and applies HTTP interception.
frontend/src/store/authStore.ts
Express API
Railway-hosted application and domain boundary.
- API server
backend/src/server.ts - API application · Applies rate limits and shared middleware.
backend/src/app.ts - Versioned API routes
backend/src/routes/index.ts - Auth, validation & errors · Authenticates, validates, scopes, and normalizes failures.
backend/src/middlewares/auth.ts - Identity & access policy · JWT credentials, roles, permissions, and branch/staff visibility.
backend/src/services/auth.service.ts - Booking lifecycle · Coordinates booking creation, assignment, status, and downstream effects.
backend/src/services/booking.service.ts - Revenue & reporting · Consumes finalized booking and sale data for finance, commissions, and reports.
backend/src/services/finance.service.ts - Branch & catalog domains · Controls branches, pricing, stock, memberships, coupons, and customers.
backend/src/services/branch.service.ts - WhatsApp notifications
backend/src/services/whatsapp.service.ts
Data & integrations
- Prisma data model · Defines multi-branch operational data and relationships.
backend/prisma/schema.prisma - Railway PostgreSQL
- Cloudinary · Stores branding and staff media.
backend/src/config/cloudinary.ts - Meta WhatsApp Cloud API
backend/src/config/whatsapp.ts
Connections 23
- SPA entry → Routes & app shell: mounts
- Routes & app shell → Back-office dashboard: protected operations
- Routes & app shell → Public booking widget: public /book/:branchId
- Routes & app shell → Booking & sales UI: operational routes
- Routes & app shell → Client auth boundary: session guards
- Client auth boundary → API application: authenticated HTTP
- Public booking widget → API application: public booking requests
- Booking & sales UI → API application: booking and sales requests
- API server → API application: starts
- API application → Auth, validation & errors: applies middleware
- Auth, validation & errors → Versioned API routes: dispatches authorized requests
- Versioned API routes → Identity & access policy: auth and policy actions
- Versioned API routes → Booking lifecycle: booking operations
- Versioned API routes → Branch & catalog domains: branch and catalog operations
- Booking lifecycle → Revenue & reporting: finalized revenue data
- Booking lifecycle → WhatsApp notifications: booking notifications
- Identity & access policy → Prisma data model: identity records
- Booking lifecycle → Prisma data model: transactional model
- Branch & catalog domains → Prisma data model: branch-scoped data
- Revenue & reporting → Prisma data model: financial data
- Prisma data model → Railway PostgreSQL: mapped to
- Branch & catalog domains → Cloudinary: media assets
- WhatsApp notifications → Meta WhatsApp Cloud API: sends messages