How robiulislam08/pos-frontend works
1. This repo is primarily a React-based POS front end, organized as a feature-driven single-page application. The visible stack is Vite + React, with Tailwind for styling and a small set of UI primitives for toasts, tooltips, and shared form/table controls.
2. The application is split by business domain under src/features, which is the main architectural boundary. Major modules include auth, inventory, sales, purchase, expense, barcode, backups, settings, help, and several “masters” screens for customer/supplier/user/product administration.
3. Shared UI and layout concerns live outside the feature folders. src/components/layout contains the app shell pieces like AppLayout, Header, Navbar, and MobileNav, while src/components/common holds reusable building blocks such as DataTable, FormField, PageTitle, SummaryBar, and action button groups.
4. State and cross-cutting concerns are handled through React contexts. AuthContext governs session/login state, and LanguageContext drives internationalization. This makes authentication and locale selection app-wide concerns rather than feature-local ones.
5. Routing is centralized in src/routes/Routes.jsx, with navigation definitions separated into src/config/nav.config.js. That suggests a clear split between route composition, menu generation, and page implementation, which is useful for diagrams of user navigation flow.
6. The data access layer is explicitly separated from the UI. src/services/*.service.js contains domain-specific API clients for auth, products, sales, purchases, stock, suppliers, customers, expenses, credits, settings, barcodes, and user management. These services likely all wrap a shared HTTP client in src/services/api.js.
7. Above the services, domain hooks in src/hooks provide feature-friendly state management and side effects. Hooks like useProducts, useSales, useStock, useSuppliers, useUsers, and useExpenses act as the bridge between pages and the API layer, keeping component code focused on rendering and user interaction.
8. The main runtime data flow is: user action in a page → feature hook → service call → shared API client → backend API → hook state update → UI refresh. Error and success messaging are handled through toast utilities in src/lib/toast-helpers.js and the UI toast components.
9. Internationalization is a first-class subsystem. Translations live in src/i18n/en.json and src/i18n/ar.json, indicating bilingual support, likely with Arabic as a right-to-left use case that affects layout and text rendering.
10. The repo includes a backend-facing story, but the frontend is the core artifact. backend-api-implementation/, server.js, and the Windows start scripts suggest a companion Node-based local server or deployment wrapper, while vercel.json indicates the front end can also be deployed as a web app.
11. Operationally, the project includes build/test/tooling boundaries: Vite for bundling, Vitest for tests, ESLint/PostCSS/Tailwind for code and styling, and public/robots.txt plus index.html for web deployment. These are supporting layers around the main POS UI and API integration architecture.
12. For an architecture diagram, the most important nodes are: the app shell/layout, feature pages, shared contexts, domain hooks, service/API layer, and the external backend. The business flow centers on POS operations like sales, inventory movement, purchases, credits, and reporting, with auth and language as global controls.
Main entry points: Routes.jsx Routes · useProducts.js Feature hooks · App.jsx App · product.service.js Domain services
Components 22
UI shell
App shell, shared components, and page composition.
- App · Main React application bootstrap and composition root.
src/App.jsx - Layout · App shell with header, navbar, and mobile navigation.
src/components/layout/AppLayout.jsx - Common UI · Reusable page controls such as tables, forms, titles, and action buttons.
src/components/common/DataTable.jsx - Toast UI · Toast and tooltip primitives used for transient UI feedback.
src/components/ui/toaster.jsx
Cross-cutting state
Contexts and hooks that coordinate app-wide or feature-level state.
- Auth context · Global login and session state for the app.
src/contexts/AuthContext.jsx - Language context · App-wide locale and language switching state.
src/contexts/LanguageContext.jsx - Feature hooks · Domain hooks that bridge pages to services and manage side effects.
src/hooks/useProducts.js - Translations · Bilingual English and Arabic translation resources.
src/i18n/en.json
Data layer
Routing, config, services, and backend integration.
- Routes · Central route composition for the SPA.
src/routes/Routes.jsx - Nav config · Navigation definitions used to generate menus and route-aware UI.
src/config/nav.config.js - API client · Shared HTTP layer used by all domain services.
src/services/api.js - Domain services · Service modules for auth, inventory, sales, purchases, credits, settings, and users.
src/services/product.service.js
Business features
Domain pages organized by business area.
- Auth · Login and session entry point.
src/features/auth/LoginPage.jsx - Inventory · Product, stock, credit, and adjustment workflows.
src/features/inventory/StockPage.jsx - Sales · Sales entry, returns, and reporting.
src/features/sales/SalesPage.jsx - Purchase · Purchase invoice entry and review.
src/features/purchase/PurchaseInvoicePage.jsx - Masters · Customer, supplier, formulation, user, and product administration screens.
src/features/masters/AddCustomerPage.jsx - Settings · Application configuration and preferences.
src/features/settings/SettingsPage.jsx - Backup · Backup and recovery workflow.
src/features/backup/BackupPage.jsx - Barcode · Barcode generation and related workflows.
src/features/barcode/BarcodePage.jsx - Help · User help and guidance page.
src/features/help/HelpPage.jsx
Runtime & deploy
Build, hosting, and companion server artifacts.
- Server & deploy · Companion local server, start scripts, and deployment config.
server.js
Connections 30
- App → Layout: renders · The app composes the global shell around routed content.
- App → Routes: uses · The app mounts the route tree for page navigation.
- App → Auth context: wraps · Authentication state is provided app-wide.
- App → Language context: wraps · Language state is provided app-wide.
- Layout → Common UI: uses · Shell screens use shared page controls and UI building blocks.
- Layout → Nav config: renders nav · The layout reads navigation definitions for menus.
- Layout → Toast UI: shows feedback · Shell-level UI can surface toast notifications.
- Routes → Auth: routes to · Login is one of the routed entry points.
- Routes → Inventory: routes to · Inventory pages are exposed through the route tree.
- Routes → Sales: routes to · Sales pages are exposed through the route tree.
- Routes → Purchase: routes to · Purchase pages are exposed through the route tree.
- Routes → Masters: routes to · Administration screens are exposed through the route tree.
- Routes → Settings: routes to · Settings is a routed destination.
- Routes → Backup: routes to · Backup is a routed destination.
- Routes → Barcode: routes to · Barcode tools are exposed through routing.
- Routes → Help: routes to · Help is available as a routed page.
- Routes → Domain services: depends on · Route-backed pages rely on domain services for data operations.
- Feature hooks → Domain services: calls · Feature hooks encapsulate service calls and side effects.
- Domain services → API client: wraps · Each domain service delegates to the shared HTTP client.
- Auth context → Domain services: authenticates via · Session state is backed by auth-related service calls.
- Language context → Translations: loads · Language context selects translation resources.
- Inventory → Feature hooks: uses · Inventory pages consume domain hooks for products, stock, and credits.
- Sales → Feature hooks: uses · Sales pages consume sales and stock-related hooks.
- Purchase → Feature hooks: uses · Purchase pages consume purchase-related hooks.
- Masters → Feature hooks: uses · Master data screens consume customer, supplier, user, and formulation hooks.
- Settings → Feature hooks: uses · Settings uses a dedicated hook for persisted configuration.
- Backup → Domain services: uses · Backup flows operate against service-backed data operations.
- Barcode → Feature hooks: uses · Barcode workflows use barcode-related state and side effects.
- Server & deploy → App: serves · The companion runtime serves the frontend application.
- Server & deploy → Routes: hosts · Deployment serves the SPA routes.