TraceGrid bridges your database schema, API routes, and frontend components
into a single architecture.md source-of-truth
— then serves it as an interactive JSON graph for your visual canvas.
TraceGrid operates bi-directionally. Start from an idea or scan what already exists —
either way, you end up with a structured, machine-readable architecture.md.
Give TraceGrid an idea string or a PRD document. The
tracegrid-architect AI mode designs the normalized
DB schema, API route inventory, directory structure, and request flows —
then writes architecture.md before a single line of code is written.
Point TraceGrid at an existing codebase. The scanner inspects Prisma schemas,
SQL DDL, TypeORM entities, Express/Next.js/FastAPI routes, and React fetch hooks —
then compiles everything into architecture.md.
architecture.md already exists? TraceGrid parses it directly
into a { nodes, edges } JSON graph and serves it via HTTP —
hot-reload safe, ready to feed any visual canvas or analysis tool.
All commands compile to a single Node.js executable in packages/cli/dist/index.js.
Greenfield mode — generates a starter architecture.md from an idea string or PRD file.
# From a free-text idea node packages/cli/dist/index.js init "A SaaS invoicing app with team workspaces" # From an existing PRD file node packages/cli/dist/index.js init ./docs/prd.md --out architecture.md # With scaffold notice node packages/cli/dist/index.js init "Task management platform" --scaffold
Brownfield mode — scan a directory and compile architecture.md.
# Scan current directory node packages/cli/dist/index.js scan . # Scan a specific backend service node packages/cli/dist/index.js scan ./apps/api --out api-arch.md # Output: # 🔍 Scanning: /your/project # Found: 12 DB tables, 34 API routes, 18 frontend components # ✅ Written to: architecture.md
Serve the graph JSON API — reads architecture.md on every request.
node packages/cli/dist/index.js serve --port 4000 # 🟢 TraceGrid server running on http://localhost:4000 # Available endpoints: curl http://localhost:4000/graph # { nodes, edges } curl http://localhost:4000/graph/nodes # { nodes } curl http://localhost:4000/graph/edges # { edges } curl http://localhost:4000/health # { status: "ok" }
Validate architecture.md against the canonical schema and report graph statistics.
node packages/cli/dist/index.js validate # ✅ architecture.md is valid # DB tables: 3 # Relationships: 3 # API routes: 6 # Request flows: 4 # Graph nodes: 13 # Graph edges: 13 node packages/cli/dist/index.js validate --json # machine-readable
The scanner reads file contents only — no subprocess execution, no dynamic imports.
Each sub-scanner is a pure function: (content, filePath) => ScanResult.
.prisma.sql@Entitydefine()router.get/post@router.getfetch()axios.get/post/putuseSWR()useQuery()
The canonical schema is enforced by a deterministic parser.
A missing or malformed section throws a ParseError — never silent partial results.
## Database Schema ```mermaid erDiagram User { int id PK string email string passwordHash } Post { int id PK string title int authorId FK } User ||--o{ Post : "writes" ```
## API Routes | Method | Path | Handler | Description | |--------|----------------|------------------------|-----------------| | GET | /api/posts | postController.list | List all posts | | POST | /api/posts | postController.create | Create a post | | GET | /api/posts/:id | postController.get | Get single post |
## Directory Structure ``` myapp/ ├── src/ │ ├── controllers/ │ │ └── postController.ts │ └── models/ │ └── Post.ts └── package.json ```
## Request Flows | Feature | Frontend Component | Endpoint | DB Tables | |------------|--------------------|---------------------|-------------| | List Posts | PostList | GET /api/posts | Post, User | | Create Post| PostForm | POST /api/posts | Post | | View Post | PostDetail | GET /api/posts/:id | Post, Comment |
Import from @tracegrid/core in any TypeScript or Node.js project.
All public functions have explicit return types. No any.
architecture.md.architecture.md string → TraceGraph in one call.Every architectural decision in TraceGrid follows these five constraints.
architecture.md is committed before any code. No DB migration without a schema entry. No API endpoint without a route table row.
Identical input always produces identical { nodes, edges } output. No heuristics, no probabilistic guessing in the parser layer.
Every sub-scanner is (content, filePath) => ScanResult. No subprocess execution, no dynamic imports, no side effects.
@tracegrid/core has no runtime npm dependencies. Only the Node.js standard library. CLI adds only express and commander.
noUncheckedIndexedAccess, strict: true, explicit return types on all public functions. No any in core types or parser.
The generator must produce output that the parser can parse without loss. Same structure in, same structure out — always.
Install, scan your project, and have a graph JSON API running in under 60 seconds.