# ashiquehussain00/electronic-repair-app architecture

> Architecture diagram of the GitHub repository ashiquehussain00/electronic-repair-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ashiquehussain00/electronic-repair-app
- Repository: https://github.com/ashiquehussain00/electronic-repair-app

## Overview

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: [`src/routes/index.tsx`](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/routes/index.tsx) (Routes), [`server.ts`](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/server.ts) (API server), [`src/services/api.ts`](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/services/api.ts) (API client), [`vite.config.ts`](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/vite.config.ts) (Vite build)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend app"]
  node_main(("Entry<br/>bootstrap<br/>[main.tsx]"))
  node_app["App shell<br/>[App.tsx]"]
  node_routes["Routes<br/>routing<br/>[index.tsx]"]
  node_auth["Auth state<br/>context<br/>[AuthContext.tsx]"]
  node_public_layout["Public layout<br/>[PublicLayout.tsx]"]
  node_navbar["Navbar<br/>ui component<br/>[Navbar.tsx]"]
  node_loading["Loading<br/>ui component<br/>[LoadingScreen.tsx]"]
  node_home_pages["Public pages<br/>page set"]
  node_account_pages["Account pages<br/>page set"]
  node_dashboard_pages["Dashboards<br/>page set"]
  node_api_client["API client<br/>http client<br/>[api.ts]"]
  node_auth_api["Auth API<br/>[auth.ts]"]
  node_booking_api["Booking API<br/>[booking.ts]"]
end

subgraph group_backend["Backend API"]
  node_server[("API server<br/>express app<br/>[server.ts]")]
  node_file_store[("JSON store<br/>persistence")]
end

subgraph group_delivery["Delivery"]
  node_vite["Vite build<br/>frontend build<br/>[vite.config.ts]"]
  node_ci["CI workflow<br/>automation<br/>[ci.yml]"]
  node_deploy["Deploy config<br/>deployment<br/>[vercel.json]"]
end

node_main -->|"boots"| node_app
node_app -->|"renders"| node_routes
node_routes -->|"public shell"| node_public_layout
node_public_layout -->|"includes"| node_navbar
node_routes -->|"fallback"| node_loading
node_routes -->|"guards"| node_auth
node_routes -->|"public pages"| node_home_pages
node_routes -->|"account flows"| node_account_pages
node_routes -->|"role areas"| node_dashboard_pages
node_auth -->|"uses"| node_api_client
node_auth_api -->|"uses"| node_api_client
node_booking_api -->|"uses"| node_api_client
node_api_client -->|"calls"| node_server
node_auth_api -->|"auth routes"| node_server
node_booking_api -->|"booking routes"| node_server
node_server -->|"persists"| node_file_store
node_server -.->|"separate build"| node_vite
node_vite -->|"packages"| node_deploy
node_ci -->|"checks"| node_vite
node_ci -->|"checks"| node_server

click node_main "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/main.tsx"
click node_app "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/App.tsx"
click node_routes "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/routes/index.tsx"
click node_auth "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/context/AuthContext.tsx"
click node_public_layout "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/components/PublicLayout.tsx"
click node_navbar "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/components/Navbar.tsx"
click node_loading "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/components/LoadingScreen.tsx"
click node_api_client "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/services/api.ts"
click node_auth_api "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/services/auth.ts"
click node_booking_api "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/services/booking.ts"
click node_server "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/server.ts"
click node_vite "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/vite.config.ts"
click node_ci "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/.github/workflows/ci.yml"
click node_deploy "https://github.com/ashiquehussain00/electronic-repair-app/blob/main/vercel.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_app,node_routes,node_auth,node_public_layout,node_navbar,node_loading,node_home_pages,node_account_pages,node_dashboard_pages,node_api_client,node_auth_api,node_booking_api toneBlue
class node_server,node_file_store toneAmber
class node_vite,node_ci,node_deploy toneMint
```

## Components

### Frontend app

React/Vite SPA and client-side state

- [Entry](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/main.tsx): bootstrap · Browser entrypoint that mounts the React app · `src/main.tsx`
- [App shell](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/App.tsx): shell · Top-level application composition · `src/App.tsx`
- [Routes](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/routes/index.tsx): routing · Client-side route map with lazy page loading and guards · `src/routes/index.tsx`
- [Auth state](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/context/AuthContext.tsx): context · JWT-backed client auth state and identity flow · `src/context/AuthContext.tsx`
- [Public layout](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/components/PublicLayout.tsx): layout · Shared frame for public pages with persistent navigation · `src/components/PublicLayout.tsx`
- [Navbar](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/components/Navbar.tsx): ui component · Global public navigation · `src/components/Navbar.tsx`
- [Loading](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/components/LoadingScreen.tsx): ui component · Fallback UI during lazy route loading · `src/components/LoadingScreen.tsx`
- **Public pages**: page set · Home, services, and vendor acquisition surfaces
- **Account pages**: page set · Login, signup, OTP, and password recovery screens
- **Dashboards**: page set · Customer, technician, and admin role workspaces
- [API client](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/services/api.ts): http client · Shared Axios client for backend requests · `src/services/api.ts`
- [Auth API](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/services/auth.ts): service · Auth-related API calls · `src/services/auth.ts`
- [Booking API](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/src/services/booking.ts): service · Booking-related API calls · `src/services/booking.ts`

### Backend API

Express API, auth, and persistence

- [API server](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/server.ts): express app · Express backend with auth, authorization, and domain routes · `server.ts`
- **JSON store**: persistence · Flat-file state persisted on the server

### Delivery

Build, CI, and deployment config

- [Vite build](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/vite.config.ts): frontend build · Frontend dev/build pipeline · `vite.config.ts`
- [CI workflow](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/.github/workflows/ci.yml): automation · Automated checks in GitHub Actions · `.github/workflows/ci.yml`
- [Deploy config](https://github.com/ashiquehussain00/electronic-repair-app/blob/main/vercel.json): deployment · Deployment runtime configuration · `vercel.json`

## Connections

- 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
