How joshade/appointments-express-frontend works
This repository is a single-page React frontend for an appointments system. The architecture is client-side UI plus a thin data-access layer that talks to a separate backend API. The backend is not included here; the frontend is designed to run in the browser and call BASE_URL/api endpoints configured in src/axios.ts.
1. Application shell and runtime
- The app is bootstrapped from src/index.tsx and rendered into the browser DOM.
- public/index.html, public/manifest.json, public/robots.txt, and public/_redirects support static hosting and SPA routing.
- src/serviceWorker.ts indicates PWA-style support, though the main architecture is still a browser SPA.
2. Global state and store boundary
- src/app/store.ts is the Redux store composition point.
- src/app/hooks.ts provides typed Redux hooks for dispatch/select usage.
- Feature state is split into slices under src/features, notably auth, customerAuth, and domain type definitions for appointments, stores, users, and common types.
3. Server communication layer
- src/axios.ts centralizes the API base URL and is the main boundary between UI and backend.
- src/app/services/appointments.ts suggests RTK Query or similar service-based fetching for appointment-related endpoints.
- The readme explicitly says this frontend uses Redux Toolkit and RTK Query, so data fetching/caching is part of the app’s state layer rather than ad hoc component calls.
4. Authentication and route protection
- Authentication is handled through dedicated UI and state modules, including src/features/auth/authSlice.ts and src/features/customerAuth/customerAuthSlice.ts.
- Route gating is implemented in src/components/pages/auth/ProtectedRoute.tsx and UnprotectedRoute.tsx.
- There are separate login flows for different user types, visible in Login.tsx, LoginCustomer.tsx, and Register.tsx.
5. Major user-facing domains
- Public marketing/home area: src/components/pages/home/* contains the landing page and sections like features, stats, steps, roles, about, and navigation.
- Authenticated dashboard area: src/components/Dashboard.tsx, CustomerDashboard.tsx, and src/components/sidebar/* define the main logged-in navigation shell.
- Customer appointment area: src/components/pages/customerview/* includes viewing appointment lists and appointment details.
- Appointment management area: src/components/pages/manageappointment/* includes list/calendar views and appointment cards.
- Store management area: src/components/pages/managestore/* handles store info, hours, closure days/times, and store listing.
- Role/account management: src/components/pages/managerole/* and manageaccount/ManageAccount.tsx cover role assignment and account settings.
6. UI composition pattern
- Pages are built from smaller shared components rather than being monolithic.
- Shared primitives live in src/components/shared/* such as buttons, form controls, modal, scheduler, avatar upload, error notice, and dashboard headers.
- This indicates a design-system-like layer used across the business domains.
7. Forms and user input flow
- Reusable form helpers are centralized in src/components/shared/FormElements.tsx, TimeInput.tsx, Select.tsx, Checkbox.tsx, and RadioButton.tsx.
- Custom hooks in src/hooks/useForm.ts and src/hooks/useSelectStore.ts encapsulate repeated form and selection logic.
- Appointment creation is a notable form flow (src/components/pages/createappointment/*) with instructions, modal form content, and scheduler integration.
8. Customer vs. admin separation
- The file structure strongly suggests two roles with different experiences:
- customer-facing views under CustomerDashboard, LoginCustomer, and customerview/*
- staff/admin-facing management views under manageappointment, managestore, managerole, and manageaccount
- This boundary is reinforced by separate auth slices/types for general auth and customer auth.
9. Shared domain model layer
- Type definitions are organized by domain under src/features/*Types.ts.
- These types likely act as the contract between API responses, Redux state, and form/UI props.
- This reduces coupling between components and backend payload shapes.
10. Styling and presentation
- Tailwind CSS is the primary styling system, configured via tailwind.config.js and src/styles/tailwind.css.
- src/App.css appears to be supplemental app-level styling.
- The architecture is therefore component-driven with utility-first styling rather than CSS modules or a large custom stylesheet hierarchy.
11. Navigation and layout
- Reusable layout/navigation pieces include Sidebar, GridLayout, and top navigation components under the auth/home sections.
- ErrorPage.tsx provides a terminal route/view for invalid states or routing errors.
12. Overall data flow
- User action in a page/component
- form or UI state managed locally or through Redux
- async call through axios or RTK Query service to the backend API
- response stored in Redux/cache or passed directly into components
- shared components render the result in dashboard/list/detail views
13. What to show in an architecture diagram
- A browser SPA at the top
- Redux Toolkit store and RTK Query service layer in the middle
- Separate feature modules for auth, customer auth, appointments, stores, and users
- A backend API boundary reached through axios.ts
- UI grouped into public home, auth, customer dashboard, and admin management areas
14. Notable operational detail
- The readme instructs changing src/axios.ts to point at the deployed backend and to keep /api in the URL. That makes the backend endpoint configuration an explicit deployment concern for the frontend.
Main entry points: Button.tsx Shared UI · store.ts Redux store · App.tsx App shell · appointments.ts Appointments API
Components 23
Shell
Browser entrypoints, static hosting, and app bootstrap.
- App entry · React DOM bootstrap for the SPA.
src/index.tsx - App shell · Top-level application composition and route wiring.
src/App.tsx - Static host · SPA hosting and PWA support files.
public/index.html - Service worker · Service worker support for browser caching/offline behavior.
src/serviceWorker.ts
State & Data
Redux store, API boundary, and domain types.
- Redux store · Central Redux store composition point.
src/app/store.ts - Redux hooks · Typed dispatch and selector helpers.
src/app/hooks.ts - API client · Central axios configuration and backend base URL boundary.
src/axios.ts - Appointments API · Service layer for appointment-related backend calls.
src/app/services/appointments.ts - Auth state · General authentication state and actions.
src/features/auth/authSlice.ts - Customer auth · Customer-specific authentication state.
src/features/customerAuth/customerAuthSlice.ts - Domain types · Shared feature types for appointments, stores, users, and common models.
src/features/commonTypes.ts
Public Site
Landing pages and unauthenticated marketing views.
- Home pages · Landing page sections and top navigation.
src/components/pages/home/Home.tsx
Auth
Sign-in, sign-up, and route protection.
- Auth pages · Login, customer login, register, and auth gating views.
src/components/pages/auth/Login.tsx - Route gates · Protected and unprotected route wrappers plus auth loading.
src/components/pages/auth/ProtectedRoute.tsx
Customer Area
Customer-facing appointment views.
- Customer views · Customer appointment list and appointment detail pages.
src/components/pages/customerview/viewappointments/ViewAppointments.tsx
Admin Area
Staff-facing management workflows.
- Create appt · Appointment creation flow with instructions, modal form, and scheduler.
src/components/pages/createappointment/CreateAppointment.tsx - Manage appt · Appointment list and calendar management views.
src/components/pages/manageappointment/ManageAppointment.tsx - Manage store · Store information, hours, and closure management.
src/components/pages/managestore/ManageStore.tsx - Manage roles · Role assignment and role detail management.
src/components/pages/managerole/ManageRole.tsx - Account settings · Account management and profile-related settings.
src/components/pages/manageaccount/ManageAccount.tsx
Shared UI
Reusable components and layout primitives.
- Dashboards · Main dashboard shells for staff and customers.
src/components/Dashboard.tsx - Sidebar nav · Sidebar layout and menu data for authenticated areas.
src/components/sidebar/Sidebar.tsx - Shared UI · Reusable controls, forms, modals, scheduler, and notices.
src/components/shared/Button.tsx
Connections 26
- App entry → App shell: boots · Browser entry mounts the app shell.
- App shell → Redux store: uses · App composes the Redux store boundary.
- App shell → Route gates: routes · Top-level routing relies on auth guards.
- App shell → Dashboards: renders · Authenticated areas are shown through dashboard shells.
- App entry → Static host: hosted by · SPA is served from static hosting files.
- App entry → Service worker: registers · Bootstrapping includes service worker support.
- Redux store → Redux hooks: exposes · Typed hooks wrap store access for components.
- Redux store → Auth state: contains · Redux store includes auth state.
- Redux store → Customer auth: contains · Redux store includes customer auth state.
- Redux store → Domain types: typed by · Feature types define store and UI contracts.
- Appointments API → API client: calls · RTK Query service uses the shared HTTP client boundary.
- Auth pages → Route gates: gated by · Login and registration flows are controlled by route wrappers.
- Auth pages → Auth state: updates · General auth pages interact with auth state.
- Auth pages → Customer auth: updates · Customer login flow interacts with customer auth state.
- Home pages → Shared UI: composes · Landing sections are built from shared UI primitives.
- Dashboards → Sidebar nav: navigates · Logged-in shells use the sidebar navigation.
- Dashboards → Shared UI: composes · Dashboard pages rely on common headers and controls.
- Create appt → Shared UI: uses · Booking flow is assembled from shared forms and scheduler UI.
- Create appt → Appointments API: fetches · Appointment creation and related data use the appointments service.
- Manage appt → Appointments API: fetches · Management views read appointment data through the service layer.
- Manage store → Shared UI: uses · Store management is built from reusable forms and tables.
- Manage roles → Shared UI: uses · Role management reuses shared form controls.
- Account settings → Shared UI: uses · Account settings are composed from common UI primitives.
- Customer views → Appointments API: fetches · Customer appointment pages read appointment data through the service layer.
- Customer views → Shared UI: uses · Customer detail/list views use shared components.
- Static host → App shell: loads · Static host delivers the SPA bundle.