This guide will walk you through generating a Dependency Graph from a local repository.
Prerequisites
- API Key: You’ll need a Supermodel API key. Get one from the Dashboard.
- Codebase: A local folder containing the code you want to analyze.
- Tools:
zip and curl installed on your machine.
Step 1: Prepare your code
The Supermodel API accepts code as a zipped archive. Navigate to your project folder and create a zip file, excluding hidden files like .git or node_modules to keep the upload size small.
# Zip your current directory, excluding hidden files and node_modules
zip -r repo.zip . -x ".*" -x "**/.*" -x "node_modules/*"
Step 2: Generate a graph
Use the dependency endpoint to generate a graph of file-level dependencies. Replace <your-api-key> with your actual key. The Idempotency-Key should be a unique value (like a UUID) for each request.
curl --request POST \
--url https://staging.api.supermodeltools.com/v1/graphs/dependency \
--header "Idempotency-Key: $(uuidgen)" \
--header 'X-Api-Key: <your-api-key>' \
--header 'Content-Type: multipart/form-data' \
--form file='@repo.zip'
The $(uuidgen) command generates a unique ID automatically on macOS and Linux. On Windows, you can use [guid]::NewGuid() in PowerShell.
Step 3: Interpret the response
You will receive a JSON response containing the graph nodes (files) and relationships (imports).
{
"graph": {
"nodes": [
{
"id": "src/main.ts",
"labels": ["File"],
"properties": { "name": "main.ts" }
},
{
"id": "src/utils.ts",
"labels": ["File"],
"properties": { "name": "utils.ts" }
}
],
"relationships": [
{
"type": "imports",
"startNode": "src/main.ts",
"endNode": "src/utils.ts"
}
]
}
}
Next Steps
Explore other graph types to get different insights into your code: