Skip to main content

Dependency Graph Engine

A high-performance Java service for building and querying microservice dependency graphs. This service enables automated impact analysis by maintaining an in-memory graph of service dependencies and providing REST APIs for querying downstream impacts.

Architecture Diagram

The following diagram illustrates the internal architecture of the Dependency Graph Engine, showing how the graph is built using JGraphT, how different components interact, caching with Redis, and integration with the service registry.

Update the Architecture Diagram

To view and edit the architecture diagram:

  1. Open /docs/architecture/services/dependency-graph.drawio in diagrams.net or VS Code with the Draw.io extension
  2. The diagram shows the complete graph engine architecture including REST API, graph builder, impact analyzer, circular dependency detector, cache manager, and data sources
  3. After making changes, export to HTML and copy to /website/static/architecture/services/dependency-graph.drawio.html

Overview

The Dependency Graph Engine is the foundation of Rippler's impact analysis, tracking service-to-service dependencies and computing impact scores when changes occur.

Features

  • Real-time Dependency Graph: Builds and maintains an in-memory directed graph of service dependencies
  • Impact Analysis: Calculates downstream dependencies, impact scores, and dependency paths
  • Circular Dependency Detection: Identifies and reports circular dependencies in the service mesh
  • Redis Caching: Caches graph data for fast access and reduced load on the service registry
  • REST API: Clean REST endpoints for integration with other Rippler services
  • UI-Friendly Export: Exports graph data in formats optimized for visualization
  • Performance: Sub-second query times for 100+ services

Technology Stack

  • Java 17: Modern Java for reliability and performance
  • Spring Boot 3.2: Enterprise-grade framework
  • JGraphT: Robust graph algorithms library
  • Redis: High-performance caching
  • Maven: Dependency management and build tool

API Endpoints

Get Complete Graph

GET /api/v1/graph

Returns the complete dependency graph with all nodes and edges.

Response:

{
"nodes": [
{
"service_id": "api-gateway",
"name": "API Gateway",
"dependencies": ["webhook-handler"],
"dependents": []
}
],
"edges": [
{
"source": "api-gateway",
"target": "webhook-handler"
}
],
"total_services": 6,
"last_updated": "2024-01-15T10:30:00"
}

Get Downstream Dependencies

GET /api/v1/graph/downstream/{service_id}

Returns detailed analysis of all downstream dependencies for a service.

Response:

{
"service_id": "api-gateway",
"direct_dependencies": ["webhook-handler", "impact-analyzer"],
"all_downstream": ["webhook-handler", "impact-analyzer", "llm-service"],
"max_depth": 2,
"total_impacted": 4,
"impact_score": 66.67,
"dependency_paths": [
["api-gateway", "webhook-handler"],
["api-gateway", "impact-analyzer", "llm-service"]
],
"circular_dependencies": []
}

Export for UI Visualization

GET /api/v1/graph/export

Returns graph data optimized for UI visualization tools.

Refresh Graph

POST /api/v1/graph/refresh

Forces a refresh of the dependency graph from the service registry.

Health Check

GET /api/v1/health

Returns service health status.

Configuration

Environment Variables

VariableDescriptionDefault
SERVER_PORTService port8006
REDIS_HOSTRedis hostnamelocalhost
REDIS_PORTRedis port6379
LAUNCHPAD_URLService registry URLhttp://localhost:8007
LAUNCHPAD_API_KEYRegistry API key-
GRAPH_MAX_DEPTHMax dependency depth10
GRAPH_REFRESH_INTERVALAuto-refresh interval (ms)300000

Application Properties

# Server Configuration
server.port=8006

# Redis Configuration
spring.data.redis.host=localhost
spring.data.redis.port=6379

# Launchpad Service Registry
launchpad.url=http://localhost:8007
launchpad.api-key=your-api-key

# Graph Configuration
graph.max-depth=10
graph.enable-circular-detection=true
graph.refresh-interval=300000

Installation

Prerequisites

  • Java 17 or higher
  • Maven 3.6+
  • Redis

Build and Run

# Clone the repository
git clone https://github.com/Citi-Rippler/dependency-graph-engine.git
cd dependency-graph-engine

# Build
mvn clean package

# Run
java -jar target/dependency-graph-service.jar

Using Docker

# Build image
docker build -t rippler/dependency-graph-service .

# Run container
docker run -d \
-p 8006:8006 \
-e REDIS_HOST=redis \
-e LAUNCHPAD_URL=http://launchpad:8007 \
rippler/dependency-graph-service

Using Docker Compose

# From project root
docker-compose up dependency-graph

Usage

Query Downstream Impact

# Get all services affected by changes to api-gateway
curl http://localhost:8006/api/v1/graph/downstream/api-gateway

Visualize Dependencies

# Get graph data for UI
curl http://localhost:8006/api/v1/graph/export

Refresh Graph Data

# Trigger manual refresh
curl -X POST http://localhost:8006/api/v1/graph/refresh

Architecture

The Dependency Graph Engine uses JGraphT to maintain an in-memory directed graph:

  1. Graph Building: Loads service dependencies from Launchpad registry
  2. Caching: Stores graph in Redis for fast access
  3. Query Processing: Uses graph algorithms to compute impact
  4. Auto-Refresh: Periodically syncs with service registry

Integration with Rippler

graph TB
LP[Launchpad] -->|Service Data| DG[Dependency Graph]
IA[Impact Analyzer] -->|Query Dependencies| DG
UI[Rippler UI] -->|Visualize| DG
DG -->|Cache| Redis[(Redis)]

Performance

  • Build Time: < 1 second for 100 services
  • Query Time: < 100ms for downstream analysis
  • Memory: ~100MB for 100 services with 500 edges
  • Throughput: 1000+ queries/second

Development

Running Locally

# Start dependencies
docker-compose up redis launchpad

# Run service
mvn spring-boot:run

Testing

# Run unit tests
mvn test

# Run integration tests
mvn verify

Troubleshooting

Graph Not Loading

  1. Check Launchpad connectivity
  2. Verify API key configuration
  3. Check Redis connectivity
  4. Review service logs

Slow Queries

  1. Check Redis cache hit rate
  2. Verify graph size is reasonable
  3. Consider increasing cache TTL
  4. Review max depth configuration

Repository

GitHub: dependency-graph-engine