How mahi8026/ticket-bari works
1. Overall shape
Ticket Bari is a React single-page frontend for a bus ticket marketplace. It is built with Vite, deployed on Firebase Hosting, and uses client-side routing for all user flows. The repository contains no backend implementation; instead, it calls an external Node/Express API through secure Axios hooks.
2. Primary architectural boundary
The app is split between:
- Public customer-facing flows: browse tickets, view details, book seats, pay
- Authenticated role-based areas: user dashboard, admin dashboard, vendor routes
- Shared platform services: auth, theming, secure API access, SEO, loading/feedback
3. Routing and layout layer
src/Routes/Routes.jsx defines the route graph, with route guards in PrivateRoute, AdminRoute, and VendorRoute. Page composition is handled by two main shells:
- MainLayout for the public site
- DashboardLayout for authenticated dashboard sections
This is the key structural boundary for any architecture diagram.
4. Authentication and session management
Firebase Authentication is the identity layer, wired through AuthProvider and the useAuth hook. The app supports login/register and Google social login, then redirects users according to role. Role resolution is abstracted behind useRole, while useUserProfile suggests profile-backed identity data beyond Firebase auth state.
5. Backend data access
useAxiosSecure is the main API boundary for authenticated requests to the backend service. This is likely where JWT or Firebase token attachment happens before reaching the server. From the frontend perspective, all protected business data—tickets, bookings, roles, payment records—flows through this layer.
6. Ticket discovery and browsing
The public experience centers on Home, AllTickets, and TicketDetails, with supporting pages like About, Blog, Help, and Contact. TicketCard and BookingModal are reusable UI units for listing and selection. SeatSelectionDemo, SeatMap, and SeatSelectionModal indicate seat-picking is a dedicated interaction model, not just a simple form.
7. Booking and payment flow
The booking pipeline is split across modal-driven seat selection, checkout, and payment components. CheckoutForm, PaymentForm, PaymentMethodSelector, and MobileBankingPayment show a modular payment experience with Stripe integration. src/Pages/Dashboard/CheckoutForm.jsx and src/components/CheckoutForm.jsx suggest the checkout flow is reused in more than one context.
8. User dashboard subsystem
The user area contains MyBookings, Payment, TransactionHistory, and UserProfile. This section represents the post-booking lifecycle: reviewing reservations, completing or tracking payment, and viewing receipts/history. It is isolated from public browsing by dashboard routing and auth checks.
9. Admin subsystem
Admin pages include AdminHome, ManageTickets, ManageUsers, and AdvertiseTickets. This implies a moderation/operations control plane for verifying content, managing roles, and promoting or suppressing ticket visibility. The README’s mention of fraud/banning and homepage advertisement toggles fits this admin boundary.
10. Vendor subsystem
The route and folder scaffolding includes a vendor area, even though the listed files are sparse. Architecturally, this indicates a third role tier for operators who add/manage inventory and monitor booking requests. In diagrams, it should be shown as a protected dashboard branch parallel to user and admin.
11. Cross-cutting UI systems
Navbar, Footer, LoadingSpinner, and ThemeToggle are shared shell components. SEOHead handles page metadata, while PerformanceMonitor suggests client-side performance instrumentation. These are global concerns applied across routes rather than tied to any single business flow.
12. State and UX infrastructure
The repo uses React hooks for reusable stateful logic: theme, auth, role, profile, and secure API access. This keeps business pages thin and delegates platform concerns to hook/provider layers. The presence of SweetAlert2, React Query, Tailwind/DaisyUI, and Swiper in the README indicates a modern interactive frontend with cached data fetching and responsive UI behavior.
13. Deployment/runtime constraints
Firebase Hosting is the production delivery layer, and public/_redirects plus firebase.json indicate SPA rewrite handling for client-side routes. index.html, main.jsx, and App.jsx form the app bootstrap chain, with App likely mounting providers, routing, and global shell components.
14. What to emphasize in an architecture diagram
The clearest diagram should show:
- Browser client at the center
- Firebase Auth as the identity provider
- External backend API behind useAxiosSecure
- Role-gated route branches for User/Admin/Vendor
- Booking/payment flow ending in Stripe
- Shared layout/component layer spanning all pages
Main entry points: Routes.jsx Routes · useAxiosSecure.jsx Secure API · App.jsx App · Navbar.jsx Shared UI
Components 25
App Shell
Bootstrap, layouts, and route composition.
- App · Root application bootstrap and provider assembly.
src/App.jsx - Routes · Client-side route graph and flow composition.
src/Routes/Routes.jsx - Main Layout · Public site shell for browsing pages.
src/Layout/MainLayout.jsx - Dashboard Layout · Authenticated dashboard shell and navigation.
src/Layout/DashboardLayout.jsx
Identity & Access
Authentication, roles, and guarded routes.
- Auth Provider · Firebase-backed session and identity context.
src/providers/AuthProvider.jsx - useAuth · Auth access hook for user/session state.
src/hooks/useAuth.jsx - useRole · Role resolution for protected areas.
src/hooks/useRole.jsx - useUserProfile · Profile-backed identity data beyond auth state.
src/hooks/useUserProfile.jsx - Private Route · Authentication gate for protected routes.
src/Routes/PrivateRoute.jsx - Admin Route · Role gate for admin sections.
src/Routes/AdminRoute.jsx - Vendor Route · Role gate for vendor sections.
src/Routes/VendorRoute.jsx
Public Flows
Customer-facing discovery and booking.
- Home · Landing page for ticket discovery.
src/Pages/Home.jsx - All Tickets · Browse and filter ticket inventory.
src/Pages/AllTickets.jsx - Ticket Details · Ticket view with booking entry points.
src/Pages/TicketDetails.jsx - Booking Modal · Reusable booking and seat-selection trigger.
src/components/BookingModal.jsx - Seat Selection · Seat map and seat-picking flow.
src/components/SeatSelection/SeatMap.jsx - Checkout · Checkout entry and payment preparation.
src/components/CheckoutForm.jsx - Payment · Stripe-oriented payment experience.
src/components/PaymentForm.jsx
Dashboards
Authenticated user, admin, and vendor areas.
- User Dashboard · Post-booking personal account area.
src/Pages/Dashboard/User/MyBookings.jsx - Admin Dashboard · Operations control plane for tickets and users.
src/Pages/Dashboard/Admin/AdminHome.jsx - Vendor Dashboard · Protected vendor workspace for inventory and requests.
src/Pages/Dashboard/Vendor
Platform Services
Shared UI, SEO, API, and runtime services.
- Shared UI · Navbar, footer, loading, and theme controls.
src/components/Shared/Navbar.jsx - SEO & Monitor · Page metadata and client performance instrumentation.
src/components/SEO/SEOHead.jsx - Secure API · Authenticated Axios boundary to the backend service.
src/hooks/useAxiosSecure.jsx - Firebase Auth · External authentication provider used by the frontend.
src/firebase/firebase.config.js
Connections 29
- App → Auth Provider: wraps · App initializes session context.
- App → Routes: mounts · App renders the route graph.
- App → Shared UI: shares · Global shell components span the app.
- Routes → Main Layout: uses · Public routes render in the main site shell.
- Routes → Dashboard Layout: uses · Dashboard routes render in the authenticated shell.
- Routes → Private Route: protects · Protected branches require authentication.
- Routes → Admin Route: protects · Admin branch requires admin role.
- Routes → Vendor Route: protects · Vendor branch requires vendor role.
- Auth Provider → Firebase Auth: backs · Identity state is sourced from Firebase.
- useAuth → Auth Provider: reads · Auth hook consumes provider state.
- useRole → Secure API: queries · Role resolution may depend on backend data.
- useUserProfile → Secure API: queries · Profile data is loaded through secure API access.
- Private Route → useAuth: checks · Authentication gate uses session state.
- Admin Route → useRole: checks · Admin gate uses resolved role.
- Vendor Route → useRole: checks · Vendor gate uses resolved role.
- Home → Main Layout: renders in · Landing page uses the public shell.
- All Tickets → Secure API: loads · Ticket catalog comes from backend data.
- Ticket Details → Secure API: loads · Ticket detail data comes from backend data.
- Ticket Details → Booking Modal: opens · Details page starts the booking flow.
- Booking Modal → Seat Selection: advances to · Booking proceeds into seat selection.
- Seat Selection → Checkout: confirms · Selected seats feed checkout.
- Checkout → Payment: hands off · Checkout transitions to payment.
- Payment → Secure API: submits · Payment records and booking updates flow through backend access.
- User Dashboard → Secure API: reads · Bookings, history, and profile data come from backend APIs.
- Admin Dashboard → Secure API: manages · Ticket and user administration uses protected API calls.
- Vendor Dashboard → Secure API: operates on · Vendor inventory and booking workflows use protected API calls.
- Shared UI → Main Layout: composes · Shared chrome is used in the public shell.
- Shared UI → Dashboard Layout: composes · Shared chrome is used in the dashboard shell.
- SEO & Monitor → Routes: supports · Metadata and instrumentation apply across routed pages.