How mhd-muzammil/inventory_frontend works
This repository is a single-page front-end application built with React, TypeScript, and Vite. Its architecture is organized around domain modules rather than technical layers, with a shared API/client layer feeding page-level feature components, hooks, and local state stores.
1. Application shell and runtime
The app starts in src/main.tsx and src/App.tsx, then renders into a Vite-hosted browser SPA. Styling and UI composition are handled with Tailwind/PostCSS plus a shared component library under src/components/ui. The build/deploy setup is standard Vite, with vercel.json suggesting deployment to Vercel.
2. Route-level page composition
src/pages/* contains the top-level screens: Dashboard, Tickets, Stock, Materials, Customers, Quotations, Purchase Orders, Invoices, Transactions, Reports, Settings, user/engineer/manager management, and specialized buffer/buffer-stock screens. These pages are the main integration points that assemble domain-specific tables, toolbars, dialogs, and detail panels.
3. Layout and access control boundary
src/components/layout defines the application chrome: AppLayout, Sidebar, Navbar, and MobileNav. ProtectedRoute is the auth gate for protected pages. This creates a clear boundary between public auth screens (Login, Register) and the authenticated application workspace.
4. Backend/API integration layer
All server communication is centralized in src/api/*, with a shared client.ts and tokenStore.ts. Each domain has its own API module (tickets.ts, stock.ts, materials.ts, invoices.ts, etc.), which keeps transport concerns separated from UI code. This indicates the UI is a consumer of a backend service rather than owning business data locally.
5. Auth and session handling
src/store/authStore.ts and src/hooks/useAuth.ts manage authentication state on the client, while src/api/auth.ts handles login/register/session-related requests. The token store implies bearer-token authentication and client-side persistence of credentials or session tokens.
6. Shared data-fetching hooks
The src/hooks directory is the primary abstraction for getting data into components. Hooks such as useTickets, useStock, useMaterials, useInvoices, useReports, useDashboard, and useBuffer wrap API calls and provide feature-oriented state to pages. This keeps data loading, caching, and refresh logic out of presentation components.
7. Ticketing and workflow subsystem
Tickets appear to be a core business object. The ticket area includes table, detail panel, edit/create dialogs, assignment dialogs, print template, and workflow controls. src/components/workflow plus src/lib/workflow.ts and src/store/workflowStore.ts suggest the app models explicit ticket status transitions, SLA timing, priority, and delayed/breach states.
8. Inventory and stock management subsystem
There are multiple stock-related domains: general stock, materials, and buffer stock. Standard stock management lives under src/components/stock, while materials has its own CRUD surface, and buffer/buffer-stock has a dedicated workflow and data model. This implies inventory is split into operational stock and a more specialized intermediate holding system.
9. Buffer stock as a distinct business area
src/components/buffer-stock is a rich subsystem with cases, approvals, region stock, replenishment, transfers, audit log, and stock item dialogs. The presence of BufferCase*, ApprovalQueue, and AuditLogTable indicates this is not just inventory CRUD; it is a process-driven module with traceability and approval steps.
10. Commercial and procurement modules
Purchase orders, quotations, invoices, transactions, part requests, and customers are all separate feature areas with their own forms, tables, and toolbars. This indicates a workflow spanning customer-facing demand, quoting, procurement, invoicing, and financial transactions, all mediated through the shared API layer.
11. Dashboard and reporting
src/components/dashboard and src/components/reports provide analytics surfaces: KPI cards, charts, heatmaps, SLA breach feeds, recent activity, stock movement, and category summaries. These components are read-only consumers of aggregated API endpoints from dashboard.ts and reports.ts, distinct from the transactional CRUD modules.
12. State management strategy
Global state is intentionally small and domain-specific: authStore, themeStore, and workflowStore. Most other state is kept local to pages/dialogs or obtained through hooks, which keeps the architecture closer to feature-driven React than a large centralized store architecture.
13. Validation, types, and shared utilities
src/lib/validations.ts, src/types/*, and src/lib/utils.ts provide shared domain contracts and helper functions. src/lib/mock-data.ts suggests the app may support seeded/demo data or local development fallbacks, but the dominant shape is still API-driven.
14. UI patterning and reuse
The codebase relies heavily on reusable CRUD patterns: each domain typically has a table, toolbar, and one or more modal dialogs for create/edit/adjust/receive/assign operations. That repeated structure is the main architectural motif and is useful to reflect in a diagram as a shared presentation layer feeding multiple domains.
15. Tooling and constraints
The repo uses TypeScript, ESLint, Tailwind, and Vite. Those choices matter architecturally because they reinforce a static, componentized front-end with type-checked API contracts and fast client-side builds, but they do not introduce additional runtime services beyond the browser app and its backend API.
Overall, the architecture is a feature-oriented React SPA with a thin, centralized API boundary, small global stores, and many domain-specific UI modules layered on top. The main diagram should show the browser app shell at the top, then routed feature pages, then shared hooks/API/store layers, with backend services behind the API client boundary.
Main entry points: pages Pages · hooks Hooks · App.tsx App · tickets Tickets
Components 18
Runtime
Browser SPA entry, app shell, and routing boundary
Feature modules
Domain-oriented pages and UI modules
- Pages · Top-level screens assembled from domain components
src/pages - Auth pages · Login and register entry points
src/pages/Login.tsx - Dashboard · KPI and operational overview
src/components/dashboard - Tickets · Ticket CRUD, assignment, print, and timeline flows
src/components/tickets - Stock · Operational stock tables, forms, and adjustments
src/components/stock - Materials · Material CRUD and deletion control
src/components/materials - Buffer stock · Cases, approvals, replenishment, transfers, and audit trail
src/components/buffer-stock - Commerce · Quotations, purchase orders, invoices, customers, transactions, and part requests
src/components/quotations - Reports · Summary charts, category analysis, and KPI reporting
src/components/reports
Shared runtime
Hooks, stores, utilities, and reusable UI
API boundary
Centralized client and domain API modules
- API client · Shared HTTP client, token handling, and domain API modules
src/api/client.ts - Backend API · Remote application data and business endpoints
Connections 23
- main.tsx → App: mounts · Bootstraps the SPA root
- App → Layout: renders shell · Wraps protected workspace routes in the app chrome
- App → Auth pages: routes auth · Exposes login and register screens
- Layout → Pages: hosts views · Provides the authenticated workspace for feature pages
- Pages → Dashboard: includes · Dashboard page composes analytic widgets
- Pages → Tickets: includes · Ticket page composes workflow controls and dialogs
- Pages → Stock: includes · Stock page composes inventory management views
- Pages → Materials: includes · Materials page composes material CRUD surfaces
- Pages → Buffer stock: includes · Buffer stock page composes process-heavy operations
- Pages → Commerce: includes · Commercial pages cover customers, quotations, orders, invoices, and transactions
- Pages → Reports: includes · Reports page surfaces analytics and summaries
- Tickets → Workflow: uses · Ticket UI depends on shared transition and SLA logic
- Tickets → Hooks: loads data · Ticket screens consume ticket and auth hooks
- Stock → Hooks: loads data · Inventory screens use stock hooks
- Materials → Hooks: loads data · Material screens use materials hooks
- Buffer stock → Hooks: loads data · Buffer stock screens use buffer-specific hooks
- Commerce → Hooks: loads data · Commercial flows are driven by domain hooks
- Dashboard → Hooks: loads data · Dashboard widgets consume aggregated metrics hooks
- Reports → Hooks: loads data · Reporting widgets consume reporting hooks
- Hooks → API client: calls · Hooks wrap centralized API modules
- Stores → API client: shares auth · Session state and token persistence support API calls
- API client → Backend API: requests · HTTP client communicates with the remote service
- Pages → UI kit: builds with · Feature screens use shared UI primitives