@@ -18,14 +18,53 @@ A powerful CLI tool that analyzes Go codebases and generates graph visualization
18
18
- ** 📝 Configurable** : YAML-based configuration for project-specific settings
19
19
- ** 🏛️ Clean Architecture** : Extensible design following Domain-Driven Design principles
20
20
21
+ ## 🛡️ Project Isolation
22
+
23
+ gograph provides ** complete project isolation** to enable multiple Go projects to coexist safely in the same Neo4j database:
24
+
25
+ ### Key Benefits
26
+
27
+ - ** 🏗️ Multi-Project Support** : Analyze multiple projects without data conflicts
28
+ - ** 🔒 Data Isolation** : Each project's data is completely isolated from others
29
+ - ** 🏷️ Unique Identifiers** : User-defined project IDs ensure clear project boundaries
30
+ - ** 🚀 Performance Optimized** : Database indexes on project_id for fast queries
31
+ - ** 🧹 Safe Cleanup** : Clear project data without affecting other projects
32
+
33
+ ### How It Works
34
+
35
+ 1 . ** Project Initialization** : Each project requires a unique ` project_id ` during setup
36
+ 2 . ** Data Tagging** : All nodes and relationships are tagged with the project_id
37
+ 3 . ** Query Filtering** : All operations automatically filter by project_id
38
+ 4 . ** Index Optimization** : Database indexes ensure fast project-scoped queries
39
+
40
+ ### Usage Example
41
+
42
+ ``` bash
43
+ # Project A
44
+ cd /path/to/project-a
45
+ gograph init --project-id backend-api --project-name " Backend API"
46
+ gograph analyze
47
+
48
+ # Project B
49
+ cd /path/to/project-b
50
+ gograph init --project-id frontend-app --project-name " Frontend App"
51
+ gograph analyze
52
+
53
+ # Both projects coexist safely in the same database
54
+ # Queries automatically filter by project_id
55
+ ```
56
+
21
57
## 📋 Table of Contents
22
58
23
- - [ Installation] ( #installation )
59
+ - [ Project Isolation] ( #️-project-isolation )
60
+ - [ Installation] ( #installation )
24
61
- [ Quick Start] ( #quick-start )
62
+ - [ Complete Workflow] ( #-complete-codebase-analysis-workflow )
25
63
- [ Usage] ( #usage )
26
64
- [ Configuration] ( #configuration )
27
65
- [ Graph Schema] ( #graph-schema )
28
66
- [ MCP Integration] ( #mcp-integration )
67
+ - [ Architecture] ( #️-architecture )
29
68
- [ Development] ( #development )
30
69
- [ Contributing] ( #contributing )
31
70
- [ License] ( #license )
@@ -88,7 +127,7 @@ docker run -v $(pwd):/workspace compozy/gograph:latest analyze /workspace
88
127
2 . ** Initialize project configuration** :
89
128
90
129
``` bash
91
- gograph init
130
+ gograph init --project-id my-awesome-project
92
131
```
93
132
94
133
3 . ** Analyze your Go project** :
@@ -124,15 +163,14 @@ make run-neo4j
124
163
# Navigate to your Go project directory
125
164
cd /path/to/your/go/project
126
165
127
- # Initialize gograph configuration
128
- gograph init --project-name my-awesome-project
166
+ # Initialize gograph configuration with required project ID
167
+ gograph init --project-id my-awesome-project --project-name " My Awesome Project "
129
168
130
- # Analyze the entire codebase (including tests and dependencies )
169
+ # Analyze the entire codebase (project ID is read from config )
131
170
gograph analyze . \
132
171
--include-tests \
133
172
--include-vendor \
134
- --concurrency 8 \
135
- --project-id my-awesome-project
173
+ --concurrency 8
136
174
```
137
175
138
176
### 2. Access Neo4j Browser
@@ -299,28 +337,57 @@ Initialize a new project configuration in the current directory.
299
337
gograph init [flags]
300
338
301
339
Flags:
302
- --force Overwrite existing configuration
303
- --project-name Set project name (default: directory name)
340
+ --project-id string Unique project identifier (required)
341
+ --project-name string Human-readable project name (defaults to project-id)
342
+ --project-path string Project root path (defaults to current directory)
343
+ --force Overwrite existing configuration
344
+ ```
345
+
346
+ ** Examples:**
347
+ ``` bash
348
+ # Basic initialization with required project ID
349
+ gograph init --project-id my-backend-api
350
+
351
+ # Full initialization with custom settings
352
+ gograph init \
353
+ --project-id my-backend-api \
354
+ --project-name " My Backend API" \
355
+ --project-path ./src
356
+
357
+ # Force overwrite existing configuration
358
+ gograph init --project-id my-api --force
304
359
```
305
360
306
361
#### ` gograph analyze `
307
362
308
- Analyze a Go project and store the results in Neo4j.
363
+ Analyze a Go project and store the results in Neo4j. The project ID is automatically loaded from the ` gograph.yaml ` configuration file.
309
364
310
365
``` bash
311
366
gograph analyze [path] [flags]
312
367
313
368
Flags:
314
369
--path string Path to analyze (default: current directory)
315
- --neo4j-uri string Neo4j connection URI
316
- --neo4j-user string Neo4j username
317
- --neo4j-password string Neo4j password
318
- --project-id string Project identifier
370
+ --neo4j-uri string Neo4j connection URI (overrides config)
371
+ --neo4j-user string Neo4j username (overrides config)
372
+ --neo4j-password string Neo4j password (overrides config)
373
+ --project-id string Project identifier (overrides config)
319
374
--concurrency int Number of concurrent workers (default: 4)
320
375
--include-tests Include test files in analysis
321
376
--include-vendor Include vendor directory
322
377
```
323
378
379
+ ** Examples:**
380
+ ``` bash
381
+ # Analyze current directory (uses config from gograph.yaml)
382
+ gograph analyze
383
+
384
+ # Analyze specific directory with all options
385
+ gograph analyze /path/to/project --include-tests --include-vendor --concurrency 8
386
+
387
+ # Override project ID for one-time analysis
388
+ gograph analyze --project-id temporary-analysis
389
+ ```
390
+
324
391
#### ` gograph query `
325
392
326
393
Execute Cypher queries against the graph database.
@@ -349,25 +416,44 @@ Flags:
349
416
350
417
#### ` gograph clear `
351
418
352
- Clear project data from the database.
419
+ Clear project data from the database. Uses project isolation to safely remove only the specified project's data.
353
420
354
421
``` bash
355
422
gograph clear [project-id] [flags]
356
423
357
424
Flags:
358
- --all Clear all projects
425
+ --all Clear all projects (dangerous - use with caution)
359
426
--force Skip confirmation prompt
360
427
```
361
428
429
+ ** Examples:**
430
+ ``` bash
431
+ # Clear current project (reads project ID from gograph.yaml)
432
+ gograph clear
433
+
434
+ # Clear specific project by ID
435
+ gograph clear my-backend-api
436
+
437
+ # Clear with confirmation skip
438
+ gograph clear my-backend-api --force
439
+
440
+ # Clear all projects (dangerous - removes all data)
441
+ gograph clear --all --force
442
+ ```
443
+
444
+ ** Safety** : The clear command only removes data tagged with the specified project_id, ensuring other projects remain untouched.
445
+
362
446
### Examples
363
447
364
448
``` bash
365
- # Analyze current directory
449
+ # Initialize a new project
450
+ gograph init --project-id myproject --project-name " My Go Project"
451
+
452
+ # Analyze current directory (uses project ID from gograph.yaml)
366
453
gograph analyze
367
454
368
455
# Analyze specific project with custom settings
369
456
gograph analyze /path/to/project \
370
- --project-id myproject \
371
457
--concurrency 8 \
372
458
--include-tests
373
459
@@ -395,15 +481,15 @@ Create a `gograph.yaml` file in your project root:
395
481
396
482
``` yaml
397
483
project :
398
- name : my-project
399
- root_path : .
400
- id : my-project-id
484
+ id : my-project-id # Required: Unique project identifier
485
+ name : my-project # Optional: Human-readable name (defaults to id)
486
+ root_path : . # Optional: Project root path (defaults to ".")
401
487
402
488
neo4j :
403
- uri : bolt://localhost:7687
404
- username : neo4j
405
- password : password
406
- database : gograph_my_project
489
+ uri : bolt://localhost:7687 # Neo4j connection URI
490
+ username : neo4j # Neo4j username
491
+ password : password # Neo4j password
492
+ database : " " # Optional: Database name (uses default if empty)
407
493
408
494
analysis :
409
495
ignore_dirs :
@@ -449,10 +535,12 @@ You can override configuration using environment variables:
449
535
export GOGRAPH_NEO4J_URI=bolt://localhost:7687
450
536
export GOGRAPH_NEO4J_USERNAME=neo4j
451
537
export GOGRAPH_NEO4J_PASSWORD=password
452
- export GOGRAPH_PROJECT_ID=my-project
538
+ export GOGRAPH_PROJECT_ID=my-project # Overrides config project ID
453
539
export GOGRAPH_MCP_PORT=8080
454
540
```
455
541
542
+ ** Important** : The ` GOGRAPH_PROJECT_ID ` environment variable will override the project ID from your ` gograph.yaml ` file. This is useful for CI/CD environments or temporary analysis.
543
+
456
544
## 📊 Graph Schema
457
545
458
546
### Node Types
@@ -532,15 +620,32 @@ Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/
532
620
533
621
### Available MCP Tools
534
622
535
- - ` analyze_project ` : Analyze a Go project
536
- - ` query_dependencies ` : Query project dependencies
623
+ ** Project Management:**
624
+ - ` list_projects ` : List all projects in the database
625
+ - ` validate_project ` : Validate project existence and configuration
626
+ - ` analyze_project ` : Analyze a Go project with full isolation
627
+
628
+ ** Code Analysis:**
629
+ - ` query_dependencies ` : Query project dependencies with filtering
537
630
- ` get_function_info ` : Get detailed function information
538
- - ` list_packages ` : List all packages in a project
539
- - ` execute_cypher ` : Execute custom Cypher queries
631
+ - ` list_packages ` : List all packages in a specific project
632
+ - ` get_package_structure ` : Get detailed package structure
633
+ - ` find_implementations ` : Find interface implementations
634
+ - ` trace_call_chain ` : Trace function call chains
635
+
636
+ ** Querying & Search:**
637
+ - ` execute_cypher ` : Execute custom Cypher queries with project filtering
540
638
- ` natural_language_query ` : Translate natural language to Cypher
541
- - ` detect_code_patterns ` : Detect common design patterns
542
- - ` verify_function_exists ` : Verify function existence (prevent hallucinations)
543
- - ` verify_import_relationship ` : Verify import relationships
639
+ - ` get_code_context ` : Get code context for LLM understanding
640
+
641
+ ** Code Quality:**
642
+ - ` detect_code_patterns ` : Detect common design patterns and anti-patterns
643
+ - ` check_test_coverage ` : Analyze test coverage by package
644
+ - ` detect_circular_deps ` : Find circular dependencies
645
+
646
+ ** Verification (Anti-Hallucination):**
647
+ - ` verify_code_exists ` : Verify function/type existence
648
+ - ` validate_import_path ` : Verify import relationships
544
649
545
650
For detailed MCP integration guide, see [ docs/MCP_INTEGRATION.md] ( docs/MCP_INTEGRATION.md ) .
546
651
0 commit comments