Saudi Vision 2030 · National Transport & Logistics Strategy
Port Community System
Enterprise digital transformation for King Abdulaziz Port, Dammam.
Single API connecting shipping lines, freight forwarders, ZATCA customs,
and port authority in real time.
Before PCS, a single vessel arrival triggered 12+ manual data exchanges between stakeholders. Average cargo dwell time: 5.2 days. Saudi Vision 2030 targets 24 hours.
The Problem
Before PCS: Shipping lines faxed manifests. Customs officers re-typed data. Freight forwarders called the terminal by phone to check container status. Each stakeholder maintained separate bilateral data feeds — 12+ integrations per shipping line.
Average dwell time (before)5.2 days
Target dwell time (Vision 2030)24 hours
The Solution
With PCS: One authenticated API. Real-time vessel arrivals via AIS. Automatic customs declarations via ZATCA Fasah. Container status from discharge to gate-out. All stakeholders see the same data, simultaneously.
ZATCA Fasah Single Window — 100% electronic customs declarations
AIS feed updated every 15 minutes — real vessel ETAs
ISO 6346 container tracking from discharge to delivery
Saudi PDPL compliant — data residency in me-south-1 (Bahrain)
System Design
Architecture & Data Flows
Event-driven microservices on AWS EKS with Kafka as the backbone, RDS PostgreSQL for persistence, and ElastiCache Redis for session and rate management.
System Layers
🚢Shipping Lines
·
📦Freight Forwarders
·
🛃Customs Officers
·
⚓Port Authority
·
🚛Trucking Cos.
HTTPS · JWT · API Key
🌐AWS ALBSSL · WAF · HTTP→HTTPS
→
☸️EKS — pcs-api (FastAPI)HPA: 3–10 pods · Rolling update maxUnavailable=0
🐘RDS PostgreSQL 16Multi-AZ · pcs_core · pcs_audit
·
⚡ElastiCache RedisSessions · Cache · Rate limits
·
📡Amazon MSK Kafka6 topics · SASL/SCRAM · KMS
📶AIS Feed15 min · MarineTraffic
·
🛂ZATCA FasahOAuth2 · Webhooks · SADAN
·
📊Prometheus · Grafana12 alerts · 10 metrics
🚢
Vessel Pre-Arrival Flow
Agent submits ETA → PCS validates 72h lead time → Kafka vessel.arrivals event → Berth planner notified → AIS feed begins tracking → VTS records ATA → Status: AT_ANCHORAGE
Ten integrated modules covering the complete port community workflow from vessel pre-arrival to container delivery.
Vessel Call Management
Full lifecycle tracking: pre-arrival notification (72h MAWANI requirement), AIS position updates, berth assignment, status transitions with audit trail. Enforced state machine: EXPECTED → AT_ANCHORAGE → BERTHED → DEPARTED.
IMO · AIS · MAWANI
Cargo Manifest Submission
EDIFACT CUSCAR to JSON bridge. ISO 6346 container validation. Dangerous goods (IMDG class + UN number), reefer (temperature setpoint), out-of-gauge cargo. HS code 6–10 digit validation per Saudi ZATCA requirements.
EDIFACT · ISO 6346 · HS Codes
ZATCA Customs Integration
Direct OAuth2 integration with ZATCA Fasah Single Window. Automatic declaration submission, HMAC-verified webhook callbacks, Redis-cached access tokens, idempotent submission guard. Saudi Customs law compliant.
Fasah · OAuth2 · HMAC-SHA256
AIS Vessel Tracking
MarineTraffic / Spire AIS feed polling every 15 minutes. Vessel position, heading, speed, and ETA updates. Deviation alerting when AIS feed is stale for more than 20 minutes (VesselETAUpdateLag Prometheus alert).
AIS · IMO · MarineTraffic
Container Lifecycle Tracking
End-to-end status from MANIFESTED through DISCHARGED, YARD_IN, CUSTOMS_CLEARED, AVAILABLE_FOR_PICKUP, GATE_OUT to DELIVERED. Real-time webhook notifications. ISO 6346 check digit validated at middleware layer.
ISO 6346 · Webhooks · Redis Cache
Zero-Trust Security
JWT (60min) + API key auth. slowapi rate limiting (5/min login, 20/min customs). SQL injection middleware. Immutable audit log (PostgreSQL trigger + INSERT-only role). HSTS, CSP, X-Frame-Options on every response.
OWASP · PDPL · Audit
Prometheus Monitoring
10 custom port-domain metrics: vessel calls, customs backlog, AIS freshness, DB pool utilisation. 12 alert rules with port-operations context. 11-panel Grafana dashboard. CloudWatch Logs Insights compatible JSON logging.
Prometheus · Grafana · CloudWatch
Event-Driven Architecture
6 Kafka topics with MAWANI/ZATCA compliance-driven retention (14 days for cargo manifests, 30 days for customs declarations). SASL/SCRAM-512 encryption. Customer-managed KMS key. Consumer lag alerting at 1,000 messages.
Kafka MSK · SASL · KMS
Kubernetes-Native Deployment
EKS with HPA (CPU 70% / Memory 80%), pod anti-affinity across 3 nodes, zero-downtime rolling updates (maxUnavailable=0), ALB Ingress with SSL redirect. Secrets from AWS Secrets Manager. 30-day auto-rotation Lambda.
EKS · HPA · Secrets Manager
Infrastructure as Code
Complete Terraform for VPC, RDS Multi-AZ, ElastiCache, MSK, EKS in me-south-1 (Bahrain) for Saudi PDPL compliance. S3 remote state + DynamoDB locking. 5-stage CI/CD pipeline with ECR vulnerability scanning.
Terraform · AWS · GitHub Actions
Technology Stack
Enterprise-Grade Components
Every technology chosen for production reliability in a 24/7 port operations environment.
🐍
Python 3.12
3.12 LTS
Async-first runtime. asyncio + asyncpg for non-blocking I/O across all DB, Redis, and Kafka calls.
⚡
FastAPI 0.115
0.115
Pydantic v2 schema validation on every request/response. Auto-generated OpenAPI. Async route handlers throughout.
⚛️
React 18
18 + TypeScript
Stakeholder portals: shipping agent dashboard, customs queue, container tracker. React Query for server state.
🐘
PostgreSQL 16
16 on RDS Multi-AZ
ACID transactions for vessel calls and manifests. Separate pcs_audit database with immutability trigger + INSERT-only role.
🔴
Redis 7
7 on ElastiCache
JWT blacklist, API key lookup, rate limit counters, AIS position cache, ZATCA OAuth2 token cache.
🟨
Apache Kafka 3.6
3.6 on Amazon MSK
6 compliance-driven topics. SASL/SCRAM-512. Customer KMS. auto.create.topics.enable=false in production.
☸️
Kubernetes (EKS)
EKS me-south-1
3-node cluster, HPA, ALB Ingress, pod anti-affinity. Zero-downtime rolling updates. Helm for monitoring stack.
🟣
Terraform 1.7
1.7 + S3 state
4 modules: vpc → rds → redis → kafka. S3 remote state + DynamoDB lock. Bahrain region for PDPL compliance.
📊
Prometheus + Grafana
kube-prometheus-stack
15s scrape interval, 30-day retention, 12 alert rules, 11-panel dashboard with Saudi port domain context.
Developer Experience
Up and Running in 5 Commands
The full stack — PostgreSQL, Redis, Kafka, and FastAPI — runs locally via Docker Compose. Saudi port seed data included.
Clone & Configure
Copy the two environment files and fill in values (defaults work for local development).
Start All Services
Docker Compose starts PostgreSQL 16, Redis 7, Zookeeper, Kafka, Kafka UI, and FastAPI — all with health checks.