4b6138f049c6ac92bc98ae453d9153c34f53ad42
Four related backend features. They are committed together because they interleave in api/views.py and api/serializers.py - one hunk holds the combinations ViewSet, the licensing helpers and LicenseView - and splitting by hunk would produce commits that do not import. ExtraCombination records previously-used combinations of lookup nomenclature values so an operator can refill the Additional Data fields in one click. Deduplicated by a canonical order-independent hash, since JSONField equality compares serialized text on SQLite and so depends on key order. Weighing replaces set_tare/set_gross with a single measure action that assigns by weight - lighter becomes tare, heavier gross - because trucks arrive both loaded and empty. A second, lighter reading moves the first to gross carrying its own timestamp, user and manual fields, so provenance follows the value rather than the slot. Manual entries record who, when and why, gated on the previously unenforced can_measure and can_manually_measure flags. ScaleProtocol stores how to read each indicator, so a new scale type is a configuration change rather than a new binary on every station PC. Licensing is offline and node-locked: the server verifies an Ed25519 signature against a fingerprint of four hardware components, tolerating one change, and counts concurrently connected stations. Sites are air-gapped, so there is no activation server. A 14-day grace period keeps an unlicensed or newly-invalid install working, because a licence check must never stop a weighbridge without warning. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ScalesApp - Multi-Component Application
A distributed application consisting of three main components:
Architecture
1. Frontend (React)
- Location:
/frontend - Description: React web application that displays real-time data from the serial port
- Communicates with: Django backend via REST API
- Port: 3000 (default)
2. Backend (Django)
- Location:
/backend - Description: Django REST API server for storing and retrieving serial data
- Database: SQLite (configurable)
- Port: 8000 (default)
3. Serial Bridge (Python)
- Location:
/serial_bridge - Description: Python application that reads data from COM ports
- Features: System tray integration, runs as EXE (via PyInstaller)
- Communicates with: Django backend via REST API
- Data Flow: COM Port → Serial Bridge → Django Backend → React Frontend
Installation & Setup
Prerequisites
- Node.js 16+ (for React)
- Python 3.8+ (for Django and Serial Bridge)
- pip or conda for Python packages
Quick Start
-
Backend Setup
cd backend python -m venv venv venv\Scripts\activate pip install -r requirements.txt python manage.py migrate python manage.py runserver -
Frontend Setup
cd frontend npm install npm start -
Serial Bridge Setup
cd serial_bridge python -m venv venv venv\Scripts\activate pip install -r requirements.txt python app.py
Data Flow
COM Port
↓
Serial Bridge (Python)
↓
Django Backend REST API
↓
React Frontend
Configuration
Each component has its own configuration file:
- Frontend:
.env - Backend:
settings.pyand.env - Serial Bridge:
config.pyand.env
Development Tips
- Keep all three services running during development
- Use
CORSheaders properly in Django for frontend requests - Serial Bridge should continuously read COM data and POST to backend
- Frontend should poll/subscribe to backend for updates
Description
VehicleScales app with Django and React. It has a python service reading from comport and forwarding data to frontend via sse
Languages
JavaScript
62.1%
Python
23.8%
CSS
13.8%
Dockerfile
0.1%