How pallab-js/stonecrusher_nextjs works
StoneOps is a local-first operations dashboard for a single stone-crusher unit. Staff sign in, use role-gated operational pages to record production, inventory, sales/dispatch, purchases and expenses, then review reports, maps and printed documents. Server actions validate and process mutations through repository queries against a local SQLite database; dashboard and reporting views summarize that operational data. The README documents settings, demo data and JSON backup/restore as additional capabilities. Some feature wiring is documented but unsampled, so those relationships cite the README rather than implying source inspection.
Main entry points: db.ts SQLite database · page.tsx Offline maps · login-form.tsx PIN login · operations.ts Operations repository
Components 26
Access and shell
- PIN login
app/login/login-form.tsx - PIN and roles
lib/auth.ts - Session cookie
lib/session.ts - App shell
components/shell/app-shell.tsx
Unit operations
- Production shifts
components/modules/production-table.tsx - Inventory ledger
components/modules/inventory-view.tsx - Sales and dispatch
components/modules/sales-table.tsx - Customer orders
components/modules/orders-table.tsx - Purchases and GRNs
components/modules/purchases-table.tsx - Expenses
components/modules/expenses-table.tsx - Customer and supplier masters
lib/repo/masters.ts - Operational actions
actions/production.ts - Operations repository
lib/repo/operations.ts
Insights and maps
- Dashboard
components/modules/dashboard.tsx - Analytics queries
lib/repo/analytics.ts - Reports and export
components/modules/reports-view.tsx - Report queries
lib/repo/reports.ts - Offline maps
app/(app)/maps/page.tsx - Map views
components/maps/plant-map.tsx
Local data
- SQLite database
lib/db.ts - Settings and seed data
components/modules/settings-view.tsx
Print and backup
- Statements
lib/repo/statements.ts - Print documents
components/print/statement-sheet.tsx - JSON backup
lib/backup.ts - Backup endpoint
app/api/backup/route.ts
Other components
- Staff
Connections 23
- Staff → PIN login: enters PIN
README.md - PIN login → PIN and roles: verifies PIN
- PIN login → Session cookie: sets session
- App shell → PIN and roles: checks access
components/shell/app-shell.tsx - App shell → Staff: presents modules
README.md - Production shifts → Operational actions: submits shifts
- Sales and dispatch → Customer orders: uses order data
components/modules/sales-table.tsx - Sales and dispatch → Operations repository: reads sales data
app/(app)/sales/page.tsx - Operational actions → Operations repository: writes operations
- Operations repository → SQLite database: queries and updates
lib/repo/operations.ts - Customer and supplier masters → SQLite database: queries masters
lib/repo/masters.ts - Dashboard → Analytics queries: renders metrics
app/(app)/dashboard/page.tsx - Analytics queries → SQLite database: queries summaries
lib/repo/analytics.ts - Reports and export → Report queries: renders reports
app/(app)/reports/page.tsx - Report queries → SQLite database: queries periods
lib/repo/reports.ts - Offline maps → Analytics queries: loads plant summary
app/(app)/maps/page.tsx - Offline maps → Customer and supplier masters: loads products and customers
app/(app)/maps/page.tsx - Offline maps → Map views: supplies map data
app/(app)/maps/page.tsx - Statements → SQLite database: queries balances
lib/repo/statements.ts - Print documents → Statements: shows statement data
components/print/statement-sheet.tsx - Settings and seed data → Staff: manages roles and data
README.md - Backup endpoint → JSON backup: imports and exports
app/api/backup/route.ts - JSON backup → SQLite database: backs up database