How hamas-aboalmaali/sarh-orders-console works
Orders Console lets agents authenticate, search and browse a large order history, register phone orders safely, and view deliberately slow order statistics; admins can also delete orders. The main path runs from the web console through authenticated API routes to PostgreSQL. The graph preserves the separate list, creation/idempotency, authentication, and overview stages. Some client hooks and API modules were not excerpted, so their links are included only where the README documents the behavior or a read file shows the reference.
Main entry points: orders.routes.ts Order endpoints · App.tsx Console shell · require-auth.ts Session and role guard · schema.ts PostgreSQL data
Components 21
Web console
- Console shell
apps/web/src/App.tsx - Sign-in page
apps/web/src/features/auth/LoginPage.tsx - Session client
apps/web/src/features/auth/session.ts - Orders workspace
apps/web/src/features/orders/OrdersPage.tsx - Virtual order table
apps/web/src/features/orders/OrdersTable.tsx - Order entry dialog
apps/web/src/features/orders/create/CreateOrderDialog.tsx - Create mutation
apps/web/src/features/orders/create/use-create-order.ts - Order query keys
apps/web/src/features/orders/order-keys.ts - Overview screen
apps/web/src/features/stats/OverviewPage.tsx - Stats query
apps/web/src/features/stats/use-order-stats.ts - HTTP client
apps/web/src/lib/api-client.ts
API services
- API composition
apps/api/src/app.ts - Auth endpoints
apps/api/src/auth/auth.routes.ts - Session and role guard
apps/api/src/auth/require-auth.ts - Order endpoints
apps/api/src/orders/orders.routes.ts - Search and deletion
apps/api/src/orders/orders.service.ts - Idempotent creation
apps/api/src/orders/create-order.ts - Order statistics
apps/api/src/orders/order-stats.ts
Persistence and contracts
- PostgreSQL data
apps/api/src/db/schema.ts - Shared Zod contracts
packages/shared/src/orders.ts
Other components
- Agent / admin
Connections 29
- Agent / admin → Console shell: uses
README.md - Console shell → Sign-in page: shows
apps/web/src/App.tsx - Console shell → Session client: checks session
apps/web/src/App.tsx - Console shell → Orders workspace: shows orders
apps/web/src/App.tsx - Console shell → Overview screen: shows overview
apps/web/src/App.tsx - Sign-in page → Session client: signs in
apps/web/src/features/auth/LoginPage.tsx - Session client → HTTP client: requests session
apps/web/src/features/auth/session.ts - Orders workspace → Virtual order table: renders
apps/web/src/features/orders/OrdersPage.tsx - Orders workspace → Order entry dialog: opens
apps/web/src/features/orders/OrdersPage.tsx - Order entry dialog → Create mutation: submits through
apps/web/src/features/orders/create/CreateOrderDialog.tsx - Create mutation → HTTP client: posts order
apps/web/src/features/orders/create/use-create-order.ts - Create mutation → Order query keys: invalidates cache
apps/web/src/features/orders/create/use-create-order.ts - Overview screen → Stats query: loads stats
apps/web/src/features/stats/OverviewPage.tsx - Stats query → Order query keys: uses query key
apps/web/src/features/stats/use-order-stats.ts - API composition → Auth endpoints: mounts
apps/api/src/app.ts - API composition → Session and role guard: protects orders
apps/api/src/app.ts - API composition → Order endpoints: mounts
apps/api/src/app.ts - Auth endpoints → Session and role guard: checks identity
apps/api/src/auth/auth.routes.ts - Session and role guard → PostgreSQL data: loads user
apps/api/src/auth/require-auth.ts - Order endpoints → Session and role guard: checks role
apps/api/src/orders/orders.routes.ts - Order endpoints → Shared Zod contracts: validates requests
apps/api/src/orders/orders.routes.ts - Order endpoints → Search and deletion: lists and deletes
apps/api/src/orders/orders.routes.ts - Order endpoints → Idempotent creation: creates order
apps/api/src/orders/orders.routes.ts - Order endpoints → Order statistics: gets statistics
apps/api/src/orders/orders.routes.ts - Search and deletion → PostgreSQL data: reads and deletes
apps/api/src/orders/orders.service.ts - Idempotent creation → PostgreSQL data: claims and writes
apps/api/src/orders/create-order.ts - Order statistics → PostgreSQL data: aggregates
apps/api/src/orders/order-stats.ts - Virtual order table → Shared Zod contracts: uses order types
apps/web/src/features/orders/OrdersTable.tsx - Order endpoints → HTTP client: serves client requests
README.md