PriceStream is WIP a modular Scala backend service for concurrent price ingestion and historical price tracking across multiple platforms. It exposes operational endpoints for the ingestion runs and metrics dashboard visualization.
The system combines:
- REST API for tracking and querying data
- Scheduled ingestion pipeline
- Concurrent provider processing
- Persistent ingestion run tracking
- Historical price tracking (WIP)
- Decoupled dashboard API and API gateway (FastAPI)
- Dashboard frontend to visualize runs data (React)
Backend (Scala)
- Cats Effect
- FS2
- Http4s
- Doobie (PostgreSQL)
- Circe
Dashboard
- FastAPI
- PostgreSQL
- React
- JWT-based authentication
All infrastructure components are managed using Resource:
- HTTP server
- Database transactor
- HTTP client
- Background ingestion scheduler
This guarantees safe startup and graceful shutdown.
The ingestion pipeline is implemented as an FS2 stream:
- Initial ingestion at startup
- Recurring ingestion every 10 minutes (
Stream.awakeEvery) - Executed in a dedicated fiber
- Gracefully cancelled on application shutdown
Each ingestion cycle processes providers in parallel:
providers.parTraverse_(ingestFromProvider)This leverages structured concurrency via Cats Effect fibers.
Each ingestion run is persisted with state tracking:
- Running
- Completed
- Failed
Failures are captured using .attempt to prevent scheduler crashes and
ensure the system continues operating.
The backend ingestion service is logically isolated from the dashboard.
The dashboard consumes only exposed REST endpoints secured with JWT
authentication.
This allows independent evolution of:
- Ingestion logic
- API contracts
- Visualization layer
- Application starts
- Resources are initialized (DB, client, server, scheduler)
- Initial ingestion runs
- Scheduler triggers ingestion every 10 minutes
- Dashboard consumes exposed endpoints for visualization
- Bounded concurrency (
parTraverseN) - Rate limiting / throttling
- Retry with exponential backoff
- Metrics and observability (Prometheus)
- Message broker integration (Kafka / RabbitMQ)
- Circuit breaker for external providers
To
- Explore structured concurrency in Scala
- Apply effect-based architecture in real backend systems
- Model clean separation between domain and infrastructure
- Implement safe background processing with lifecycle control