How remrodri/touroperatorreactmui works
Project Type and Purpose
• This is a single-page web application (SPA) built with React 18, TypeScript, Material-UI and Vite.
• It serves as a front-end “Tour Operator” management console: user authentication, role-based access, tour packages, bookings, payments, reports, cancellation policies, destinations, etc.
• It communicates with an external RESTful API (configured via VITE_API_URL) using Axios and manages client-side state with React Context and custom hooks.
Top-Level File Structure & Architectural Layers
• public/ – Static assets (index.html, images, video).
• src/
– Entry & Bootstrap: main.tsx → wraps App.tsx in ThemeProvider, global ContextProviders, React Router.
– router/ – AppRouter.tsx defines client-side routes (Login, Home, Booking, Packages, Reports, SecuritySetup, UserManagement, Guide, etc.).
– theme/ – ThemeProvider, palettes, component overrides.
– config/ – axiosConfig.ts sets base URL, interceptors for JWT.
– context/ – Cross-cutting providers (AlertDialog, Snackbar).
– features/ – Domain modules organized by feature (auth, userManagement, tourPackage, booking, payment, reports, guide, etc.). Each follows a “feature folder” pattern:
• components/ (presentational and container components)
• context/ (feature-specific ContextProvider)
• service/ (API calls via axios)
• types/ (TypeScript definitions)
• validations/ (Yup schemas)
– pages/ – Page components per route; use feature containers.
– utils/ – helpers (bcryptUtils, tokenService), modal utilities, global snackbar.
– Animations & TextAnimations – reusable animation components.
– assets/ – images, fonts.
– App.tsx – root component that composes layout, router and providers.
External Dependencies & Build
• VITE for development server, HMR, and build.
• ESLint/Prettier for linting/formatting.
• npm scripts (dev, build, preview, lint, test).
• .env (VITE_API_URL) for backend API endpoint.
Main Components & Relationships
• Entry Point
– index.html loads the app. main.tsx mounts App inside React.StrictMode.
• Presentation Layer
– ThemeProvider wraps entire app.
– Global ContextProviders (AlertDialog, Snackbar, feature contexts) wrap AppRouter.
– AppRouter dispatches to pages (LoginPage, MainLayout → nested pages).
• Page Containers & Components
– Each page imports feature container components (e.g., BookingShowcaseContainer) which connect to feature Context + service.
– Patterns: Presentational vs Container components; Form components use Formik + Yup.
• State Management
– React Context & custom hooks for each feature domain (useLogin, useLogout, useGroupedAttendance, etc.).
– Local component state for UI.
• Service Layer
– axiosConfig defines HTTP client with base URL, JWT interceptor.
– featureService.ts modules implement REST calls (CRUD operations) and return typed data.
• External API
– All services call external REST API over HTTP.
– JWT token stored via tokenService in localStorage or cookies.
• Utilities & Helpers
– Global snackbars and dialogs for notifications.
– bcryptUtils for any client-side hashing.
– Animation components used by various pages.
Architectural Patterns & Design Principles
• Feature-folder structure for high cohesion.
• Presentational/Container separation.
• Single SPA with React Router and nested routes.
• Context API + custom hooks for state sharing.
• Service layer abstracts HTTP calls.
• Theming via centralized ThemeProvider.
• Form management with Formik and validation with Yup.
– Browser / Static Assets (public/index.html, public/*)
– Vite Dev Server / Build Pipeline
– Entry Point (main.tsx)
– ThemeProvider + Global ContextProviders
– AppRouter (React Router)
– Pages (LoginPage, HomePage, BookingPage, TourPackagePage, ReportsPage, etc.)
– Feature Modules (auth, userManagement, tourPackage, booking, payment, reports, guide, cancellationPolicy, tourType, touristDestination) each with:
• Context Provider
• Container Components
• Presentational Components
• Service Layer (axios calls)
– Utils & Animations modules
– External API (REST endpoints)
b. Relationships & Data Flow
– Page → Container → Context → Service → Axios → External API
– Service calls return data up to context or container → presentational component updates.
c. Patterns
d. Technologies
– Show .env → VITE_API_URL feeding axiosConfig.