Skip to content

Architecture ​

Overview ​

The Smart City TVMS API is built on Cloudflare's edge infrastructure, providing global low-latency access.

┌─────────────────────────────────────────────────────────────────┐
│                        Cloudflare Edge                          │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌──────────────────┐    ┌──────────────────┐                  │
│  │   Web Frontend   │    │   API Worker     │                  │
│  │   (Pages)        │───▶│   (Workers)      │                  │
│  │ itms.solutions   │    │ api.itms.solutions│                 │
│  └──────────────────┘    └────────┬─────────┘                  │
│                                   │                             │
│          ┌────────────────────────┼────────────────────┐       │
│          │                        │                    │        │
│          ▼                        ▼                    ▼        │
│  ┌──────────────────┐    ┌──────────────────┐  ┌─────────────┐ │
│  │   D1 Database    │    │   R2 Storage     │  │    KV       │ │
│  │   (SQLite)       │    │   (Object Store) │  │   (Cache)   │ │
│  └──────────────────┘    └──────────────────┘  └─────────────┘ │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Technology Stack ​

Backend (API Worker) ​

ComponentTechnology
RuntimeCloudflare Workers
FrameworkHono
API LayertRPC
DatabaseCloudflare D1 (SQLite)
StorageCloudflare R2
AuthJWT (Web Crypto API)
Passwordbcryptjs

Frontend (Web App) ​

ComponentTechnology
HostingCloudflare Pages
FrameworkNext.js 14
UIChakra UI
API ClienttRPC Client
StateReact Query

API Structure ​

api.itms.solutions/trpc/
├── auth.*           # Authentication endpoints
├── sensors.*        # Sensor management
├── reports.*        # Analytics & reports
├── system.*         # System configuration
│   ├── getLicense
│   ├── timezone.*
│   ├── health
│   └── getSettings
└── storage.*        # File storage

Database Schema ​

The D1 database uses the following core tables:

  • User - System users and authentication
  • Sensor - Connected sensors and devices
  • Location - Physical locations/intersections
  • Event - Traffic events and violations
  • Report - Generated reports

Request Flow ​

  1. Client sends request to api.itms.solutions
  2. Cloudflare routes to nearest edge location
  3. Worker processes request
  4. Database/storage operations (if needed)
  5. Response sent back to client

Average latency: < 50ms globally

SCS Smart City - Traffic, Gateway, Camera, and NVR Platform