How ashiquehussain00/electronic-repair-app works
1. Overall shape
This repo is a full-stack appliance repair booking platform with a React/Vite single-page frontend and an Express/Node backend in server.ts. The frontend talks to the backend through /api calls, and the backend persists data in a flat-file JSON store per the README.
2. Client application boundary
The src/ tree is the browser app. main.tsx boots React, App.tsx wires the app shell, and routes/index.tsx defines all page navigation. The app is organized as a routed SPA rather than a server-rendered app.
3. Routing and page access control
src/routes/index.tsx is the key client-side boundary. It uses React.lazy() for page code-splitting and Suspense with LoadingScreen for fallback rendering. Public pages are wrapped in PublicLayout, while authenticated pages go through a protected route layer that checks auth state and role.
4. Public shell and navigation
PublicLayout.tsx provides the shared frame for public-facing pages, mounting Navbar once and rendering route content via Outlet. This means the public marketing pages share a persistent header and navigation behavior instead of each page owning its own layout.
5. Authentication state flow
AuthContext.tsx is the client’s central auth store. It manages JWT token persistence in localStorage, exposes the current user and role, and provides login/signup/logout/check-auth flows. This context is the main bridge between UI state and server-side identity.
6. Feature surfaces on the frontend
The page set splits into three major user areas:
- Public acquisition pages: Home, AllServices, BecomeVendor
- Account/auth pages: Login, Signup, VerifyOTP, ForgotPassword
- Role dashboards: CustomerDashboard, TechnicianDashboard, AdminDashboard
That division is important for any architecture diagram because it reflects the product’s role-based UI boundaries.
7. Frontend service layer
src/services/api.ts defines the shared Axios client, and auth.ts and booking.ts encapsulate the backend interactions. The UI does not call the backend directly from components in a scattered way; it routes request logic through these service modules.
8. Backend responsibilities
server.ts owns the API, authentication, authorization, and data mutations. It is an Express server using JWT for session identity and bcrypt for password hashing. The README also notes a token middleware that re-checks live user block status on every request, which is a notable server-side enforcement point.
9. Domain API boundaries
The API surface is organized around three domains:
- Auth: register, login, and current-user lookup
- Bookings: listing, creation, status updates, acceptance, and reviews
- Admin: stats, user blocking, and vendor creation
This maps cleanly to the three main roles in the UI: customer, technician, and admin.
10. Data and persistence model
The README describes a file-based JSON database (database.json) rather than a separate database server. That means the backend is stateful at the file layer, with the API acting as the sole mutation boundary. For diagram purposes, the persistence layer is local storage on the server, not an external DB service.
11. Shared UI primitives
LazyImage, LoadingScreen, and Navbar are reusable cross-page components. src/animations/index.ts centralizes motion variants, which implies consistent animation behavior across pages rather than page-specific animation logic.
12. Static app configuration
src/constants/index.ts holds stable business data such as service categories and booking time slots. These are treated as application constants rather than fetched configuration, so they sit outside the API/data flow path.
13. Build and deployment flow
The repo uses Vite for frontend development/build and TypeScript/esbuild for the backend compilation path. The presence of .github/workflows/ci.yml, vite.config.ts, and vercel.json shows the project is designed for automated CI and deployment, with Vite handling the SPA asset pipeline and the Node server handling API/runtime requests.
14. Key architecture boundaries to draw
The most important diagram lines are:
- Browser SPA → Axios service layer → Express API
- React route guards → AuthContext → /api/auth/me
- Role dashboards → bookings/admin endpoints
- Express API → JSON file persistence
These are the core control and data-flow boundaries that define the system.
Main entry points: index.tsx Routes · server.ts API server · api.ts API client · vite.config.ts Vite build
Components 18
Frontend app
React/Vite SPA and client-side state
- Entry · Browser entrypoint that mounts the React app
src/main.tsx - App shell · Top-level application composition
src/App.tsx - Routes · Client-side route map with lazy page loading and guards
src/routes/index.tsx - Auth state · JWT-backed client auth state and identity flow
src/context/AuthContext.tsx - Public layout · Shared frame for public pages with persistent navigation
src/components/PublicLayout.tsx - Navbar · Global public navigation
src/components/Navbar.tsx - Loading · Fallback UI during lazy route loading
src/components/LoadingScreen.tsx - Public pages · Home, services, and vendor acquisition surfaces
- Account pages · Login, signup, OTP, and password recovery screens
- Dashboards · Customer, technician, and admin role workspaces
- API client · Shared Axios client for backend requests
src/services/api.ts - Auth API · Auth-related API calls
src/services/auth.ts - Booking API · Booking-related API calls
src/services/booking.ts
Backend API
Express API, auth, and persistence
- API server · Express backend with auth, authorization, and domain routes
server.ts - JSON store · Flat-file state persisted on the server
Delivery
Build, CI, and deployment config
- Vite build · Frontend dev/build pipeline
vite.config.ts - CI workflow · Automated checks in GitHub Actions
.github/workflows/ci.yml - Deploy config · Deployment runtime configuration
vercel.json
Connections 20
- Entry → App shell: boots · Browser entrypoint mounts the application shell
- App shell → Routes: renders · App shell hands off to client routing
- Routes → Public layout: public shell · Public routes share a common layout
- Public layout → Navbar: includes · Persistent navigation across public pages
- Routes → Loading: fallback · Lazy pages render with a loading screen
- Routes → Auth state: guards · Protected routes consult auth state and role
- Routes → Public pages: public pages · Public acquisition and marketing surfaces
- Routes → Account pages: account flows · Login, signup, OTP, and recovery routes
- Routes → Dashboards: role areas · Role-specific workspaces for customer, technician, and admin
- Auth state → API client: uses · Auth context issues API requests through the shared client
- Auth API → API client: uses · Auth service reuses the shared HTTP client
- Booking API → API client: uses · Booking service reuses the shared HTTP client
- API client → API server: calls · Browser requests flow to the Express API
- Auth API → API server: auth routes · Login, signup, and current-user lookup
- Booking API → API server: booking routes · Booking lifecycle and review actions
- API server → JSON store: persists · Backend reads and writes flat-file application state
- API server → Vite build: separate build · Frontend build remains distinct from backend runtime
- Vite build → Deploy config: packages · Vite builds the SPA asset pipeline for deployment
- CI workflow → Vite build: checks · CI validates the frontend build path
- CI workflow → API server: checks · CI validates the backend TypeScript/runtime path