Back to Case Studies
healthcareweb

DICOM Router

Lightweight, self-hosted DICOM toolkit for telemedicine providers and medium-sized medical facilities. Single Go binary that receives medical images via DICOM protocol, routes them based on rules, and forwards to multiple cloud services (AWS S3, MinIO, file storage) or other DICOM servers. Features rule-based routing by modality/AE Title/tags, AI integration with callback patterns, C-FIND/C-MOVE support for querying external PACS, web management UI with audit logging for HIPAA compliance, and DICOMweb integration with OHIF viewer. Not a full PACS replacement—rather an extensible router toolkit for quickly connecting imaging devices to clouds, archives, and AI pipelines.

20255 min read
DICOM Router dashboard showing real-time monitoring of file routing, DICOM job tracking, and system statistics

The Challenge

Telemedicine providers and medium-sized medical facilities struggle to connect imaging devices to modern infrastructure. Legacy DICOM systems are expensive ($50K+), vendor-locked, monolithic, and require extensive customization. Teams need a lightweight router that receives DICOM files from scanners, intelligently routes them to cloud storage (AWS S3, MinIO), triggers AI processing pipelines, and archives to other DICOM systems—without buying a full enterprise PACS they don't need.

Built as a pragmatic toolkit for the growing telemedicine market. Smaller clinics and telemedicine platforms need DICOM routing capability but can't justify expensive commercial PACS licenses. They want to leverage cloud services, connect AI processors, and scale to multiple imaging devices without deployment complexity. The system needs to handle real-world DICOM variety (different modalities, vendors, edge cases) while remaining simple enough to self-host.

Key Constraints

  • Support standard DICOM C-STORE receiver for imaging devices
  • Route files to multiple destinations: DICOM servers, AWS S3, MinIO, local storage
  • Configurable rules: match by AE Title (calling entity), modality (CT, MR, etc.), and custom tags
  • AI integration: send files to AI processors with callback webhooks and result tag-based routing
  • Query existing PACS: C-FIND/C-MOVE support to retrieve images from external systems
  • Web-based management: rule configuration, job tracking, destination health monitoring
  • HIPAA compliance: full audit trail of all operations, user authentication, encrypted secrets
  • Browser-based viewing: DICOMweb integration with OHIF Viewer for radiologist access
  • Production-ready: graceful shutdown, connection pooling, panic recovery, race condition-free

Our Approach

Built a single Go binary that combines SCP receiver (DICOM C-STORE), routing engine, multi-destination dispatcher, retry worker, web UI, REST API, and DICOMweb support. PostgreSQL stores state (jobs, rules, destinations, audit logs). Go's concurrency model handles multiple simultaneous connections. Templ templates with HTMX provide lightweight interactive web UI without JavaScript bloat.

Key Technical Decisions

  • Single binary in Go - type safety, fast execution, minimal resource footprint, easy to deploy
  • Templ + HTMX over React - server-side rendering reduces complexity, HTMX for interactivity without heavy framework
  • PostgreSQL for state - proper transactional guarantees, ACID compliance for audit logs, built-in connection pooling
  • Rule-based routing with AET/Modality/Tags - covers 95% of real-world routing needs without requiring custom plugins
  • Callback-based AI integration - AI processors run async, return results via webhook, enables long-running ML workloads
  • C-FIND/C-MOVE SCU support - bridges to existing PACS, supports query and retrieve workflows without reimplementation
  • DICOMweb (QIDO-RS, WADO-RS) - standard HTTP/JSON interface enables OHIF viewer integration and third-party tools
  • Structured logging (slog) - production debugging, no external logging infrastructure required

Timeline: Iterative development over multiple phases. Core routing (4-6 weeks), Web UI (2-3 weeks), AI integration (3-4 weeks), DICOMweb (2-3 weeks), production hardening (ongoing)

Implementation

DICOM Receiver & Routing Engine

Implemented SCP server to receive DICOM files, atomic storage to disk, routing engine matching by AET pattern/modality/tags with priority-based rule evaluation. PostgreSQL job tracking for each file sent through the system. Tested with real DICOM files from various vendors and modalities.

4-6 weeks

Multi-Destination Dispatcher

Built async dispatcher sending files to multiple destinations: DICOM C-STORE (SCU client), AWS S3 and MinIO (S3 plugin), local file storage. Per-destination success/failure tracking. Retry worker with exponential backoff (30s → 30m) for failed transfers.

Web UI & Management Interface

Created lightweight web UI with Templ + HTMX + Tailwind CSS. Sections for managing destinations (DICOM/S3/file), routing rules with visual priority editor, job monitoring dashboard, settings configuration, and storage management. Server-side rendering keeps bundle size minimal.

AI Integration & Advanced Features

Implemented callback-based AI processor integration: routes files to AI endpoints, receives results via webhook, tags output for secondary routing. Added C-FIND SCP for local query, C-FIND/C-MOVE SCU to retrieve from external PACS systems. User authentication with JWT sessions and password management. Audit logging for HIPAA compliance tracking who accessed what and when.

DICOMweb & Standards Compliance

Added QIDO-RS (query studies/series/instances via HTTP), WADO-RS (retrieve metadata and pixel frames). Integrated OHIF Viewer for web-based DICOM viewing. Ensures compatibility with standard medical imaging tools and dashboards.

Production Hardening

Connection pool tuning for database, panic recovery, race condition fixes via proper synchronization. Graceful shutdown for deploying updates without data loss. Settings encrypted in database (AES-256-GCM for S3 secrets). Comprehensive error logging for debugging production issues.

System Architecture

DICOM Router rule configuration interface showing rule-based routing by AE Title, modality, and custom tags

Single Go binary combines SCP server (obd-dicom library for DICOM handling), routing engine with rule evaluation, multi-destination dispatcher (goroutines with channels), retry worker, Gin web framework with REST API, Templ templates for server-rendered UI, PostgreSQL for persistent state (pgx driver, sqlc for type-safe queries). SCP receiver handles C-STORE protocol, parses DICOM files, stores atomically to disk with temp file pattern. Router evaluates rules in priority order, matches by AET pattern (*wildcard support), modality, and tag conditions. Dispatcher sends to destinations: DICOM (C-STORE SCU), S3/MinIO (native clients with secret encryption), file system (directory copy with date organization). Retry worker uses exponential backoff (30s, 1m, 5m, 15m, 30m) for failed jobs. C-FIND SCP receives queries, searches local PostgreSQL index. C-MOVE SCP handles retrieve requests. C-FIND/C-MOVE SCU clients query external PACS and retrieve studies. DICOMweb layer implements QIDO-RS (query via HTTP) and WADO-RS (retrieve metadata and frames). OHIF Viewer integrated on same server, launched with StudyInstanceUID. Web UI built with Templ (server-side templates), HTMX for interactive components (rules editor, destination testing), Alpine.js for lightweight client interactivity, Tailwind CSS for responsive design. PostgreSQL stores jobs (with per-destination status), routing rules, destinations (config + health status), AI processors, audit logs (7-year retention for HIPAA). User auth via JWT sessions with bcrypt-hashed passwords. Settings encrypted in DB (AES-256-GCM). Structured logging via slog for production debugging. Docker container runs single binary, mounts PostgreSQL connection, configurable via env vars. Nginx reverse proxy in front for TLS termination and connection multiplexing. Graceful shutdown on SIGTERM waits for in-flight jobs. Race detector passes in CI. Built and tested on Go 1.23+.

Technology Stack

Go 1.23+Ginobd-dicompgxsqlcTemplHTMXAlpine.jsTailwind CSSPostgreSQL 16DockerS3/MinIONGINX (reverse proxy)slog (structured logging)Custom metricsAI callback webhooksTag-based routing

Results & Impact

Single BinaryEasy Deploy

No runtime dependencies beyond PostgreSQL, Docker-ready, runs anywhere

28K+ LOCGo Production

28,876 lines of well-tested production code with 73.2% coverage

10+ RoutesSimultaneous

Handles multiple concurrent DICOM connections and dispatcher workers

700+ TestsUnit + Integration

Comprehensive test suite (1.45:1 test-to-code ratio) for healthcare reliability

5 YearsProduction Ready

Designed for long-term operational stability with audit trails

  • Eliminated need for expensive enterprise PACS for telemedicine providers ($50K+ licensing → self-hosted toolkit)
  • Enables clinics to integrate modern cloud workflows with legacy DICOM equipment immediately
  • Supports AI integration without replacing DICOM infrastructure—processors plugged in via callbacks
  • Provides standard DICOM/DICOMweb interfaces—compatible with any modern medical imaging tool
  • Full audit trail for HIPAA compliance—every operation logged with user context and timestamps
  • Browser-based DICOM viewing via OHIF Viewer—radiologists access studies through secure web interface
  • Query existing PACS systems (C-FIND/C-MOVE)—bridges to legacy systems when needed
  • Scales from single clinic with one scanner to telemedicine network with dozens of devices across locations

What We Learned

  • DICOM is complex but standard - 3000+ page spec, but respecting protocol pays off in compatibility. Real-world testing with different vendors essential.
  • Rule-based routing sufficient - initially designed for plugin system, but AET + Modality + Tags covers real-world requirements without added complexity.
  • Go's concurrency is powerful - goroutines and channels handle multiple SCP connections elegantly. Proper testing with race detector essential.
  • Lightweight UI wins - Templ + HTMX proved significantly lighter and more maintainable than React for this use case. Server-side rendering fits healthcare workflows.
  • Audit logging from day one - HIPAA requirements drove logging architecture early. Building it in from start much easier than retrofitting.
  • PostgreSQL flexibility - structured data (rules, jobs) mixed with semi-structured (DICOM metadata, S3 configs). JSONB and hstore proved valuable.
  • AI callbacks beat polling - asynchronous webhook-based integration cleaner than polling AI services. Simplifies long-running ML workloads.
  • Test with real data - synthetic DICOM files don't expose edge cases (legacy formats, vendor quirks, multi-frame images). Real hospital samples essential.
  • DICOMweb bridges to modern - HTTP/JSON interface via QIDO-RS/WADO-RS opens door to web-based tools. OHIF viewer integration game-changer for remote radiologists.

Have a similar project in mind?

Let's discuss how we can help you build it

More Case Studies

Speech Coach AI platform dashboard showing real-time speech analysis with pace tracking, filler word detection, and emotional tone visualization

Speech Coach

AI-powered speech coaching platform that democratizes public speaking improvement. Built with Next.js and LLM APIs, the platform analyzes speech in real-time, providing instant feedback on pace, clarity, filler words, and emotional tone. Serving 10K+ users who need affordable, 24/7 access to personalized coaching—replacing expensive $100-300/hour human coaches with AI that scales.

DICOM Routing Platform dashboard displaying medical imaging data flow, real-time monitoring of 100GB+ daily DICOM transfers, and microservices health status

DICOM Routing Platform

Enterprise medical imaging platform built for US telemedicine providers to route DICOM data from distributed clinics. Processes 100GB+ daily with zero downtime using microservices architecture (FastAPI, Redis Streams, HAProxy). Ensures HIPAA compliance, provides audit trails for healthcare regulations, and scales seamlessly from single-clinic to multi-site deployments. Features real-time monitoring dashboard and handles concurrent connections from dozens of imaging devices.

AI Education Platform interface showing Jupyter notebook environment with GPU resource monitoring, medical dataset access, and student workspace management for 40 concurrent users

AI Education Platform

Government-funded platform for healthcare AI training in Korea, replacing expensive cloud services with on-premise GPU infrastructure. Built with NestJS and FastAPI to manage 40 concurrent students across 4 Tesla V100 GPUs partitioned via NVIDIA MIG. Features isolated Jupyter environments, unlimited GPU access for medical dataset training, custom Prometheus monitoring for GPU utilization, and role-based access to shared/private datasets. Solved the challenge of providing secure, cost-effective AI education at scale.

Orthanc PACS dashboard showing DICOM studies list, patient metadata, and system monitoring with CloudWatch metrics

Orthanc PACS Deployment

Production DICOM PACS system deployed on AWS for healthcare startup. Orthanc + S3 + PostgreSQL architecture handling 1500+ DXA bone density scans with VPN-only access, automated backups, and CloudWatch monitoring. Deployed in 3 weeks with defense-in-depth security.

PACS platform study list interface showing advanced filtering, batch operations, and real-time study management with pagination and search

PACS Platform Modernization

Complete modernization of legacy PACS system handling 21TB of medical imaging data. Custom Next.js platform with Orthanc backend, PostgreSQL indexing, and Redis caching. Improved performance from 3-4 studies/second to 100 studies in under 2 seconds. Multi-site deployment with role-based access control and OHIF viewer integration.