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.
To view and edit the architecture diagram:
- Open
/docs/architecture/services/dependency-graph.drawioin diagrams.net or VS Code with the Draw.io extension - The diagram shows the complete graph engine architecture including REST API, graph builder, impact analyzer, circular dependency detector, cache manager, and data sources
- 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
| Variable | Description | Default |
|---|---|---|
SERVER_PORT | Service port | 8006 |
REDIS_HOST | Redis hostname | localhost |
REDIS_PORT | Redis port | 6379 |
LAUNCHPAD_URL | Service registry URL | http://localhost:8007 |
LAUNCHPAD_API_KEY | Registry API key | - |
GRAPH_MAX_DEPTH | Max dependency depth | 10 |
GRAPH_REFRESH_INTERVAL | Auto-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:
- Graph Building: Loads service dependencies from Launchpad registry
- Caching: Stores graph in Redis for fast access
- Query Processing: Uses graph algorithms to compute impact
- 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
- Check Launchpad connectivity
- Verify API key configuration
- Check Redis connectivity
- Review service logs
Slow Queries
- Check Redis cache hit rate
- Verify graph size is reasonable
- Consider increasing cache TTL
- Review max depth configuration
Related Documentation
Repository
GitHub: dependency-graph-engine