Project structure
How the ai-cost-gate source tree is organized after you clone it.
After cloning the private repository (Pro buyers only), the layout is:
ai-cost-gate/
├── cmd/
│ └── aicg/ # main binary entry point
├── internal/
│ ├── proxy/ # OpenAI-compatible proxy
│ ├── attribution/ # project/agent/model attribution
│ ├── budget/ # budget, throttle, auto-stop
│ ├── store/ # SQLite persistence
│ ├── admin/ # admin HTTP API
│ └── dashboard/ # embedded web dashboard
├── web/ # dashboard frontend (assets)
├── data/ # SQLite file lives here at runtime
├── docker-compose.yml
├── Dockerfile
├── .env.example
└── README.mdTop-level conventions
cmd/holds the entry points. There is only one binary,aicg, which starts the proxy, the admin API, and the embedded dashboard.internal/holds all business logic. Nothing ininternal/is importable from outside this module — that's Go's convention and we use it.web/contains the static assets for the dashboard. They are embedded into the binary withgo:embedso the docker image stays as a single artifact.
Where to look
- Adding a provider adapter? Start at
internal/proxy/adapters/. - Changing how cost is calculated? Look at
internal/attribution/pricing.go. - Changing the auto-stop heuristic? Look at
internal/budget/autostop.go. - Changing the schema? Look at
internal/store/migrations/.
Build artifacts
After go build ./cmd/aicg, the binary is at ./aicg. The Docker image is built with a multi-stage Dockerfile that uses a distroless base — no shell, no package manager, ~30MB final image.