A high-performance, distributed Go application for capturing, processing, and storing SBS (BaseStation) messages from ADS-B receivers. The system provides real-time aircraft tracking, flight session management, and comprehensive data persistence with TimescaleDB.
- Real-time SBS Message Ingestion: Connects to multiple ADS-B receivers simultaneously
- Distributed Architecture: Microservices-based design with NATS messaging
- Aircraft State Tracking: Real-time position, altitude, speed, and flight data
- Flight Session Management: Automatic flight detection and session tracking
- High-Performance Storage: TimescaleDB for time-series data with automatic retention policies
- Redis Caching: Fast access to active aircraft states and flight data
- Comprehensive Logging: Daily log rotation with automatic compression
- Statistics & Monitoring: Real-time system metrics and performance tracking
- Docker Support: Complete containerized deployment with docker-compose
This project maintains high code quality and security standards through automated checks:
- π Code Quality: Automated linting with golangci-lint
- π§ͺ Testing: Comprehensive unit and integration tests with race condition detection
- π Code Coverage: Continuous coverage tracking with Codecov
- π Security Scanning: Automated vulnerability scanning with Trivy
- π³ Container Security: Docker image scanning and multi-platform builds
- π Go Report Card: Code quality analysis and grading
- π CI/CD: Automated testing, building, and deployment pipeline
The system consists of several microservices that communicate via NATS:
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Ingestor βββββΆβ NATS βββββΆβ Logger β
β β β β β β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β
βΌ
βββββββββββββββ
β Tracker β
β β
βββββββββββββββ
β
ββββββββ΄βββββββ
βΌ βΌ
βββββββββββββββ βββββββββββββββ
β TimescaleDB β β Redis β
β β β β
βββββββββββββββ βββββββββββββββ
- Ingestor: Connects to SBS sources and publishes messages to NATS
- Logger: Subscribes to messages and writes to daily log files
- Tracker: Processes messages, tracks aircraft states, manages flight sessions, and handles database migrations
- NATS: Message broker for inter-service communication
- TimescaleDB: Time-series database for aircraft states and statistics
- Redis: Caching layer for active aircraft and flight data
- Go 1.24.5 or later
- Docker and Docker Compose
- PostgreSQL/TimescaleDB
- Redis
- NATS Server
- Clone the repository:
git clone https://github.com/saviobatista/sbs-logger.git
cd sbs-logger
- Configure environment variables:
# Copy the sample environment file
cp .env.sample .env
# Edit the .env file with your configuration
nano .env
- Update the key variables in
.env
:
# Your ADS-B receiver(s)
SOURCES=your-adsb-receiver:30003,another-receiver:30003
# Your receiver location (for Ultrafeeder)
ULTRAFEEDER_LAT=your_latitude
ULTRAFEEDER_LON=your_longitude
ULTRAFEEDER_ALT=your_altitude
# Database credentials (change for production)
POSTGRES_PASSWORD=your_secure_password
- Start the services:
docker-compose up -d
- Install dependencies:
go mod download
- Build all components:
go build ./cmd/ingestor
go build ./cmd/logger
go build ./cmd/tracker
- Start the services:
# Migrations will run automatically when the tracker service starts
./tracker
The tracker service will automatically run database migrations on startup.
The project uses a .env
file for configuration. Start by copying the sample file:
cp .env.sample .env
SOURCES
: Comma-separated list of SBS sources (e.g.,10.0.0.1:30003,10.0.0.2:30003
)NATS_URL
: NATS server URL (default:nats://nats:4222
)
OUTPUT_DIR
: Directory for log files (default:./logs
)NATS_URL
: NATS server URL (default:nats://nats:4222
)
NATS_URL
: NATS server URL (default:nats://nats:4222
)DB_CONN_STR
: Database connection stringREDIS_ADDR
: Redis server address (default:redis:6379
)
The .env.sample
file is organized into sections:
- Ultrafeeder Configuration: ADS-B receiver settings and web interface
- SBS Services: Configuration for ingestor, logger, and tracker
- Database Configuration: TimescaleDB connection settings
- Security: Optional authentication and SSL settings
The system uses TimescaleDB with the following main tables:
aircraft_states
: Time-series table for aircraft position and state dataflights
: Flight session informationsystem_stats
: System performance and statistics
NATS is configured with JetStream enabled for message persistence:
port: 4222
http_port: 8222
jetstream {
store_dir: "/data"
max_memory_store: 1G
max_file_store: 10G
}
The system processes the following SBS message types:
- MSG,1: Selection change
- MSG,2: New aircraft
- MSG,3: New ID
- MSG,4: New callsign
- MSG,5: New altitude
- MSG,6: New ground speed
- MSG,7: New track
- MSG,8: New lat/lon (position)
- MSG,9: New ground status
The tracker maintains real-time state for each aircraft:
- Position (latitude/longitude)
- Altitude and vertical rate
- Ground speed and track
- Callsign and squawk
- Ground status
Flight sessions are automatically detected and tracked:
- Session start/end times
- Flight path (first/last position)
- Maximum altitude and speed
- Session statistics
The system provides comprehensive statistics:
- Message processing rates
- Aircraft and flight counts
- Processing performance metrics
- Error rates and system health
Statistics are logged every minute and persisted to the database every 5 minutes.
sbs-logger/
βββ cmd/ # Application entry points
β βββ ingestor/ # SBS message ingestion
β βββ logger/ # Log file management
β βββ tracker/ # Aircraft state tracking
βββ internal/ # Private application code
β βββ capture/ # Network capture logic
β βββ config/ # Configuration management
β βββ db/ # Database operations
β βββ nats/ # NATS client
β βββ parser/ # SBS message parsing
β βββ redis/ # Redis client
β βββ stats/ # Statistics tracking
β βββ storage/ # Storage abstractions
β βββ types/ # Data structures
βββ config/ # Configuration files
β βββ nats/ # NATS server configuration
βββ logs/ # Log file output
βββ docker-compose.yml # Container orchestration
go test ./...
# Build all components
make build
# Build individual components
make build-ingestor
make build-logger
make build-tracker
The project includes automated Docker Hub publishing. To set up:
- Setup Docker Hub publishing:
make dockerhub-setup
- Test Docker builds locally:
make dockerhub-test
- Manual push to Docker Hub:
make dockerhub-push DOCKERHUB_USERNAME=youruser DOCKERHUB_TOKEN=yourtoken VERSION=v1.0.0
- Automated publishing: Create a GitHub release to trigger automatic publishing
For detailed setup instructions, see Docker Hub Setup Guide.
The project provides pre-built Docker images on multiple registries:
# Pull images from GHCR
docker pull ghcr.io/saviobatista/sbs-logger/sbs-ingestor:latest
docker pull ghcr.io/saviobatista/sbs-logger/sbs-logger:latest
docker pull ghcr.io/saviobatista/sbs-logger/sbs-tracker:latest
# Pull images from Docker Hub
docker pull saviobatista/sbs-ingestor:latest
docker pull saviobatista/sbs-logger:latest
docker pull saviobatista/sbs-tracker:latest
- Scaling: Run multiple ingestor instances for high availability
- Storage: Configure appropriate retention policies for TimescaleDB
- Monitoring: Set up monitoring for NATS, Redis, and TimescaleDB
- Backup: Implement regular database backups
- Security: Use TLS for NATS and database connections
# Production deployment
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# Scale services
docker-compose up -d --scale ingestor=3
Update your docker-compose.yml
to use pre-built images:
services:
ingestor:
image: saviobatista/sbs-ingestor:latest
# or: image: ghcr.io/saviobatista/sbs-logger/sbs-ingestor:latest
environment:
- SOURCES=your-adsb-receiver:30003
- NATS_URL=nats://nats:4222
depends_on:
- nats
logger:
image: saviobatista/sbs-logger:latest
environment:
- OUTPUT_DIR=/app/logs
- NATS_URL=nats://nats:4222
volumes:
- ./logs:/app/logs
depends_on:
- nats
Logs are written to daily files with automatic rotation:
- Format:
sbs_YYYY-MM-DD.log
- Compression: Previous day's logs are automatically compressed
- Location:
./logs/
directory (configurable)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
For issues and questions:
- Check the documentation
- Search existing issues
- Create a new issue with detailed information