How franstio/timbangan-step-2-api works
This is a Node/Express service for a waste-handling installation: operators scan badges and containers, record or update waste transactions, and monitor bin weights. The runtime also reads two serial scales, serves live bin-weight updates, and synchronizes employees, bins, containers, and pending transactions with external systems. The graph follows the sampled route, controller, and startup wiring; several synchronization implementations are only partially shown, so uncertain internal calls are omitted.
Main entry points: Employee.js Transaction workflows · Bin.js Bin operations · index.js HTTP and job runtime · APIRoute.js API routes
Components 22
Operator API
- HTTP and job runtime
index.js - Scanner routes
routes/ScannerRoute.js - API routes
routes/APIRoute.js
Weight Monitoring
- Bin operations
controllers/Bin.js - Scale readers
controllers/Scales.js
Waste Records
- Transaction workflows
controllers/Employee.js - Bin records
models/BinModel.js - Container records
models/ContainerModel.js - Waste types
models/WasteModel.js - Employee records
models/EmployeeModel.js - Transaction records
models/TransactionModel.js - Database connection
config/db.js
Synchronization
- Background queues
index.js
Other components
- Operator / client
- Serial scales
- Bin clients
- MySQL database
- PIDSG service
- Step 1 service
- Step 3 service
- Rack API
- Redis password store
Connections 32
- Operator / client → Scanner routes: sends requests
- Operator / client → API routes: sends requests
- HTTP and job runtime → Scanner routes: mounts routes
- HTTP and job runtime → API routes: mounts routes
- Scanner routes → Transaction workflows: dispatches handlers
- Scanner routes → Bin operations: dispatches handlers
- API routes → Transaction workflows: dispatches handlers
- API routes → Bin operations: dispatches handlers
- API routes → Scale readers: dispatches reset
- HTTP and job runtime → Database connection: authenticates
- Database connection → MySQL database: connects
- Transaction workflows → Employee records: queries
- Transaction workflows → Container records: queries
- Transaction workflows → Bin records: queries
- Transaction workflows → Transaction records: records transactions
- Bin operations → Bin records: reads bin state
- HTTP and job runtime → Scale readers: starts readers
- Scale readers → Serial scales: reads serial data
- Scale readers → Background queues: requeues reads
- HTTP and job runtime → Background queues: schedules jobs
- Background queues → Transaction workflows: runs sync jobs
- Background queues → Scale readers: runs scale jobs
- Background queues → Bin operations: runs weight updates
- Background queues → Rack API: posts sync payloads
- Transaction workflows → PIDSG service: syncs records
- Transaction workflows → Step 1 service: fetches and updates logs
- Transaction workflows → Step 3 service: updates values
- Transaction workflows → Bin operations: updates bin weights
- Bin clients → HTTP and job runtime: opens socket
- HTTP and job runtime → Bin operations: registers weight listener
- Bin operations → Bin clients: emits weight updates
- Bin operations → Redis password store: reads and writes password