How zihad-1883/l1-a9-sportnest-sports-facility-booking-management-system-client works
1. SportNest is a Next.js App Router client application. The repo is organized around routed screens in src/app, with most business UI living in reusable components under src/app/components. It is primarily a frontend for a separate backend API, with only auth-specific route handling inside this repo.
2. The application shell is defined globally in src/app/layout.js and styled through src/app/globals.css, TailwindCSS, and DaisyUI. The shared shell likely wraps all pages with common navigation and footer components, while loading.jsx files provide route-level pending states and not-found.jsx handles unknown routes.
3. The public-facing marketing layer is concentrated on the home and informational pages: src/app/page.js, about-us, plus sections like Banner, HowItWorks, WhyChooseUs, Testimonials, FeaturedFacilities, and Footer. This makes the homepage a conversion entry point rather than just a dashboard.
4. Facility discovery is centered on all-facilities and all-facilities/[id]. The list page uses search/filter UI, card summaries, and sport-type filtering, while the detail page uses FacilitiesDetails to show a single facility and likely acts as the handoff into booking.
5. Booking is a dedicated flow implemented by BookingForm, with cancellation handled by BookingCancelAlert and booking history surfaced in MyBooking. The data path is: user action in the UI -> form/alert component -> backend API call -> updated booking state shown on the bookings page.
6. Facility management is a separate owner/admin-style subsystem. add-facility, manage-facilities, EditFacilityForm, and FacilityDeleteAlert support creating, editing, and deleting facilities, so the architecture distinguishes between browsing/bookings and facility CRUD operations.
7. Authentication is handled through Better Auth. The local auth boundary is exposed at src/app/api/auth/[...all]/route.js, while src/lib/auth.js and src/lib/auth-client.js separate server/client auth setup. The README also indicates email/password and Google login, with protected routes guarded by JWT-based access control.
8. The app’s main business data does not live in this repository. Client pages call an external backend via NEXT_PUBLIC_API_URL, which is where facility, booking, and user data are fetched and mutated. MongoDB is mentioned in the README, but it is part of the backend persistence layer, not the frontend runtime.
9. src/proxy.js is the request-time protection boundary for private routes. It likely redirects unauthenticated users away from booking/management pages and keeps the public pages accessible without login.
10. The component architecture is intentionally modular: forms, cards, alerts, navigation, and content sections are isolated as separate React components. That keeps page files thin and makes it easier to diagram the system as a set of route-level screens composed from shared UI primitives, with auth and data access as the main cross-cutting concerns.
11. Operationally, the project is built for browser deployment on Vercel, with environment variables for auth and backend integration. Key external dependencies that materially affect architecture are Next.js App Router, Better Auth, axios-style HTTP calls, and UI libraries for styling and interaction.
Main entry points: proxy.js Route guard · layout.js App shell · page.js Home page · Navbar.jsx Navbar
Components 21
App Router
Route-level screens, shell, and request handling in the Next.js client app.
- App shell · Global layout and styling foundation for the app.
src/app/layout.js - Home page · Public landing page that introduces the service and conversion content.
src/app/page.js - About us · Public informational page about the product or company.
src/app/about-us/page.jsx - All facilities · Facility discovery page with search, filtering, and card summaries.
src/app/all-facilities/page.jsx - Facility detail · Single facility view that supports booking handoff.
src/app/all-facilities/[id]/page.jsx - Add booking · Booking creation flow for selecting a facility and submitting reservation data.
src/app/components/BookingForm.jsx - My bookings · User booking history and booking management view.
src/app/my-bookings/page.jsx - Add facility · Facility creation screen for owner or admin workflows.
src/app/add-facility/page.jsx - Manage facilities · Facility CRUD management page for editing and deleting listings.
src/app/manage-facilities/page.jsx - Login · Sign-in page for authenticated access to private flows.
src/app/login/page.jsx - Register · Account creation page for new users.
src/app/register/page.jsx
Shared UI
Reusable page sections and interaction components composed by route files.
- Navbar · Shared top-level navigation used across screens.
src/app/components/Navbar.jsx - Footer · Shared footer shown in the application shell and marketing pages.
src/app/components/Footer.jsx - Landing sections · Homepage conversion sections including banner, process, trust, testimonials, and featured facilities.
src/app/components/Banner.jsx - Facility UI · Reusable cards, filters, detail view, and booking-related actions for facilities.
src/app/components/FacilitiesCard.jsx - Owner forms · Reusable create, edit, and delete components for facility management.
src/app/components/AddFacilityForm.jsx - Booking actions · Booking history and cancellation interaction components.
src/app/components/MyBooking.jsx
Auth & Access
Local auth integration and route protection boundaries.
- Auth API · Catch-all auth route exposed under the App Router API boundary.
src/app/api/auth/[...all]/route.js - Server auth · Server-side Better Auth setup and access control definitions.
src/lib/auth.js - Client auth · Client-side auth integration used by login and session-aware UI.
src/lib/auth-client.js - Route guard · Request-time protection boundary for private routes.
src/proxy.js
Connections 23
- App shell → Navbar: wraps · Shared shell includes global navigation.
- App shell → Footer: wraps · Shared shell includes the site footer.
- App shell → Home page: hosts · Layout frames the routed pages.
- Home page → Landing sections: composed of · Home page is assembled from marketing sections.
- Home page → Footer: reuses · Public pages share footer content.
- About us → Footer: reuses · Informational pages share the global footer.
- All facilities → Facility UI: uses · List page relies on card and filter components.
- All facilities → Facility detail: links to · Browsing flows into a single-facility view.
- Facility detail → Add booking: handoff to · Detail page leads into booking creation.
- Add booking → Booking actions: updates · Booking flow feeds user booking state and actions.
- My bookings → Booking actions: renders · Bookings page displays booking history and cancellations.
- Add facility → Owner forms: uses · Owner create flow is built from reusable form components.
- Manage facilities → Owner forms: uses · Management page relies on edit and delete UI.
- Login → Client auth: uses · Login page connects to the client auth layer.
- Register → Client auth: uses · Registration page connects to the client auth layer.
- Auth API → Server auth: backed by · API route is implemented through the server auth configuration.
- Route guard → Server auth: checks · Route guard depends on auth state and access rules.
- Route guard → Add facility: protects · Private owner pages are guarded at request time.
- Route guard → Manage facilities: protects · Private owner pages are guarded at request time.
- Route guard → My bookings: protects · Private user pages are guarded at request time.
- Facility UI → Add booking: feeds · Facility detail and list UI feed booking actions.
- Navbar → Login: routes to · Navigation exposes access to auth pages.
- Navbar → All facilities: routes to · Navigation exposes discovery pages.