|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +Infrahub is a graph-based infrastructure data management platform by OpsMill. It combines Git-like branching and version control with a flexible graph database (Neo4j) and a modern UI/API layer. |
| 6 | + |
| 7 | +## Tech Stack |
| 8 | + |
| 9 | +- **Backend:** Python 3.12, FastAPI 0.121.1, Neo4j 5.28, Pydantic 2.10 |
| 10 | +- **Frontend:** TypeScript 5.9, React 19.2, Vite 7.2, Tailwind CSS 4.1 |
| 11 | +- **Testing:** pytest 7.4, Vitest 4.0, Playwright 1.56 |
| 12 | +- **Linting:** ruff 0.14.5, mypy 1.15, Biome 2.3 |
| 13 | +- **Package Managers:** uv (Python), npm (Frontend) |
| 14 | +- **Task Runner:** Invoke 2.2.0 |
| 15 | + |
| 16 | +## File Structure |
| 17 | + |
| 18 | +- `backend/` – Python backend (FastAPI, GraphQL, core logic) - see [backend/AGENTS.md](backend/AGENTS.md) |
| 19 | +- `frontend/app/` – React frontend - see [frontend/app/AGENTS.md](frontend/app/AGENTS.md) |
| 20 | +- `docs/` – Docusaurus documentation - see [docs/AGENTS.md](docs/AGENTS.md) |
| 21 | +- `python_sdk/` – Python SDK (Git submodule) |
| 22 | +- `tasks/` – Invoke task definitions |
| 23 | +- `schema/` – JSON/GraphQL schema definitions |
| 24 | +- `changelog/` – Towncrier changelog fragments |
| 25 | + |
| 26 | +## Commands |
| 27 | + |
| 28 | +### Setup |
| 29 | + |
| 30 | +```bash |
| 31 | +uv sync --all-groups # Install Python dependencies |
| 32 | +cd frontend/app && npm install # Install frontend dependencies |
| 33 | +``` |
| 34 | + |
| 35 | +### Testing |
| 36 | + |
| 37 | +```bash |
| 38 | +uv run invoke backend.test-unit # Backend unit tests |
| 39 | +uv run invoke backend.test-integration # Backend integration tests |
| 40 | +cd frontend/app && npm run test # Frontend unit tests |
| 41 | +cd frontend/app && npm run test:e2e # Frontend E2E tests |
| 42 | +``` |
| 43 | + |
| 44 | +### Linting & Formatting |
| 45 | + |
| 46 | +```bash |
| 47 | +uv run invoke format # Format all Python code |
| 48 | +uv run invoke lint # Lint all Python code |
| 49 | +cd frontend/app && npm run biome:fix # Format/lint frontend |
| 50 | +uv run invoke docs.lint # Lint documentation |
| 51 | +``` |
| 52 | + |
| 53 | +### Build |
| 54 | + |
| 55 | +```bash |
| 56 | +uv run invoke dev.build # Build Docker containers |
| 57 | +cd frontend/app && npm run build # Build frontend |
| 58 | +cd docs && npm run build # Build documentation |
| 59 | +``` |
| 60 | + |
| 61 | +## Generated Files (Do Not Edit) |
| 62 | + |
| 63 | +- `backend/infrahub/core/schema/generated/` – Schema definitions |
| 64 | +- `backend/infrahub/core/protocols.py` – Protocol definitions |
| 65 | +- `frontend/app/src/shared/api/graphql/generated/` – GraphQL types |
| 66 | +- `frontend/app/src/shared/api/rest/types.generated.ts` – REST types |
| 67 | + |
| 68 | +Regenerate with: `uv run invoke backend.generate` or `cd frontend/app && npm run codegen` |
| 69 | + |
| 70 | +## Markdown Formatting |
| 71 | + |
| 72 | +When editing markdown files (enforced by markdownlint): |
| 73 | + |
| 74 | +- Use `-` for unordered lists |
| 75 | +- Add blank line before/after headings, code blocks, and lists |
| 76 | +- Use fenced code blocks with language identifier |
| 77 | +- No trailing spaces or multiple consecutive blank lines |
| 78 | +- No bare URLs (use `[text](url)` format) |
| 79 | + |
| 80 | +## Git Workflow |
| 81 | + |
| 82 | +- **Main branches:** `stable` (production), `develop` (development), `release-*` (releases) |
| 83 | +- **Commit messages:** Conventional commits; include issue references |
| 84 | +- **Changelog:** Add fragment to `changelog/` using Towncrier format |
| 85 | + |
| 86 | +## Boundaries |
| 87 | + |
| 88 | +### Always Do |
| 89 | + |
| 90 | +- Run formatters before committing (`uv run invoke format`, `npm run biome:fix`) |
| 91 | +- Write tests for new functionality |
| 92 | +- Use type hints (Python) and TypeScript types (frontend) |
| 93 | + |
| 94 | +### Ask First |
| 95 | + |
| 96 | +- Database schema or migration changes |
| 97 | +- GraphQL schema modifications |
| 98 | +- New dependencies |
| 99 | +- CI/CD workflow changes |
| 100 | +- Authentication/authorization changes |
| 101 | + |
| 102 | +### Never Do |
| 103 | + |
| 104 | +- Commit secrets, API keys, or credentials |
| 105 | +- Edit generated files manually |
| 106 | +- Skip linting in CI |
| 107 | +- Force push to `stable` or `develop` |
0 commit comments