{"id":31391689,"url":"https://github.com/tscircuit/tscircuit-autorouter","last_synced_at":"2025-09-29T02:49:44.338Z","repository":{"id":275621487,"uuid":"924883209","full_name":"tscircuit/tscircuit-autorouter","owner":"tscircuit","description":"A State of the Art MIT-licensed PCB Autorouter","archived":false,"fork":false,"pushed_at":"2025-09-27T22:06:54.000Z","size":10613,"stargazers_count":9,"open_issues_count":81,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-27T22:10:18.642Z","etag":null,"topics":["autorouter","pcb","pcb-layout"],"latest_commit_sha":null,"homepage":"https://autorouter.tscircuit.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tscircuit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-30T20:17:59.000Z","updated_at":"2025-09-27T20:19:53.000Z","dependencies_parsed_at":"2025-03-20T07:37:09.847Z","dependency_job_id":"8bb61a8f-fd9b-45ea-aa9e-b6280106f688","html_url":"https://github.com/tscircuit/tscircuit-autorouter","commit_stats":null,"previous_names":["tscircuit/capacity-node-autorouter","tscircuit/capacity-autorouter","tscircuit/unravel-autorouter","tscircuit/tscircuit-autorouter"],"tags_count":111,"template":false,"template_full_name":null,"purl":"pkg:github/tscircuit/tscircuit-autorouter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tscircuit%2Ftscircuit-autorouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tscircuit%2Ftscircuit-autorouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tscircuit%2Ftscircuit-autorouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tscircuit%2Ftscircuit-autorouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tscircuit","download_url":"https://codeload.github.com/tscircuit/tscircuit-autorouter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tscircuit%2Ftscircuit-autorouter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277458661,"owners_count":25821319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-29T02:00:09.175Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autorouter","pcb","pcb-layout"],"created_at":"2025-09-29T02:49:43.191Z","updated_at":"2025-09-29T02:49:44.329Z","avatar_url":"https://github.com/tscircuit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @tscircuit/capacity-autorouter\n\nAn MIT-licensed full-pipeline PCB autorouter library for node.js and TypeScript projects. Part of [tscircuit](https://github.com/tscircuit/tscircuit)\n\n[View Online Playground](https://unraveller.vercel.app) \u0026middot; [tscircuit docs](https://docs.tscircuit.com) \u0026middot; [discord](https://tscircuit.com/join) \u0026middot; [twitter](https://x.com/seveibar) \u0026middot; [try tscircuit online](https://tscircuit.com) \u0026middot; [Report/Debug Autorouter Bugs](https://docs.tscircuit.com/contributing/report-autorouter-bugs)\n\nWant to understand how the autorouter works? Check out a stage-by-stage breakdown with videos in [this autorouter walk through](./docs/blog-post/blog-post.md)\n\n## How to file a bug report\n\n1. You should have [created a bug report via the tscircuit errors tab](https://docs.tscircuit.com/contributing/report-autorouter-bugs)\n2. Run `bun run bug-report \u003cbug-report-url\u003e`\n3. This will download the bug report and create a debugging fixture file in the `examples/bug-reports` directory, you can then find the bug report in the server (via `bun run start`)\n\n## Installation\n\n```bash\nbun add @tscircuit/capacity-autorouter\n```\n\n## Usage as a Library\n\n### Basic Usage\n\n```typescript\nimport { CapacityMeshSolver } from \"@tscircuit/capacity-autorouter\"\n\n// Create a solver with SimpleRouteJson input\nconst solver = new CapacityMeshSolver(simpleRouteJson)\n\n// Run the solver until completion\nwhile (!solver.solved \u0026\u0026 !solver.failed) {\n  solver.step()\n}\n\n// Check if solving was successful\nif (solver.failed) {\n  console.error(\"Routing failed:\", solver.error)\n} else {\n  // Get the routing results as SimpleRouteJson with traces\n  const resultWithRoutes = solver.getOutputSimpleRouteJson()\n\n  // Use the resulting routes in your application\n  console.log(\n    `Successfully routed ${resultWithRoutes.traces?.length} connections`\n  )\n}\n```\n\n### Input Format: SimpleRouteJson\n\nThe input to the autorouter is a `SimpleRouteJson` object with the following structure:\n\n```typescript\ninterface SimpleRouteJson {\n  layerCount: number\n  minTraceWidth: number\n  obstacles: Obstacle[]\n  connections: Array\u003cSimpleRouteConnection\u003e\n  bounds: { minX: number; maxX: number; minY: number; maxY: number }\n  traces?: SimplifiedPcbTraces // Optional for input\n}\n\ninterface Obstacle {\n  type: \"rect\"\n  layers: string[]\n  center: { x: number; y: number }\n  width: number\n  height: number\n  connectedTo: string[] // TraceIds\n}\n\ninterface SimpleRouteConnection {\n  name: string\n  pointsToConnect: Array\u003c{ x: number; y: number; layer: string }\u003e\n}\n```\n\n### Output Format\n\nThe `getOutputSimpleRouteJson()` method returns the original `SimpleRouteJson` with a populated `traces` property. The traces are represented as `SimplifiedPcbTraces`:\n\n```typescript\ntype SimplifiedPcbTraces = Array\u003c{\n  type: \"pcb_trace\"\n  pcb_trace_id: string // TraceId\n  route: Array\u003c\n    | {\n        route_type: \"wire\"\n        x: number\n        y: number\n        width: number\n        layer: string\n      }\n    | {\n        route_type: \"via\"\n        x: number\n        y: number\n        to_layer: string\n        from_layer: string\n      }\n  \u003e\n}\u003e\n```\n\n### Advanced Configuration\n\nYou can provide optional configuration parameters to the solver:\n\n```typescript\nconst solver = new CapacityMeshSolver(simpleRouteJson, {\n  // Optional: Manually set capacity planning depth (otherwise automatically calculated)\n  capacityDepth: 7,\n\n  // Optional: Set the target minimum capacity for automatic depth calculation\n  // Lower values result in finer subdivisions (higher depth)\n  targetMinCapacity: 0.5,\n})\n```\n\nBy default, the solver will automatically calculate the optimal `capacityDepth` to achieve a target minimum capacity of 0.5 based on the board dimensions. This automatic calculation ensures that the smallest subdivision cells have an appropriate capacity for routing.\n\n### Visualization Support\n\nFor debugging or interactive applications, you can use the `visualize()` method to get a visualization of the current routing state:\n\n```typescript\n// Get visualization data that can be rendered with graphics-debug\nconst visualization = solver.visualize()\n```\n\n## Development\n\nTo work on this library:\n\n```bash\n# Install dependencies\nbun install\n\n# Start the interactive development environment\nbun run start\n\n# Run tests\nbun test\n\n# Build the library\nbun run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftscircuit%2Ftscircuit-autorouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftscircuit%2Ftscircuit-autorouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftscircuit%2Ftscircuit-autorouter/lists"}