Files
mrp/README.md
2026-03-15 09:22:39 -05:00

320 lines
15 KiB
Markdown

# MRP Codex
Foundation release for a modular Manufacturing Resource Planning platform built with React, Express, Prisma, SQLite, and a single-container Docker deployment.
## Documentation Maintenance
- Keep [CHANGELOG.md](D:/CODING/mrp-codex/CHANGELOG.md) updated for shipped features, workflow changes, and notable operational updates.
- Keep [README.md](D:/CODING/mrp-codex/README.md), [INSTRUCTIONS.md](D:/CODING/mrp-codex/INSTRUCTIONS.md), [STRUCTURE.md](D:/CODING/mrp-codex/STRUCTURE.md), [ROADMAP.md](D:/CODING/mrp-codex/ROADMAP.md), and [UNRAID.md](D:/CODING/mrp-codex/UNRAID.md) aligned when changes affect their scope.
Current foundation scope includes:
- authentication and RBAC
- company branding and theme settings
- CRM customers and vendors with create/edit/detail workflows
- CRM search, filtering, status tagging, and reseller hierarchy
- CRM contact history, account contacts, and shared attachments
- inventory item master, BOM, warehouse, stock-location, and stock-transaction flows
- sales quotes and sales orders with searchable customer and SKU entry
- purchase orders with searchable vendor and SKU entry, restricted to purchasable inventory items
- purchase receiving with warehouse/location posting and receipt history against purchase orders
- branded quote, sales-order, and purchase-order PDFs through the shared backend document pipeline
- shipping shipments linked to sales orders with packing-slip PDFs
- file storage and PDF rendering
## Product Map
Current completed foundation areas:
- dashboard foundation
- CRM foundation
- inventory foundation
- sales and purchasing foundation
- shipping foundation
- branding, attachments, auth/RBAC, and PDF infrastructure
Planned cross-module execution areas:
- projects and program management
- manufacturing execution
- planning and gantt scheduling
Near-term priorities:
1. Shipping labels, bills of lading, and logistics attachments
2. Projects and program management
3. Manufacturing execution
4. Vendor invoice/supporting-document attachments and broader vendor-facing operational depth
5. Sales approvals and revision history
Revisit / deferred items:
- local Windows Prisma migration reliability
- frontend code-splitting and bundle-size reduction
- sales approvals and revision history
- inventory transfers, reservations, and deeper stock controls
- deeper audit-trail coverage
- projects are not yet first-class records even though planning/manufacturing flows will need them
Dashboard direction:
- the landing page is now `Dashboard`, not `Overview`
- it should remain a metric-oriented operational surface rather than a generic welcome page
- new modules should add reusable dashboard cards/panels instead of replacing the whole layout
- future additions should emphasize relevant metrics, next actions, alerts, and workflow shortcuts
- richer recent-activity widgets and exception queues are a planned QOL follow-up, not a separate landing-page redesign
- projects should eventually feed dashboard widgets for active jobs, overdue milestones, shortages, and shipment readiness
Navigation direction:
- module navigation now uses inline SVG icons alongside labels
- new modules should add a clear, domain-appropriate SVG icon when they are added to the shell
- icons should stay lightweight, theme-aware, and dependency-free unless there is a strong reason to introduce a shared icon package
## Projects Direction
Projects should become the long-running program and delivery layer tying together commercial work, engineering context, purchasing, manufacturing, shipping, and customer-facing execution.
Planned interactions:
- CRM: each project should link to a customer account and relevant contacts
- Sales: quotes and sales orders should be able to spawn or attach to projects
- Inventory: projects should reference item/BOM scope and later expose shortages or allocations
- Purchasing: project material demand should be visible to purchasing and receiving workflows
- Shipping: shipments tied to project deliverables should be visible from the project record
- Manufacturing: work orders should link back to projects without turning projects into the manufacturing module
- Planning: project milestones and execution dates should feed gantt scheduling and dependency views
- Dashboard: projects should contribute status, risk, backlog, and milestone widgets
## Manufacturing Direction
Manufacturing should remain a separate execution subsystem rather than being collapsed into Projects.
Planned interactions:
- Projects: manufacturing orders may belong to a project, but projects remain the higher-level long-running record
- Inventory: manufacturing consumes components and produces stock
- Purchasing: shortages and buyout demand should surface from manufacturing execution
- Shipping: completed manufacturing should feed shipment readiness
- Planning: manufacturing orders, routings, and work centers should drive capacity and schedule views
## Workspace
- `client`: React, Vite, Tailwind frontend
- `server`: Express API, Prisma, auth/RBAC, file storage, PDF rendering
- `shared`: shared TypeScript contracts and constants
## Local Development
1. Use Node.js 22 for local development if you want Prisma migration commands to behave the same way as Docker.
2. Install dependencies with `npm.cmd install`.
3. Copy [`.env.example`](D:\CODING\mrp-codex\.env.example) to `.env` and adjust values if needed.
4. Generate Prisma client with `npm run prisma:generate`.
5. Apply committed migrations with `npm run prisma:deploy`.
6. Start the workspace with `npm run dev`.
The frontend runs through Vite in development and is served statically by the API in production.
Seeded admin credentials for first login:
- email: `admin@mrp.local`
- password: `ChangeMe123!`
## Docker
Build and run:
```bash
docker build -t mrp-codex .
docker run -p 3000:3000 -v mrp_data:/app/data mrp-codex
```
Command-line build notes:
- The Dockerfile is intended to be built directly from the repo root with `docker build`
- `puppeteer` browser download is disabled during image build because the runtime image installs system Chromium
- You can override the Node base image version if needed:
```bash
docker build --build-arg NODE_VERSION=22 -t mrp-codex .
```
The container startup script runs `npx prisma migrate deploy` automatically before launching the server.
This Docker path is currently the most reliable way to ensure the database schema matches the latest CRM and inventory migrations on Windows.
## Persistence And Backup
- SQLite database path: `/app/data/prisma/app.db`
- Uploaded files: `/app/data/uploads`
- Backup the entire mounted `/app/data` volume to preserve both records and attachments.
## CRM
The current CRM foundation supports:
- customer and vendor list, detail, create, and edit flows
- search by text plus status and state/province filters
- customer reseller flag, reseller discount, and parent-child hierarchy
- contact-history timeline entries for notes, calls, emails, and meetings
- multiple account contacts with role and primary-contact tracking
- shared file attachments on customer and vendor records
- commercial terms fields including payment terms, currency, tax exempt, and credit hold
QOL direction:
- saved filters and quick views
- cleaner hierarchy navigation for reseller/customer trees
- richer downstream rollups once purchasing and shipping grow further
Recent CRM features depend on the committed Prisma migrations being applied. If you update the code and do not run migrations, the UI may render fields that are not yet present in the database.
## Inventory
The current inventory foundation supports:
- protected item master list, detail, create, and edit flows
- SKU, description, type, status, unit-of-measure, sellable/purchasable, default cost, default price, and notes fields
- BOM header and BOM line editing directly on the item form
- searchable component lookup for BOM lines, designed for large item catalogs
- SKU-first searchable component lookup for BOM lines, with SKU shown in the picker and description kept separate in the selected row
- BOM detail display with component SKU, name, quantity, unit, notes, and position
- protected warehouse list, detail, create, and edit flows
- nested stock-location management inside each warehouse record
- inventory transaction posting for receipts, issues, and adjustments
- item on-hand quantity, stock-by-location balances, and recent stock history
- item-level file attachments for drawings and support documents
- seeded sample inventory items and a starter assembly BOM during bootstrap
- seeded sample warehouse and stock locations during bootstrap
QOL direction:
- stock transfers
- reservations and allocations
- clearer warehouse dashboards and shortage views
- BOM revisions and where-used visibility
This module introduces `inventory.read` and `inventory.write` permissions. After updating the code, restart the server against the migrated database so bootstrap can upsert the new permissions onto the default administrator role.
`defaultPrice` now flows from inventory items into quote and sales-order line entry when a SKU is selected. Users can still override the line price after selection.
## Sales
The current sales foundation supports:
- quote and sales-order list, detail, create, and edit flows
- searchable customer lookup instead of static customer dropdowns
- SKU-searchable line entry for quote and order lines
- document-level discount, tax, freight, subtotal, and total calculations
- reseller discount defaulting from customer records into sales documents
- status quick actions directly from quote and order detail pages
- quote conversion into a sales order
- line-level unit prices populated from the selected inventory item default price
- branded quote and sales-order PDFs through the shared document pipeline
QOL direction:
- line duplication and faster keyboard-heavy line editing
- stronger revision/approval flow
- richer PDF output for quotes and sales orders
This module introduces `sales.read` and `sales.write` permissions. After updating the code, restart the server against the migrated database so bootstrap can upsert the new permissions onto the default administrator role.
## Purchasing
The current purchasing foundation supports:
- purchase-order list, detail, create, and edit flows
- searchable vendor lookup instead of a static vendor dropdown
- SKU-searchable line entry for purchase-order lines
- purchase-order item lookup restricted to inventory items flagged as purchasable
- receiving workflow tied to purchase orders, with receipt history and inventory posting
- document-level tax, freight, subtotal, and total calculations
- quick status actions directly from purchase-order detail pages
- vendor payment terms and currency surfaced on purchase-order forms and details
- branded purchase-order PDFs through the shared document pipeline
QOL direction:
- vendor invoice/supporting-document attachments
- richer dashboard widgets for vendor queues and inbound material exceptions
This module introduces `purchasing.read` and `purchasing.write` permissions. After updating the code, restart the server against the migrated database so bootstrap can upsert the new permissions onto the default administrator role.
## Shipping
The current shipping foundation supports:
- shipment list, detail, create, and edit flows
- searchable sales-order lookup instead of a static order dropdown
- shipment records linked directly to sales orders
- carrier, service level, tracking number, package count, notes, and ship date fields
- shipment quick status actions from the shipment detail page
- related-shipment visibility from the sales-order detail page
- branded packing-slip PDF rendering from shipment detail pages
QOL direction:
- shipment labels
- bills of lading
- logistics attachments and reprint/history actions
- partial-shipment and split-shipment UX
This module introduces `shipping.read` and `shipping.write` permissions. After updating the code, restart the server against the migrated database so bootstrap can upsert the new permissions onto the default administrator role.
Moving forward, any UI that requires searching for records or items should use a searchable picker/autocomplete rather than a static dropdown. Filter controls can remain dropdowns, but non-filter lookup fields such as SKU pickers, customer selectors, vendor selectors, and similar operational search inputs should not be implemented as long static selects.
## UI Density
The active client screens have been normalized toward a denser workspace layout:
- form controls and action bars use tighter padding
- CRM, inventory, warehouse, settings, dashboard, and login screens use reduced card spacing
- headings, metric cards, empty states, and long-text blocks were tightened for better data density
This denser layout is now the baseline for future screens. New pages should avoid reverting to oversized card padding, tall action bars, or long static dropdowns for operational datasets.
## Branding
Brand colors and typography are configured through the Company Settings page and the frontend theme token layer. Update runtime branding in-app, or adjust defaults in the theme config if you need a new baseline brand.
Logo uploads are stored through the authenticated file pipeline and are rendered back into the settings UI through an authenticated blob fetch, so image preview works after save and refresh.
## Migrations
- Create a local migration: `npm run prisma:migrate`
- Apply committed migrations in production: `npm run prisma:deploy`
- If Prisma migration commands fail on a local Node 24 Windows environment, use Node 22 or Docker for migration execution. The committed migration files in `server/prisma/migrations` remain the source of truth.
As of March 14, 2026, the latest committed domain migrations include:
- CRM status and list filters
- CRM contact-history timeline
- reseller hierarchy and reseller discount support
- CRM commercial terms and account contacts
- CRM lifecycle stages and operational metadata
- inventory item master and BOM foundation
- warehouse and stock-location foundation
- inventory transactions and on-hand tracking
- sales quote and sales-order foundation
- purchase-order foundation
- purchase receiving foundation
- branded sales and purchasing PDF templates
- inventory default price support
- sales totals and commercial fields
- shipping foundation
Recent roadmap-driving migrations should always be applied before validating new CRM, inventory, sales, shipping, or purchasing features in a running environment.
## UI Notes
- Dark mode persistence is handled through the frontend theme provider and should remain stable across page navigation.
- The shell layout is tuned for wider desktop use than the original foundation build, and now exposes Dashboard, CRM, inventory, sales, shipping, settings, and planning modules from the same app shell.
- The active module screens now follow a tighter density baseline for forms, tables, and detail cards.
- The dashboard should continue evolving as a modular metric board for future purchasing, shipping, manufacturing, and audit data.
- The client build still emits a Vite chunk-size warning because the app has not been code-split yet.
## PDF Generation
Puppeteer is used by the backend to render HTML templates into professional PDFs. The current PDF surface includes the branded company-profile preview, sales quotes, sales orders, purchase orders, and shipment packing slips. The Docker image includes Chromium runtime dependencies required for headless execution.