Backend Overview#

The backend is a Django REST Framework application that manages everything about parts, suppliers, pricing, purchase orders, and approval workflows.

Think of it as the brain of the BOM (Bill of Materials) system — it stores all the data, enforces business rules, and serves the frontend through a REST API.

Tech Stack#

Tool

What it does

Django 5.2

The web framework — handles requests, database, and business logic

Django REST Framework

Makes building APIs easy — serializers, views, authentication

PostgreSQL

The database — stores all parts, prices, orders, etc.

Redis

Fast in-memory cache — speeds up frequently accessed data

Simple History

Automatically tracks every change to every record (audit trail)

Simple JWT

Token-based authentication — no sessions, stateless

How the Code is Organized#

The backend is split into Django apps, each responsible for one domain:

backend/
├── part/           → Parts, Products, Commodities, BOM, PartSupplier
├── supplier/       → Suppliers and their portal users
├── value/          → Pricing, weights, and formula calculations
├── master_data/    → Categories, ValueHeads (shared lookup tables)
├── view_template/  → Custom display layouts for pricing data
├── purchase_order/ → Purchase Orders, line items, negotiations
├── approval/       → Approval workflows (who can approve what)
├── utility/        → Custom User model, base classes, helpers
├── download/       → Export/download job tracking
└── webapis/        → All API endpoints (serializers + URL routing)

The Big Picture#

Here’s how the main pieces connect:

Supplier ──── PartSupplier ──── Part
                  │                │
                  │                ├── type: "part" (raw materials)
                  │                ├── type: "product" (finished goods)
                  │                └── type: "commodity" (general materials)
                  ├── Value (prices, weights, formulas)
                  ├── ViewTemplate (how to display the values)
                  └── PurchaseOrder → OrderItem → Negotiation

In plain English:

  • A Part is something you manufacture or buy (a screw, a motor, a fan blade)

  • A Supplier is a company that sells parts to you

  • A PartSupplier is the relationship between the two — “Supplier X sells Part Y”

  • Values are the actual numbers — prices, weights, costs — attached to each PartSupplier

  • Purchase Orders are what you send to suppliers to buy stuff

Base Model Pattern#

Every model in the system inherits from a common base that gives it:

  • id — Auto-incrementing primary key

  • sqid — A short, human-readable ID (like Dk3mV9) generated from the id

  • active — Boolean flag to soft-delete without losing data

  • created_at / updated_at — Automatic timestamps

  • history — Full audit trail (who changed what, when)

This means you can always trace back any change to any record.

What’s Next#