Real-Time Analytics Features
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Real-Time Analytics Features of the TAMV Online system provide a robust framework for capturing, processing, and visualizing data metrics as they occur. This module is designed to handle high-concurrency data streams, ensuring that the system's "ambitious" nature is supported by immediate insights and data-driven decision-making capabilities.
The scope of this system covers the entire lifecycle of a data point, from ingestion via API endpoints to storage in optimized database schemas and eventual real-time broadcast to connected clients. This infrastructure serves as the backbone for monitoring performance and user activity within the TAMV Online ecosystem.
Sources: README.md:1-2, api/analytics_handler.py
System Architecture and Data Flow
The analytics engine operates on a producer-consumer model where incoming events are validated, enriched, and then distributed to various processing sinks. The architecture is built to maintain low latency even during peak traffic loads.
Data Ingestion Pipeline
Data enters the system through the AnalyticsHandler class, which exposes RESTful endpoints for event reporting. Once an event is received, it is passed to the StreamProcessor for immediate evaluation.
The diagram above illustrates how a single client event is bifurcated into persistent storage and volatile cache for immediate display.
Sources: api/analytics_handler.py:10-45, services/stream_processor.py:15-30
Database Schema and Persistence
The system utilizes a relational schema to ensure data integrity and complex query capabilities. The core table, system_metrics, tracks various KPIs across the platform.
Core Metrics Table
| Field Name | Data Type | Description |
|---|---|---|
event_id | UUID | Unique identifier for each event |
timestamp | TIMESTAMP | The exact time the event was recorded |
metric_type | VARCHAR(50) | The category of the metric (e.g., latency, throughput) |
value | DECIMAL | The numerical value of the metric |
metadata | JSONB | Additional context-specific information |
Sources: database/schema.sql:5-20
Stream Processing Logic
The StreamProcessor is responsible for windowing and aggregation logic. It calculates moving averages and identifies anomalies in real-time.
The sequence diagram shows the asynchronous nature of the analytics ingestion, where the client receives an acknowledgement while processing continues in the background.
Sources: services/stream_processor.py:40-65, api/analytics_handler.py:50-55
Configuration Parameters
System behavior is controlled via the analytics_config.yaml file, allowing administrators to tune performance and retention policies without code changes.
| Parameter | Type | Default Value | Description |
|---|---|---|---|
buffer_size | Integer | 1000 | Number of events to hold in memory before flush |
flush_interval | Seconds | 5 | Frequency of database writes |
retention_days | Integer | 30 | How long to keep granular metric data |
enable_alerts | Boolean | true | Toggle for threshold-based notifications |
Sources: config/analytics_config.yaml:1-12
Summary
The Real-Time Analytics Features represent a critical component of the TAMV Online project, providing the necessary visibility into system operations. By combining a high-performance ingestion API with structured SQL storage and configurable stream processing, the system ensures that performance metrics are always available for both automated scaling and human oversight.