Use this file as the first stop when making changes in this repo.
GIT-MAP is a fun codebase explorer. A user can take a public GitHub repo URL and change the domain:
https://github.com/owner/repo
https://git-map.com/owner/repo
The app fetches that repo through the GitHub API, extracts code symbols with Aider RepoMap and Tree-sitter, converts the result into graph JSON, and renders an interactive React + D3 graph in the browser.
Browser / React
-> GET /{owner}/{repo}
-> GET /api/graph/{owner}/{repo}
-> FastAPI
-> GitHub API
-> temp downloaded source files
-> Aider RepoMap tags
-> normalized graph nodes and links
-> React + D3 visualization
The backend owns repo fetching, parsing, graph building, caching, and API responses.
The frontend owns the landing page, GitHub URL parsing, route handling, and graph visualization.
README.md- public-facing project README. Keep it simple and product-focused.agents.md- this contributor/agent guide.requirements.txt- Python backend dependencies..env.example- backend environment template.pytest.ini- pytest config.runtime.txt- Python runtime hint for deployment.docs/git-map.gif- README/demo GIF.
app/main.py- FastAPI app setup, CORS, cache initialization, router registration, static mount.app/config.py- environment-backed settings, supported extensions, CORS origin parsing.app/api/routes.py- all HTTP routes and orchestration for analyzing repos.app/core/cache.py- cache interface and in-memory cache implementation.app/services/github.py- async GitHub API client for latest SHA, file tree, and file downloads.app/services/repomap.py- wrapper aroundaider.repomap.RepoMap, converts raw tags to localTagdataclass.app/services/semantic_normalizer.py- normalizes raw RepoMap tags into visible graph symbol kinds.app/services/graph_builder.py- converts tags and file paths into{ nodes, links }.app/services/discovermap_adapter.py- converts graph payloads into chunked discover/index/file payloads.app/services/file_language.py- language detection and per-language graph colors.app/static/index.html- static browser shell served by FastAPI routes.
frontend/package.json- Vite scripts and frontend dependencies.frontend/src/main.jsx- React entry point.frontend/src/App.jsx- top-level React app/router.frontend/src/pages/Home.jsx- landing/home experience.frontend/src/pages/Graph.jsx- repo graph page.frontend/src/components/RepoGraphCanvas.jsx- D3 graph rendering component.frontend/src/components/Hero.jsx- home hero/domain-swap entry UI.frontend/src/components/ExampleRepos.jsx- example repo shortcuts.frontend/src/components/Features.jsx- home feature copy.frontend/src/components/Footer.jsx- footer.frontend/src/components/BackgroundRippleEffect.jsx- visual background effect.frontend/src/components/GridDotsBackdrop.jsx- grid backdrop.frontend/src/components/LayoutTextFlip.jsx- text flip visual component.frontend/src/utils/parseGithubUrl.js- GitHub URL parsing utility.frontend/src/index.css- Tailwind/global styles.frontend/.env.example- frontend environment template.frontend/vercel.json- frontend deployment config.
tests/conftest.py- pytest setup.tests/test_graph_builder.py- graph builder unit tests.
GET /health- health check.GET /- serves the static browser shell.POST /analyze-repo- accepts{ "owner": "...", "repo": "..." }and returns graph JSON.GET /graph/{owner}/{repo}- returns graph JSON for browser route usage.GET /api/graph/{owner}/{repo}- returns graph JSON for frontend clients.GET /api/discover/{owner}/{repo}/index- returns discover index.GET /api/discover/{owner}/{repo}/chunk/{chunk_id}- returns one discover chunk.GET /api/discover/{owner}/{repo}/file?path=...- returns detailed file payload.GET /{owner}/{repo}- serves the graph browser shell for domain-swapped repo URLs.
routes.pyreceives owner/repo and normalizes them.GitHubClient.get_latest_sha()fetches the current commit SHA.MemoryCacheis checked with key{owner}/{repo}:{sha}.GitHubClient.get_file_tree()fetches the recursive tree and filters to supported source extensions.GitHubClient.download_files()downloads files into a temporary directory.extract_tags()inrepomap.pyruns Aider RepoMap against the downloaded files.graph_builder.build()creates file, type, module, and callable nodes pluscontainsandcallslinks.- The graph response is cached and returned.
discovermap_adapter.pycan reshape the same graph into index/chunk/file payloads for richer clients.
Graph responses look like:
{
"meta": {
"owner": "tiangolo",
"repo": "fastapi",
"commit_sha": "abc123",
"file_count": 42,
"node_count": 310,
"link_count": 480,
"cached": false
},
"nodes": [],
"links": []
}Node types currently used by graph_builder.py:
file- source file node.module- module-like definition.type- class/interface/struct/type-like definition.callable- function/method/callable-like definition.
Link types:
contains- a file or parent symbol owns a symbol.calls- one callable or file references another callable or file.
Backend .env:
GITHUB_TOKEN=ghp_your_github_token_here
MAX_FILES=300
CACHE_TTL=3600
LOG_LEVEL=INFO
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173,https://git-map.com,https://www.git-map.comGITHUB_TOKEN is required for backend repo API calls.
Supported source extensions are defined in app/config.py.
Backend setup:
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt
cp .env.example .envBackend dev server:
uvicorn app.main:app --reload --port 8000Frontend setup and dev server:
cd frontend
npm install
npm run devFrontend build:
cd frontend
npm run buildTests:
pytestUseful API checks:
curl http://localhost:8000/health
curl http://localhost:8000/api/graph/tiangolo/fastapi
curl -X POST http://localhost:8000/analyze-repo \
-H "Content-Type: application/json" \
-d '{"owner":"tiangolo","repo":"fastapi"}'- Change URL/domain-swap behavior in
app/api/routes.py,frontend/src/App.jsx,frontend/src/pages/Graph.jsx, orfrontend/src/utils/parseGithubUrl.js. - Change GitHub fetching, file filtering, or download behavior in
app/services/github.pyandapp/config.py. - Change supported file extensions in
app/config.py. - Change symbol extraction details in
app/services/repomap.py. - Change symbol classification in
app/services/semantic_normalizer.py. - Change graph nodes, links, weights, or call resolution in
app/services/graph_builder.py. - Change discover/index/chunk/file API payloads in
app/services/discovermap_adapter.py. - Change graph visuals in
frontend/src/components/RepoGraphCanvas.jsx. - Change landing page content in
frontend/src/pages/Home.jsxand related components. - Change README/demo presentation in
README.mdanddocs/git-map.gif.
- Keep backend services separate: routes orchestrate, services do the work.
- Do not import the cache directly inside services. Pass cache through route dependencies.
- Preserve the graph response shape unless the frontend and tests are updated together.
- If adding or changing graph behavior, add or update tests in
tests/test_graph_builder.py. - If changing frontend graph payload expectations, check
RepoGraphCanvas.jsxandGraph.jsx. - Keep README language simple: this project is positioned as a fun way to visualize a repo by changing
github.comtogit-map.com. - Avoid committing generated files such as
__pycache__,.pytest_cache,frontend/node_modules, orfrontend/distunless the deployment setup explicitly requires them.
- Improve symbol resolution for larger repos.
- Add better graph search and filtering.
- Add richer file drill-down.
- Add Redis cache backend behind the existing cache interface.
- Improve performance for large repositories.