AgentSkillsCN

project-architecture

LSTM Autoencoder异常检测项目结构、各组件职责与数据流转的参考。当您需要在代码库中快速定位各组件的关联方式,或为新加入项目团队的成员提供入门指导时,此参考手册将助您一臂之力。

SKILL.md
--- frontmatter
name: project-architecture
description: Reference for the LSTM Autoencoder anomaly detection project structure, component responsibilities, and data flow. Use when navigating the codebase, understanding how components connect, or onboarding to the project.

Project Architecture

Data flow

code
Prometheus (scrapes mock-service every 30s)
    |
    v
PrometheusClient.get_tv_metrics()    [src/data/prometheus_client.py]
    |  -- PromQL queries from config/data.yaml
    |  -- Auto-adjusts step if >11K points
    v
Raw DataFrame (timestamp, request_rate, latency_p95, memory_usage, error_rate, cpu_usage)
    |
    v
DataPreprocessor.transform()          [src/data/preprocessor.py]
    |  -- Adds temporal features (hour_sin/cos, dayofweek_sin/cos, is_weekend, is_night)
    |  -- Scales to [0,1] using fixed_minmax bounds from config
    v
Scaled DataFrame (11 features)
    |
    v
WindowGenerator.create_single_window() [src/data/windowing.py]  (inference)
WindowGenerator.create_sequences()      [src/data/windowing.py]  (training)
    |
    v
numpy array shape (batch, 20, 11)
    |
    v
LSTMAutoencoder.predict()             [src/models/lstm_autoencoder.py]
    |  -- Encoder: 64 -> 32 -> 16
    |  -- Decoder: 16 -> 32 -> 64
    |  -- Output: TimeDistributed Dense
    v
Reconstruction error (MSE per window)
    |
    v
AnomalyDetector.detect()              [src/alerting/detector.py]
    |  -- Compare MSE to saved threshold
    v
Alert pipeline (dedup, Opsgenie, Grafana links)  [scripts/inference.py]

Config hierarchy

All config loaded via src/utils/config.py using dot-notation:

FileKey prefixControls
config/data.yamldata.*Prometheus URL, metric queries, preprocessing, fixed_bounds, collection params
config/model.yamlmodel.*Architecture, hyperparams, training settings
config/windowing.yamlwindowing.*window_size, stride
config/alerting.yamlalerting.*Threshold method, rate limiting, Opsgenie, Grafana

Docker services (dev profile)

ServiceContainerPortPurpose
mock-servicemock-tv-service8000Simulated TV-over-IP with anomaly injection
prometheusprometheus9090Metrics storage, scrapes mock-service
anomaly-detectiontv-anomaly-detector8080Runs inference.py
grafanagrafana3000Dashboards