An open-source, modular Air Cargo Management System (CMS) for low-cost and small-scale airlines.
End-to-end cargo operations: agent bookings → e-AWB issuance → warehouse & ULD build-up → flight load control → import & delivery — with IATA-aligned messaging (C-IMP / SSIM / FWB / FHL / FSU / FFR / NOTOC), a full M/N/Q rating engine, and RBAC-driven admin.
Built as a community-driven, deployable alternative to commercial cargo systems for carriers that don't need a multi-million-dollar PSS.
| Operations Dashboard | Flight Movement Board |
|---|---|
![]() |
![]() |
| AWB · IATA Resolution 600a | Flights & Load Control |
![]() |
![]() |
| Live Tracking | Reports |
![]() |
| # | Module | Highlights |
|---|---|---|
| 1 | Booking & Reservation | Agent ad-hoc + template bookings, airline staff booking on behalf, live quotes, capacity & embargo checks, allotments, confirmation emails |
| 2 | AWB & Documentation | 11-digit AWB with IATA check digit (serial mod 7), full IATA Resolution 600a element set (boxes 1A–30: parties, accounts, agent IATA code, routing 11A–11F, currency, charges code, WT/VAL, other charges 15–18, declared values NVD/NVV, OCI, execution/signatures), AWB stock control, e-AWB (FWB) emission, CCA (correction advice), House AWB / FHL consolidation, IATA 600a tab + print |
| 3 | Terminal Ops (Export) | FOH → RCS acceptance flow, ULD build-up with compatibility & gross-weight limits, load planning, DGR acceptance validation |
| 4 | Flight & Load Control | SSIM ingestion (SSM/ASM), flight materialization, cargo manifest, NOTOC generator for DGR, weight & balance summary |
| 5 | Import & Delivery | Arrival flow (ARR/RCF/NFD), delivery orders (partial release supported), discrepancy handling (MISSING/FOUND/DAMAGE/OVER/SHORT/OFFLOAD), claims |
| 6 | Pricing & Revenue | Rating engine: M (minimum), N (normal), Q weight breaks (+45…+1000) with rating-up logic, contract rates per agent, valuation charge (0.50/100 USD), CASS-style charge fields |
| 7 | Admin & Master Data | Participants (agents/GHA/interline) with CASS flags & credit limits, users with RBAC, embargo management, email templates |
| 8 | Messaging & Integration | C-IMP message switchboard (FSU/FWB/FHL/FFR/FMA), SSIM inbound processing, message log, email outbox (SMTP hook ready) |
- Light / Dark / Match-system appearance toggle in the header (persisted per browser, boot script prevents white-flash on reload).
- 5 accent themes — Ink Navy (default), Cargo Emerald, Royal Blue, Kashmiri Wine, Night Violet — swap the brand surfaces without touching layout.
- 3 time-display modes for every timestamp in the system:
BASE— the sign-in station's local time everywhere,LOCAL— each event in its own station's time (origin at origin, destination at destination, IANA-zone + DST correct),UTC— Zulu, the C-IMP/SSIM wire convention.
- The Flight Movement board re-renders its date/hour grid in the active mode; leg details show STD at origin and STA at destination in LOCAL mode.
bun run db:seed:fleet # expand the demo dataset (see below) — safe to re-runGenerates the full-scale demo dataset in ~20 s: 32 airports (PK domestic + GCC + Asia + Europe + Africa, each with its IANA timezone), 21 aircraft types (A319 → A380, 737 → 747-8F — belly, freighters, one combi), 500 aircraft (AircraftProfile tails AP-C**), 168 schedule directions → 76,000+ materialised flights covering 01-Jan-2026 → 31-Dec-2027, and 650 AWBs — exactly 50 per month × 13 months covering every state: booked (BKD), full AWB flow, house AWBs (FHL), FOH, pre-manifest (RCS), manifest (MAN), departed (DEP), arrived (ARR/RCF/NFD), delivered with warehouse charges + DO + POD, full & partial offloads (part re-manifested on the next departure), discrepancy cases (SHORT/DAMAGE/OVER/MISMATCH) and transit cargo on 2-leg routings — visible on the Flight Movement board → Connections block (next flight out of the landing station, layover hours).
Importable SSIM reference material lives in docs/ssim-samples/: an SSIM "LOCAL FOR CARGO" sample (rotation/leg records, validated against the parser), a simplified SSM sample, the fleet payload plate and ICHM-mapped handling notes — illustrative demo data, built from public IATA formats (SSIM Appendix A/C, C-IMP, AHM), not from any operator timetable.
src/lib/cargo/
├── rating-engine.ts M/N/Q rating + RATING-UP + volumetric weight (6000 cm³ = 1 kg) + valuation charge
├── awb.ts AWB numbering: prefix + serial + check digit (serial mod 7), validation
├── awb-600a.ts IATA Resolution 600a element catalog, validate600a(), FWB 600a builder, house manifest
├── print-docs.ts Print-ready HTML for 13 documents (AWB 600a form, manifest, NOTOC, CCA, DO, labels, stock, invoice, CASS, ICH, filing receipt, reports)
├── state-machine.ts Shipment lifecycle: BKD → FOH → RCS → MAN → DEP → ARR → RCF → NFD → DLV (+ OFLD recovery)
├── ssim-parser.ts SSM/ASM (Type 2) parser + schedule expansion by day-of-operation into concrete flights
├── notoc.ts NOTOC (Notification to Captain) generator + DGR validation + class segregation matrix
├── cimp.ts C-IMP builders: FSU, FWB, FHL, FFR, FMA + inbound type detection
├── manifest.ts Cargo manifest builder (AWB rows, ULD positions, totals)
└── constants.ts RBAC matrix, weight & balance checks, reference generators
| Document | Where |
|---|---|
| IATA AWB Form (Res 600a, numbered boxes 1A–30) | AWB detail → printer icon → IATA AWB Form |
| House Manifest (ONE Record structure) | AWB detail → print menu |
| Piece Labels (per-piece, DGR/SHC marks) | AWB detail → print menu |
| CCA advice | AWB detail → print menu |
| Cargo Manifest + NOTOC | Flight detail → print menu |
| Delivery Order | Terminal Ops → DO row printer |
| AWB Stock Control report | AWB Stock → header printer |
| Non-CASS Invoice / CASS file / ICH statement | Billing rows + ICH tab |
| PLACI filing receipt | Compliance detail → printer |
| All 14 reports | Reports → Print report |
Every print is recorded in PrintLog + AuditLog (who, what, which station). Engine: hidden iframe + window.print() — no extra routes, no server round-trips for the render.
Run the test suites (344 tests):
bash tests/run.sh unit # 193 tests — all engines (rating, AWB, state machine, SSIM, NOTOC, C-IMP, RBAC)
bash tests/run.sh integration # 67 tests — real API routes against an isolated test DB
bash tests/run.sh security # 84 pentest regression tests (see docs/PENTEST-REPORT.md)
bash tests/run.sh all # everythingSecurity & load documentation: docs/PENTEST-REPORT.md (20 findings, all fixed), docs/LOAD-TEST-REPORT.md (1000-user simulation — 303 req/s sustained, 0 timeouts).
One command (recommended):
sh scripts/setup.sh # deps + .env (fresh AUTH_SECRET) + schema + demo seed
bun run dev # http://localhost:3000Manual steps:
# 1. install
bun install
# 2. environment — copy the template, then adjust (all vars optional in dev)
cp .env.example .env
# 3. database (SQLite dev file) — schema push
bun run db:push
# 4. realistic demo dataset (airports, fleet, agents, tariff, flights, AWBs, ULDs, messages)
bun run db:seed
# 4b. (optional) the 500-aircraft network: 76k flights to Dec-2027, 650 AWBs,
# house AWBs, offloads, discrepancies, transit connections
bun run db:seed:fleet
# 5. run
bun run dev # http://localhost:3000 — serves the PRODUCTION build
# when one exists (fast preview: minified, gzip,
# service worker); falls back to next dev otherwise.
bun run dev:real # force the real dev server (HMR, unminified)
bun run build && bun run start # explicit production run
# tests + lint
bash tests/run.sh all
bun run lintPerformance profile (why it loads like a local server): route-level
code splitting (every module is its own chunk, prefetched on sidebar
hover/focus), lazy chart + help-corpus chunks, self-hosted subset fonts,
Brotli-grade gzip on every text response, immutable cache headers, and a
service worker (public/sw.js) that serves static assets cache-first,
navigations stale-while-revalidate, and API GETs stale-while-revalidate
with a 15s freshness window — repeat loads paint in ~150 ms with zero
network, and slow-3G first loads drop from ~2 min (dev server) to a few
seconds. Scrolling stays smooth via content-visibility on table rows
and card lists. UI is pixel-identical; all of it is pure wire/render work.
Sign-in page — /login ships a real credential login (scrypt-hashed passwords, HMAC-signed 12h session tokens, RBAC-gated screens). First-run logins (change after first sign-in):
| Login | Password | Role / portal |
|---|---|---|
admin |
admin |
ADMIN · Airline Operations Console (everything) |
gha |
gha |
GHA · ground-handling scope |
agent |
agent |
AGENT · Agent Portal (own participant only) |
ops.lhe, agent.alnoor, gha.lhe |
demo123 |
seeded demo staff identities |
Hardening included: failed attempts lock the account in the database (ADMIN: 3 strikes → 15 min, staff: 8 → 10 min — rotating IPs does not reset the counters, and restarts don't either), user-enumeration timing is equalized with a decoy scrypt verify, and every login/lock/credential change is audit-logged (LOGIN.OK, LOGIN.LOCKED, PASSWORD.SELF_CHANGE…).
Password policy — Admin → Password Policy (ADMIN only, PUT /api/auth/policy, audit-logged). Shipped defaults: 8–16 characters, letter + digit required, 90-day expiry (per-account "No Pwd Expiration" overrides), lockout thresholds above. Passwords are never stored in plaintext — only scrypt$salt$hash rows exist.
Real deployments should create their own users, change the seeded passwords on first sign-in, and rotate AUTH_SECRET in .env.
Any successful write anywhere — this tab, another module or another browser tab — invalidates the
service-worker API cache and bumps the app's refresh token, so every mounted screen refetches from the
network. Layers: client-api.ts publishes after each non-GET → public/sw.js (v3) purges its API cache
the instant a write passes through → a skycargo-sync BroadcastChannel notifies every open tab.
Ephemeral endpoints (presence / locks / history / prefs) are excluded to avoid refresh storms.
Paste the scheduling department's SSIM (SSM/ASM) message into Flights → Import SSIM (or POST /api/flights/import-ssim). Schedules are created/updated and concrete flights are materialized for the next 14 days; ASM CNL cancels them.
Sample SSM accepted:
SSM
1SSIM
2SSM F 01DEC2631DEC26 1234567 SQX101 LHEJED B738 Y 0830 1130
/FREIGHTER PRIORITY
OpenAPI 3.0 spec: docs/openapi.yaml · Service info: GET /api · Liveness probe: GET /api/health (503 when the database is unreachable — safe for K8s/ALB health checks)
Core endpoints:
POST /api/rates/quote live quote (M/N/Q + contract rates + rating-up)
POST /api/bookings create (embargo + capacity checks, live quote)
POST /api/bookings/{id}/confirm|cancel
POST /api/awb issue AWB (stock serial, rating audit, FWB out)
GET /api/awb/{number} detail: events, houses, ULDs, charges
POST /api/awb/{number}/status FSU status (state-machine validated)
POST /api/awb/{number}/cca CCA correction advice
POST /api/house-awbs consolidation + FHL emission
POST /api/flights/import-ssim SSM/ASM ingestion
GET /api/flights/{id}/manifest?persist=1 cargo manifest (text + structured)
POST /api/flights/{id}/notoc NOTOC from manifested DGR shipments
GET/POST /api/flights/{id}/loadplan ULD assignment + weight & balance
GET/POST/PATCH /api/ulds ULD fleet
GET/POST /api/rates tariff maintenance
GET/POST/PATCH /api/messages C-IMP switchboard (inbound routing)
GET/POST/PATCH /api/discrepancies ops exceptions
GET/POST /api/delivery-orders (+/{id}/release) delivery & DLV
GET/POST /api/participants | /api/users admin + RBAC
GET/POST /api/embargoes | /api/allotments capacity control
GET /api/health liveness probe (SELECT 1 round-trip, 503 on DB failure)
GET /api/dashboard KPIs (tonnage, revenue, load factor, status mix)
54 entities — full textual ERD: docs/ERD.md
Key entities: Participant, User, Schedule, Flight, Booking, Awb (+ AwbStock, HouseAwb), Uld (+ UldAssignment), Rate (+ ContractRate), ShipmentEvent, MessageLog, Discrepancy, DeliveryOrder, Claim, Notoc, Manifest, Embargo, Allotment, NotificationTemplate, EmailNotification.
Dev sandbox ships SQLite (prisma/schema.prisma, provider sqlite). For production switch one line to PostgreSQL and run prisma migrate deploy:
datasource db {
provider = "postgresql" // was "sqlite"
url = env("DATABASE_URL")
}Prefer bootstrapping the schema without Prisma (ops-managed databases, migration governance, air-gapped installs)? Both dialects ship ready to execute:
| File | Dialect | Contents |
|---|---|---|
sql/schema.sqlite.sql |
SQLite | 54 CREATE TABLE + 108 indexes + FK constraints — byte-for-byte what prisma db push builds |
sql/schema.postgres.sql |
PostgreSQL | same structures, PG types (TIMESTAMPTZ(3), DOUBLE PRECISION) |
# SQLite (validated by executing the script in a scratch database)
sqlite3 aircargo.db < sql/schema.sqlite.sql
# PostgreSQL
createdb aircargo && psql -d aircargo -f sql/schema.postgres.sqlNotes:
- Audit trail is application-level (
AuditLogtable written by theauthorize()chokepoint with before/after JSON). No DB triggers by design — triggers would double-log every mutation the app already audits. - Demo/master data lives in
prisma/seed.ts(scrypt password hashing + reference generation is code, not SQL) — after the DDL, runbun run db:seedonce against the sameDATABASE_URL.
docker compose up --build # app :3000 · SQLite · demo data auto-seeded on first bootDockerfile— multi-stage (bun build → node:22-slim runtime), prisma CLI baked in so the idempotentdb pushat boot never needs the network, schema sync → seed-if-empty →server.jsdocker-compose.yml— app + persistent volumeappdata:/app/db; PostgreSQL available via the optional profile:docker compose --profile postgres up --build(then switch the Prisma datasource provider topostgresqland set itsDATABASE_URL)- Set
AUTH_SECRETin.env(or the environment) before real logins — generate withopenssl rand -base64 48
Deploy anywhere in ~5 minutes (noob-proof): install Docker → clone this repo →
docker compose up --build → open http://<server-ip>:3000. That is the whole checklist;
schema, seed and healthchecks are handled at boot. For a VPS without Docker, sh scripts/setup.sh
then bun run build && bun run start (keep the process alive with pm2 or a systemd unit).
The demo UI has a role switcher (ADMIN / AIRLINE_STAFF / GHA / AGENT / MANAGEMENT). APIs read the caller's role from the x-user-role header (demo mode) and enforce the permission matrix in src/lib/cargo/constants.ts:
ADMIN— full controlAIRLINE_STAFF— all operationsGHA— warehouse: statuses, ULD, delivery, discrepanciesAGENT— own bookings, read flights/rates, request AWBMANAGEMENT— read-only + reports
Separate interfaces per audience (src/app/page.tsx portal split): the same build renders an
Airline Operations Console (ops roles), a violet-branded Agent Portal (agents land on
Booking; only their own tenant data server-side) and a public Tracking portal for guests.
Which areas are visible is driven by user rights — every module declares the permission it needs
(MODULE_ACCESS) and the sidebar simply hides what the role cannot open, while each API
re-checks the same permission server-side (defense in depth).
Production: replace getRole() in src/lib/api.ts with a NextAuth (or OAuth2/JWT) session lookup — every route already calls a single authorize() chokepoint, so the swap is one function.
.envis gitignored and untracked — runtime secrets never enter the repository (.env.exampleis the committed template)AUTH_SECRETsigns HMAC session tokens; required in production, ≥ 32 chars, and signing fails closed if it is short or missing (src/lib/auth.ts) — the in-source default was removed in the pentest round precisely because public OSS code is public knowledge- Passwords: scrypt with a per-user 16-byte random salt (
scrypt$salt$hash), verification is timing-safe - Demo headers (
x-user-role) are honoured only whenDEMO_AUTH=1; without it every caller without a valid Bearer token is GUEST - No secrets are exposed to the browser bundle: no
NEXT_PUBLIC_*secrets exist, and business logic (rating/TACT engine, pricing, RBAC) runs server-side — the client only renders server-produced values
On top of the role matrix, a full duty-code layer mirrors Champ Cargospot's user-rights model (844-code catalog imported from a real Cargospot deployment):
- Prefix semantics:
_FULL_AWBscreen duty ·.BOOKINGgroup duty (expands to members) ·*CLIENT_deployment-specific · trailing-_codes grantable only with SUPER_ authority - Permit levels 0–9 per assignment; a
DUTY_CODE_CTRLholder of permit N grants N and below (Admin-Guide ladder) - Admin → Duty Codes screen: catalog search/create, per-user grant/revoke with the expanded effective set
- Enforcement:
requireDuty(caller, code, permit)insrc/lib/cargo/duty.ts— roles stay coarse, duties refine sensitive actions
- Presence strip on every page: who else is on the screen, live "X is editing AWB 555-…" lock badges, and an activity feed of that page's recent changes (verified under 1000-user load: both concurrent editors always see each other and the lock holder)
- Customize menu on every page (Cargospot UI conventions): column visibility, screen density, default query values, default values for new records, delete-confirmation switch, sidebar Quick Links — persisted per (user, page), server-sanitized (
src/lib/cargo/prefs.ts)
SSIM (SSM/ASM) ──▶ Inbound switchboard ──▶ Schedule/Flight tables
SITA Type-B ──▶ POST /api/messages ──▶ detect FSU/FWB/FHL/FFR ──▶ route
Booking flow ──▶ OUT: FWB (e-AWB) ──▶ MessageLog (SITA/email gateway hook)
Ops console ──▶ OUT: FSU per status ──▶ MessageLog
Destination ──▶ OUT: FHL / FFR (CASS billing data) ──▶ MessageLog
Templates ──▶ EmailNotification outbox ──▶ (SMTP worker in production)
The C-IMP encoding here is a simplified, community-friendly subset that keeps the line structure (header / addressing / detail) so teams can adapt it to a real SITA Type-B gateway with light work. ONE Record (v2.0.0) and Cargo-XML adapters are the natural next contributions (see roadmap).
- IATA ONE Record (v2.0.0) REST adapter + Cargo-XML codecs
- Real SMTP/SITA gateway workers for the outboxes
- Customs declaration hooks (per-region, e.g. AES for EU, ACE for US)
- Interline prorate & bilateral agreements, full revenue accounting posting
- Crew duty rostering (per-diem payroll module)
- Barcode/RFD scanning endpoints for warehouse handhelds
- Multi-tenant mode (one deployment, many airlines)
MIT — free for community use. IATA standards references (AWB, C-IMP, SSIM, DGR, TACT) remain the property of IATA; this project implements the logic in good faith for interoperability and education.






