Content
# Git + Azure Knowledge Graph
A knowledge graph system that indexes Git repositories to map code structure and service architecture. It parses C# source with Roslyn, discovers REST endpoints, HTTP calls, message queues, and database access, then exposes the graph through a REST API, Angular dashboard, and Cursor MCP integration.

## Documentation
| Guide | Description |
|-------|-------------|
| **[User Guide](docs/USER_GUIDE.md)** | Full setup, UI walkthrough, queries, MCP, troubleshooting |
| **[Architecture](docs/ARCHITECTURE.md)** | System design, data model, indexing flows |
| **[Docs index](docs/README.md)** | All documentation and UI images |
## Features
- **Code-level graph** — classes, methods, properties, inheritance, and call relationships (Roslyn)
- **Service-level graph** — REST APIs, HTTP clients, RabbitMQ/Kafka/Azure Service Bus, EF Core/Dapper
- **Natural-language queries** — keyword-based graph queries ("Find all methods calling X")
- **Incremental refresh** — git-diff-based reindexing of changed files only
- **Dual access** — Web API + MCP server share the same LiteDB store
- **Interactive UI** — Angular dashboard with D3 force-directed graph visualization
## Architecture

```
┌─────────────┐ ┌─────────────┐
│ Angular UI │ │ Cursor MCP │
│ (port 4200)│ │ (stdio) │
└──────┬──────┘ └──────┬──────┘
│ │
▼ ▼
┌──────────────────────────────────┐
│ Web API (5196) │
│ GraphController │
│ RepositoryController │
└──────────────┬───────────────────┘
│
▼
┌──────────────────────────────────┐
│ Core Library │
│ GraphStore (LiteDB + cache) │
│ GraphEngine (BFS/DFS/paths) │
│ GraphIndexer (entity → graph) │
│ RepositoryIndexingService │
│ QueryProcessor (NL queries) │
│ ServiceGraphBuilder │
│ IncrementalRefresher │
└──────────────┬───────────────────┘
│
▼
┌──────────────────────────────────┐
│ LiteDB (%LocalAppData%\ │
│ GitKnowledgeGraph\graph.db) │
└──────────────────────────────────┘
```
See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for detailed design documentation.
Historical phase reports are archived in [docs/archive/](docs/archive/).
## Quick Start
### Prerequisites
- [.NET 9 SDK](https://dotnet.microsoft.com/download)
- [Node.js 18+](https://nodejs.org/) (for the Angular frontend)
- Git
### 1. Build the backend
```bash
dotnet build GitAzureKnowledgeGraph.sln
```
### 2. Start the Web API
```bash
cd src/WebApi/WebApi
dotnet run
```
Swagger UI: http://localhost:5196/swagger
### 3. Start the Angular frontend
```bash
cd frontend
npm install
npm start
```
Dashboard: http://localhost:4200
### 4. Index a repository
**Via UI:** Go to **Repositories** → **+ Index repository** → enter a Git URL → **Start indexing**
**Via API:**
```bash
curl -X POST http://localhost:5196/api/repository/index \
-H "Content-Type: application/json" \
-d '{"gitUrl": "https://github.com/your-org/your-repo.git"}'
```
**Via MCP (Cursor):** See [User Guide — MCP setup](docs/USER_GUIDE.md#using-with-cursor-mcp)
### 5. Query the graph
**Via UI:** Go to **Graph** → type a query → **Run query**
```bash
curl -X POST http://localhost:5196/api/graph/query \
-H "Content-Type: application/json" \
-d '{"query": "Find all classes", "scope": "all"}'
```
## Web UI
| Page | Route | Screenshot |
|------|-------|------------|
| Dashboard | `/dashboard` | [ui-dashboard.png](docs/images/ui-dashboard.png) |
| Graph Explorer | `/graph` | [ui-graph-view.png](docs/images/ui-graph-view.png) |
| Repositories | `/repositories` | [ui-repositories.png](docs/images/ui-repositories.png) |
See the [User Guide](docs/USER_GUIDE.md) for a full walkthrough of each page.
## Project Structure
```
MemoryBankProject/
├── src/
│ ├── Core/Core/ Shared library (models, graph, git, service discovery)
│ ├── WebApi/WebApi/ ASP.NET Core REST API
│ └── McpServer/McpServer/ Cursor MCP stdio server
├── frontend/ Angular 17 SPA
├── docs/
│ ├── USER_GUIDE.md How to install and use the system
│ ├── ARCHITECTURE.md Design and data model
│ ├── images/ UI screenshots and diagrams
│ └── archive/ Historical phase reports
└── GitAzureKnowledgeGraph.sln
```
## API Endpoints
| Method | Route | Description |
|--------|-------|-------------|
| GET | `/api/graph/stats` | Graph statistics |
| POST | `/api/graph/query` | Natural-language query |
| GET | `/api/graph/nodes/{id}` | Get node by ID |
| GET | `/api/graph/nodes?type=&limit=` | List nodes by type |
| GET | `/api/graph/nodes/{id}/dependencies` | Outgoing dependency tree |
| GET | `/api/graph/nodes/{id}/dependents` | Incoming dependent tree |
| GET | `/api/graph/path?from=&to=` | Shortest path between nodes |
| GET | `/api/graph/cycles` | Detect circular dependencies |
| GET | `/api/repository` | List indexed repositories |
| POST | `/api/repository/index` | Index a new repository |
| POST | `/api/repository/{id}/refresh` | Incremental refresh |
## MCP Tools
| Tool | Description |
|------|-------------|
| `index_repository` | Clone and index a Git repository |
| `query_knowledge_graph` | Natural-language graph query |
| `get_entity_details` | Get details for a specific entity |
| `refresh_repository` | Incrementally refresh an indexed repo |
## Node Types

All node types are stored in lowercase kebab-case:
| Type | Source |
|------|--------|
| `class`, `method`, `property`, `interface`, ... | Roslyn code parsing |
| `service` | Service discovery |
| `api-endpoint` | REST endpoint extraction |
| `http-call` | Outbound HTTP client calls |
| `message-queue` | MQ publish/subscribe |
| `database-access` | EF Core / Dapper / SQL |
## Configuration
| Setting | Default | Location |
|---------|---------|----------|
| Database path | `%LocalAppData%\GitKnowledgeGraph\graph.db` | `Program.cs` (WebApi + MCP) |
| API port | 5196 | `launchSettings.json` |
| Frontend port | 4200 | `angular.json` |
| Cache size | 10,000 nodes/edges | `GraphStore` constructor |
## License
Internal project — see repository owner for licensing terms.