Skip to main content
Tuğrul Yıldırım
By Tuğrul Yıldırım

Factory ERP Foundation: CRM, Stock and Procurement Workflow

A manufacturing case study showing how disconnected sales, stock, purchasing and finance workflows were moved into a documented ERP foundation.

Technologies Used

Laravel, ERP Workflow, Role Permissions, API Integration
Factory ERP Foundation: CRM, Stock and Procurement Workflow
Laravel 12 Livewire 4 Manufacturing ERP Production Planning Inventory & Procurement Quality Control Finance & Payroll API / MCP / AI

A Private Manufacturing ERP Built Around Real Factory Operations

This project is a large-scale, purpose-built ERP application developed for the internal operations of a manufacturing business. It is not a generic SaaS product and was not designed around a pre-packaged ERP template. The system has evolved directly around real production, sales, inventory, procurement, logistics, quality, finance and workforce processes.

What initially began as an operational foundation grew into an interconnected manufacturing platform where a customer order can be followed through product configuration, material requirements, customer-reserved stock, production planning, work orders, procurement, warehouse operations, shipment, delivery, financial exposure and reporting.

The architectural objective is not simply to store records. The ERP acts as an operational source of truth, connecting decisions made by sales, production, purchasing, warehouse, logistics, quality, finance and HR teams while preserving permissions, transaction integrity and traceability across those workflows.

ERP Scope: From Customer Demand to Factory Execution

Manufacturing operations cannot be represented accurately by isolated CRM, inventory or production screens. A customer order affects material demand; material demand affects procurement and production; production affects customer-reserved stock; available stock affects shipment planning; and shipment events affect both financial exposure and customer order completion.

The application therefore uses connected domain workflows rather than treating each department as an independent software module.

Commercial

Customer & Orders

Customer records, account ownership, addresses, contacts, customer-specific product codes, price lists, order lines, discounts, currencies and commercial documents.

Planning

Production

Production plans, work orders, recipes, production lines, machines, molds, operator reporting, approvals, waste and production progress.

Supply

Stock & Procurement

Inventory buckets, customer stock reservations, material requirements, purchase requests, supplier options, arrivals, returns and physical stock tracking.

Fulfilment

Shipment & Finance

Shipment planning, warehouse confirmation, logistics costs, export documents, currency exposure, collections, margins and operational reporting.

Customer, CRM and Order Management

Customer management extends beyond a conventional contact database. Customer records are connected directly to orders, representatives, addresses, authorized contacts, product codes, reserved stocks, financial information, purchasing requirements and operational history.

Customer Master Data

  • Customer profiles and account ownership
  • Billing and delivery addresses
  • Authorized contacts and communication addresses
  • Industry and customer-region assignments
  • Assigned sales representatives
  • Role-aware customer visibility
  • Customer wallets and payment history
  • Customer-specific intelligence and notes

Customer-Specific Product Context

  • Internal and customer-specific product codes
  • Customer-specific default recipes
  • Product labels and barcode-related requirements
  • Customer-reserved finished goods stock
  • Standard and special-order stock reservations
  • Order-specific product and recipe snapshots
  • Customer-linked procurement requirements
  • Historical order and fulfilment context

Order Management Is the Operational Backbone

Orders are modeled as operational objects rather than simple sales records. A single order may carry customer-specific pricing, currency snapshots, packaging rules, quantities expressed as units or cases, technical recipes, customer product codes, shipment status and production requirements.

Price & Currency Control

Price lists, historical currency snapshots, tax, primary and secondary discounts, and customer-specific commercial terms.

Unit & Packaging Logic

Separate box, case and pieces-per-case rules prevent ambiguous quantity calculations between sales, production, shipment and reporting.

Order-Level Recipes

Recipes can be copied from customer or product defaults and then frozen or adjusted specifically for the individual order.

Controlled Lifecycle

Order state, production, procurement, shipment, delivery and financial context remain linked throughout the order lifecycle.

Product Master Data, Recipes and Manufacturing Structure

Product data is used by nearly every other ERP domain. Products can participate in customer orders, recipes, procurement, stock movements, production plans, quality rules and shipping calculations.

The application supports the distinction between finished goods, semi-finished products, raw materials, packaging components and other production-relevant item types instead of reducing everything to a generic SKU.

Product Recipes / BOM

Finished products can consume raw materials, semi-finished products, packaging materials or other manufactured components through recipe relationships.

Nested Requirements

Material requirement calculations can recursively expand semi-finished products, making downstream manufacturing requirements visible before production begins.

Sets & Assemblies

Set products and their underlying manufactured components are handled as connected production structures rather than flat order lines.

Packaging Dimensions

Product and delivery packaging data feeds weight, volume, packing list and shipment calculations.

Stock Tracking Modes

Different products can use standard quantity tracking or more detailed physical-unit models such as individually tracked raw-material rolls.

Quality Relationships

Product-specific quality rules can be associated with production processes and evaluated as part of manufacturing control.

Inventory, Reserved Stock and Material Availability

Inventory is not represented by one stock number. Different quantities have different operational meanings: usable stock, semi-finished stock, customer-reserved stock, standard sales allocations and special-order allocations must remain distinguishable.

This becomes particularly important when production and procurement are calculated against actual customer demand. A product may physically exist in the warehouse while already being reserved for another customer or production requirement.

Inventory Concern ERP Capability Operational Purpose
General stock Product-level inventory buckets Understand physically and operationally available quantities
Customer reservations Customer-specific stock allocations Prevent one customer's reserved production from appearing freely available
Critical stock Minimum usable-stock thresholds Identify materials requiring attention before production is blocked
Recipe demand Material requirement and stock-gap calculations Convert production demand into material requirements
Physical material units Individually tracked rolls and movement history Preserve physical traceability for weight-based raw materials
Auditability Stock movement records and reconciliation Explain why inventory changed rather than showing only the latest balance

Physical Roll Tracking for Weight-Based Raw Materials

Some manufacturing materials cannot be managed accurately with only a generic kilogram balance. Individual material rolls can have their own identity, remaining weight, supplier lot, dimensions, warehouse location and movement history.

For applicable raw and semi-finished materials, the ERP supports individually identified rolls. A roll number can be reserved during procurement, activated when the physical material arrives, consumed during production and adjusted through controlled usage, waste and reversal movements.

Unique Material Identity

Physical rolls can retain unique codes independent of aggregate product stock.

Actual Weight Tracking

Planned procurement weight and actual received or remaining weight remain distinguishable.

Production Consumption

Operators can associate physical material consumption and waste with production records.

Reversible Audit Trail

Corrections use controlled reversal movements instead of deleting historical stock evidence.

Production Planning and Shop-Floor Execution

Production is modeled from planning through execution rather than as a final quantity entry. Plans can be linked directly to customer orders or opened for general stock production.

The planning model understands production lines, manufacturing departments, machines, molds, nested production requirements and the relationship between finished goods and the semi-finished components required to manufacture them.

Production Lines

Hierarchical production lines and manufacturing departments model the actual structure of the factory floor.

Machines & Molds

Production can be associated with specific machines and molds, allowing planning to reflect physical manufacturing constraints.

Daily Planning

Daily production records retain planned quantities, completed quantities, transfers, progress, dates and operational status.

Work Orders

Workshop-style work orders provide an additional planning layer for operations that require capacity-oriented scheduling rather than only daily quantity planning.

Gantt Planning

Production workloads can be represented through timeline-oriented planning views for more complex workshop and machine schedules.

Production Transfers

Incomplete work can be transferred to future production plans without falsifying the quantity actually completed on the original day.

Operator Reporting, Production Time and Approval Workflow

Shop-floor production is not immediately treated as official inventory. Operators can report production activity, while completed quantities pass through a separate approval process before becoming authoritative production state.

Start

Record when production activity actually begins.

Stop

Capture interruptions, downtime reasons and operator notes.

Resume / Finish

Build a usable production-time history instead of relying only on plan dates.

Approval

Separate operator-reported output from officially approved production and stock movement.

Example Order-to-Production Flow

01

Customer Order

02

Order Recipe

03

Stock Gap

04

Produce / Procure

05

Quality Gate

06

Customer Stock

07

Shipment

Every stage can retain its own operational state while remaining connected to the original customer order. This allows teams to investigate the cause of a delay instead of seeing only a generic “order pending” status.

Procurement and Supplier Operations

Procurement is demand-aware. Purchase requests can originate from general operational needs or be tied directly to a customer order and its individual order line. This preserves the relationship between the commercial commitment and the material being purchased.

Purchase Request Management

  • Product and requested quantity
  • Requesting employee
  • Optional preferred supplier
  • Customer and order relationship
  • Open and purchased quantities
  • Return quantities
  • Request grouping through procurement carts

Supplier & Purchase Decisions

  • Supplier-specific price options
  • One-time negotiated purchase prices
  • Tax and discount calculations
  • Supplier payment terms
  • Minimum order considerations
  • Historical purchase context
  • Supplier performance and quality context

Partial Purchasing and Partial Arrivals

A purchase request does not need to be fulfilled by one supplier or one delivery. The same requirement can be purchased in parts, and each purchase can itself arrive through multiple delivery records.

Requested

Material requirement

Purchased

One or more supplier orders

Received

One or more warehouse arrivals

Quality Control and Non-Conformance Management

Quality control is modeled as an operational gate rather than a note field added after production. Quality rules can be assigned to products or production records and evaluated during manufacturing.

Quality Rules

  • Reusable quality rules
  • Product-level rule assignments
  • Production-specific quality requirements
  • Production quality checks
  • Quality-gate completion status

Non-Conformance

  • Non-conformance reports
  • Corrective or related actions
  • Production-linked quality evidence
  • Structured exception history
  • Traceability between production and quality outcomes

Shipment Planning, Warehouse Handoff and Logistics

Shipment planning is connected to actual customer-order lines. A shipment may contain lines from one or multiple orders and preserves quantities, package quantities, weight, volume, customer, product and fulfilment state.

Planning and warehouse execution are deliberately separated. The quantity planned for shipment is not automatically considered shipped; warehouse-reported and approved quantities determine the authoritative delivery state.

Multi-Order Shipments

One logistics plan can combine appropriate lines from multiple customer orders.

Warehouse Confirmation

Actual warehouse quantities remain separate from the quantities originally planned.

Weight & Volume

Packaging dimensions, quantities, net weight and gross weight support logistics calculations.

Loading Records

Loading and operational shipment-time information can be retained for logistics analysis.

Returns

Return shipments remain distinguishable and feed net shipment and reporting calculations.

Logistics Costs

Freight, driver, customs and other shipment costs can be tracked independently and reflected in reports.

Commercial, Warehouse and Export Document Generation

ERP data is also used to generate operational and customer-facing documents. Document rendering shares the same order and shipment calculation rules instead of independently reimplementing totals in each PDF template.

Proforma Invoice

Commercial Invoice

Packing List

Order Form

Export Form

Bill of Lading

PDF / XLSX

CSV Export

Heavy document generation can be queued instead of blocking the user's page request, while generated documents retain order and user context.

Finance, Currency Exposure and Margin Visibility

The financial reporting layer connects commercial value with operational events. It does not look only at the price written on the order: purchase costs, shipment costs, payments, currency movements and delivery dates can all affect the economic interpretation of an order.

Currency & Exposure

  • Order-time currency snapshots
  • Current and historical exchange-rate comparison
  • Delivery-date exchange-rate context
  • Currency-difference reporting
  • Revaluation runs
  • Inflation-aware operational analysis

Margin & Collection Context

  • Order revenue
  • Order-linked purchasing cost
  • Shipment additional costs
  • Estimated operational margin
  • Remaining receivables
  • Payment allocations

This allows management reporting to answer more useful questions than “what was the sales price?”—for example, what was purchased for the order, what logistics costs were incurred, how currency moved and what margin remains after those effects.

HR, Attendance, Shifts and Payroll

Workforce management is integrated as another operational domain. Employee profiles, shifts, attendance, overtime, field-work attendance, payroll calculations and payroll-accounting export records can be managed within the ERP.

Attendance

Attendance events can arrive from devices, integrations, imported files or controlled mobile workflows.

Shift Planning

Shift templates, employee assignments, weekly calendars, tolerances and manual overrides support factory scheduling.

Overtime Approval

Calculated overtime can remain operationally visible while only approved overtime is included in payroll calculations.

Mobile Field Attendance

Geofenced attendance workflows can validate employee position against configured facility or field-work rules.

Payroll Engine

Country-aware payroll rules, attendance summaries, variable earnings, advances and salary slips are processed through dedicated payroll logic.

Payroll Security

Payroll data uses stricter permission boundaries because salary and employee financial information require separate authorization.

Role-Based Permissions and Data Isolation

A factory ERP cannot expose every customer, payroll record, financial figure or production action to every employee. Authorization is therefore part of the domain architecture rather than an interface-only concern.

Company Scope

Operational records are restricted to the user's permitted organizational context.

Customer Scope

Selected employees can be limited to the customers and accounts they are authorized to manage.

Functional Permissions

Read, create, update, approval, download and sensitive-domain operations can have independent controls.

AI and Model Context Protocol as an ERP Interaction Layer

The application also explores a structured AI interaction model through Model Context Protocol (MCP). Instead of giving an AI model direct database access, ERP capabilities are exposed through explicit, permission-aware business tools.

This allows an authorized assistant to reason over ERP information while the application continues to enforce company scope, customer scope, quantity rules, recipes and business constraints.

Order 360° Analysis

Combine order lines, production, procurement, shipment, customer stock and operational risks into one contextual view.

Customer 360° Analysis

Bring open orders, reserved stock, production, procurement and recent shipments together for one customer.

Recipe Explosion

Recursively calculate the raw and semi-finished materials required to manufacture an order or product quantity.

Procurement Decision Support

Compare supplier options, purchase history, payment terms, currencies and purchasing rules.

Order Health Scoring

Evaluate due-date pressure, material shortages, missing plans, procurement gaps and pending production approvals.

Quality Gate Visibility

Read the active production-quality requirements and identify unresolved checks blocking production completion.

Supplier Scorecards

Analyze lead time, returns, pricing trends, quality and supplier-performance signals.

Margin Analysis

Combine order revenue, product cost and currency information into structured operational decision support.

The important design principle is that AI does not bypass ERP business rules. It works through controlled application services, the same way another trusted client or integration would interact with the ERP.

API-First Integration and Real-Time Infrastructure

A large ERP inevitably becomes an integration platform. Mobile applications, attendance systems, external services, AI clients, document workflows and operational dashboards all need controlled access to the same business state.

REST API & Authentication

  • Laravel Passport and Sanctum capabilities
  • Explicit API authentication boundaries
  • Mobile and integration endpoints
  • Idempotency requirements for critical mutations
  • Company and permission-aware requests
  • Swagger/OpenAPI tooling in the codebase

Queues & Real-Time Events

  • Laravel Horizon queue management
  • Redis-backed infrastructure capability
  • Laravel Reverb real-time communication
  • Laravel Echo client integration
  • Background document generation
  • Asynchronous operational processing

The same architecture principles are used in my API Integration Services : explicit contracts, controlled authorization, idempotency, background processing and reconciliation instead of fragile direct database coupling.

Architecture: One Operational Backbone, Multiple Domain Workflows

Demand

CRM & Orders

Customers, pricing, order lines, recipes and delivery commitments.

Planning

MRP & Production

Recipe requirements, production plans, work orders, machines and approvals.

Supply

Stock & Procurement

Availability, raw materials, suppliers, arrivals and inventory movement.

Execution

Quality & Logistics

Quality gates, customer stock, warehouse confirmation and shipment.

Intelligence

Finance, Reports & AI

Margin, exposure, KPIs, alerts, MCP and management decision support.

Designed for Transaction Integrity and Operational Traceability

ERP complexity is not primarily a UI problem. The difficult part is preserving business invariants when several workflows modify related state.

Production approval may alter finished-goods stock, customer-reserved stock, component quantities and physical material units. Procurement arrival may affect inventory and customer-linked demand. Shipment approval may affect delivered quantities, financial exposure and document calculations.

Database Transactions

Related state changes are grouped so partial operational updates do not survive a failed workflow.

Row Locking

Critical concurrent stock and production operations use locking where shared state must remain consistent.

Idempotency

External and AI-assisted mutation flows can require stable request identities to prevent duplicate operations.

Reversal Instead of Deletion

Sensitive stock and production corrections can preserve the original event and record a compensating movement.

Operational Reporting Across Departments

Because sales, inventory, production, procurement and logistics share the same operational model, reporting can cross departmental boundaries rather than reproducing isolated spreadsheets.

Stock Valuation

Analyze inventory value using operational stock and cost information.

Product Costs

Connect product cost information with recipes, purchasing and operational margins.

Raw-Material Needs

Translate planned or demanded production into material gaps requiring stock or procurement action.

Production Load

Compare planned and produced quantities across dates and production lines.

Shipment Performance

Analyze shipment quantities, customers, dates, returns, costs and delivery results.

Financial Exposure

Review receivables, purchasing cost, logistics cost, exchange-rate movement and estimated margin.

Technical Scope

The codebase reflects the scale of the business workflows it supports. The application combines traditional ERP screens with asynchronous jobs, real-time interfaces, document generation, integrations and AI-facing business tools.

PHP 8.5 + Laravel 12

Core domain logic, transactions, APIs, background processing and enterprise workflows.

Livewire 4

Data-intensive operational screens and reactive ERP interfaces.

TailwindCSS + Flowbite

Responsive user interfaces and reusable operational components.

Laravel Horizon + Redis

Queue-oriented processing for expensive and asynchronous workloads.

Laravel Reverb + Echo

Real-time application events and interactive operational communication.

Passport + Sanctum

Authentication foundations for APIs, mobile applications and integrations.

PDF / Excel / CSV Generation

Operational, financial, shipment and commercial document workflows.

QR & Barcode Workflows

Barcode generation and browser-side scanning capabilities for operational processes.

Frappe Gantt + Chart.js

Production planning timelines and data visualization.

Laravel MCP + Laravel AI

Permission-aware AI and structured ERP tool integration.

Google AI / Cloud Integrations

Infrastructure for AI, document, storage, translation and data-oriented integrations.

PWA & Mobile Integration

Support for operational mobile workflows and installable application experiences.

Why This Required a Custom ERP Instead of a Generic Template

The value of this project comes from modeling the factory's actual operational rules. Packaging quantities, customer-specific recipes, semi-finished products, physical roll tracking, machine and mold relationships, approval flows, customer-reserved stock and shipment calculations are tightly connected.

Trying to reproduce these workflows only through generic configuration would either force the business to change proven operational processes or create a large collection of disconnected workarounds around the ERP.

The custom approach allowed the software model to follow operational reality while still applying engineering discipline around permissions, transactional consistency, APIs, background jobs, auditability and long-term maintainability.

More Than an ERP Dashboard: A Manufacturing Operating System

This project represents one of the most comprehensive examples of my manufacturing software work. It combines CRM, ERP, MRP-style material planning, production execution, inventory control, procurement, logistics, quality, finance, HR, reporting and integration architecture in one continuously evolving codebase.

The most important part is not the number of modules. It is the relationship between them: customer demand can be traced into material requirements; material shortages into procurement; procurement and stock into production; production into customer inventory; customer inventory into shipment; and shipment back into financial and management reporting.

That end-to-end traceability is what turns separate business screens into an ERP.

Related Projects

Explore more projects showcasing CRM, ERP, and API integration work.

Working on a similar project?

Share the current workflow and systems involved to get a practical direction for scope, integrations and a useful first release.

Typical response within 24 hours · Clear scope & timeline · Documentation included