Skip to content

Project Structure & Dependency Map ​

File Hierarchy ​

14-tracing-backend/
├── backend/
│   ├── alembic/                # Database schema migrations
│   ├── alembic.ini             # Alembic migration configuration
│   ├── src/
│   │   ├── api/                # FastAPI application entry & HTTP routers
│   │   │   ├── app.py          # FastAPI initialization & global exception handlers
│   │   │   ├── deps.py         # Database session & security dependencies
│   │   │   ├── middleware/     # Auth, tenant isolation, rate limiting middleware
│   │   │   └── routes/         # REST API endpoints (traces, services, sampling, ml)
│   │   ├── collector/          # Ingestion engine (OTLP receiver, backpressure, batching)
│   │   ├── observability/      # Internal telemetry & profiler
│   │   ├── query/              # Span DAG assembly, critical path calculation
│   │   ├── sampling/           # Head, tail, error-aware & priority sampling policies
│   │   ├── security/           # PII redaction, JWT/OIDC validator, mTLS, RBAC
│   │   ├── storage/            # ClickHouse/SQLite async models, failover client
│   │   └── tracelib/           # W3C trace context propagation & utilities
│   └── tests/                  # 141 test files (313 pytest unit & integration tests)
├── frontend/
│   ├── src/
│   │   ├── App.tsx             # Root React component & navigation router
│   │   ├── api/client.ts       # Typed API client for tracing backend
│   │   ├── components/         # Interactive UI components
│   │   │   ├── WaterfallTimeline.tsx      # SVG-based span execution timeline
│   │   │   ├── SpanTree.tsx               # Collapsible hierarchical span tree
│   │   │   ├── DependencyGraph.tsx        # Service-to-service graph visualizer
│   │   │   ├── CriticalPathHighlight.tsx  # Bottleneck execution path marker
│   │   │   ├── IncidentSummarizer.tsx     # LLM incident postmortem viewer
│   │   │   ├── AnomaliesViewer.tsx        # Real-time ML anomaly alerts
│   │   │   └── NLQuerySearch.tsx          # Semantic natural language trace query
│   │   └── pages/              # TraceExplorer, TraceDetail, ServiceMap
│   ├── package.json            # React 18, Vite 6, TypeScript 5.7 dependencies
│   └── vite.config.ts          # Vite build configuration
├── ml/                         # 11 Statistical anomaly & LLM evaluation modules
│   ├── latency_anomaly.py      # Statistical p95/p99 latency outlier detection
│   ├── dependency_anomaly.py   # Service call topology shift detection
│   ├── error_spike.py          # Sliding-window burst error detector
│   ├── trace_anomaly.py        # Whole-trace graph structure anomaly scorer
│   ├── slow_span_predictor.py  # Critical path delay forecaster
│   ├── dynamic_sampling.py     # Adaptive sampling weight calculator
│   ├── semantic_search.py      # Vector embeddings for trace logs & tags
│   ├── llm_engine.py           # Pre-trained LLM integration for incident summaries
│   └── root_cause.py           # Causal DAG traversal for fault isolation
├── legacy_scaffold/            # Preserved initial project scaffolds
├── FEATURES.csv                # 150 feature tracking matrix
└── PROGRESS.md                 # Implementation milestone log

Tech Stack & Runtime Dependencies ​

TierTechnologyVersionPurpose
Backend RuntimePython3.13High-performance asynchronous execution runtime
Web FrameworkFastAPI0.115+Asynchronous REST and OpenTelemetry ingestion endpoints
Data ValidationPydantic2.10+Strict type validation for spans, traces, and sampling policies
Database ORMSQLAlchemy / aiosqlite2.0+Async database access with ClickHouse / SQLite failover
Migration ToolAlembic1.14+Schema version control and database migrations
TestingPytest / Pytest-asyncio8.3+313 unit and integration tests with async test harnesses
Frontend FrameworkReact18.3.1Component-driven UI architecture with concurrent rendering
Bundler & Dev ServerVite6.0.7Lightning-fast ESM dev server and optimized production bundler
LanguageTypeScript5.7.2End-to-end static typing across frontend interfaces
IconsLucide React0.469.0Accessible UI icons for traces, services, and anomalies

Environment Variables & Configuration ​

Variable NameDefault / ExamplePurposeSource / Provider
TRACING_PORT8000HTTP port for FastAPI collector & query engineApplication runtime
DATABASE_URLsqlite+aiosqlite:///./tracing.dbPrimary async connection stringClickHouse or SQLite
CLICKHOUSE_HOSTlocalhost:9000Columnar database endpoint for high-volume spansInfrastructure ClickHouse
OPENAI_API_KEY[CONFIRM WITH DEVELOPER]API key for LLM automated incident summarizationOpenAI / Claude API
TAIL_SAMPLING_WINDOW_SEC30In-memory ring buffer retention before sample decisionBackend config
MAX_BATCH_SIZE5000Maximum span batch size accepted per OTLP requestCollector safety limit