Back to Portfolio

Ecotrack

Environmental Tracking System — Personal Project · Architecture & Full Backend

FastAPIPostgreSQLRedisEvent-DrivenClean Architecture

The Problem

Environmental data is fragmented across sources. Air quality sensors, weather stations, and noise monitors each produce data in different formats, at different intervals, through different APIs. The challenge was to build a single system that ingests, processes, and visualizes environmental metrics at scale — handling concurrent data streams without data loss or bottlenecks.

Architecture Decisions

  • Chose FastAPI for async data ingestion — Python's asyncio handles concurrent sensor data streams efficiently.
  • PostgreSQL with time-series optimized schema — proper indexing on timestamp columns for efficient range queries.
  • Event-driven pipeline for real-time data processing — new readings trigger alerts and aggregations asynchronously.
  • Redis caching for dashboard queries — frequently accessed metrics served from cache with configurable TTL.

System Design

emits (1:N)recorded_at (1:N)summarizes (1:N)triggers (1:N)environmental_readingssensorslocationsalertsaggregated_metrics
01
Client

HTTP request originates from the frontend application or external API consumer.

02
API Gateway

Request enters through the gateway which handles routing, rate limiting, and initial validation.

03
Auth Middleware

Authentication and authorization checks. Validates JWT tokens or API keys before proceeding.

04
Service Layer

Business logic execution. Orchestrates use cases and coordinates between components.

Key Technical Highlights

  • Async ingestion handling concurrent data streams from multiple sensor types
  • Schema design with proper indexing for time-range queries — B-tree on (location_id, timestamp)
  • Clean Architecture separation: Domain → Use Cases → Infrastructure layers for testability
  • Materialized views for pre-computed hourly/daily aggregations

Results / Impact

A scalable architecture handling multiple data sources with clean separation of concerns. The system processes concurrent sensor readings without data loss, and the dashboard queries return sub-100ms responses thanks to strategic caching and materialized views.

Have a similar system to build?