AGENTS.md
Coding Agent Guidelines
Scope
This file is for coding agents working in this repository. Prefer concrete, verifiable commands over assumptions.
Project Structure
netflow-webapp/: SvelteKit frontend and API routes.netflow-webapp/src/routes: Pages and route-level loaders.netflow-webapp/src/routes/api: HTTP endpoints and file-detail utilities.netflow-webapp/src/lib: Shared UI, stores, helpers, and common types (src/lib/types/types.ts).netflow-db/: Python data ingestion/aggregation scripts, logs, and SQLite database files.maad/: Haskell MAAD tooling (nix-shell+./compile.shwhen MAAD binaries are needed).burstify/: Zig MAAD tooling.
Backend Pipeline Notes
netflow-db/flow_db.pynetflow-db/ip_db.pynetflow-db/protocol_db.pynetflow-db/spectrum_db.pynetflow-db/structure_db.pynetflow-db/discovery.pynetflow-db/pipeline.py
Git
Use Graphite to draft and create PRs:
| 1 | # Create a branch with a single commit |
| 2 | # - the --all flag will stage any modified files |
| 3 | # - a branch will be created from the given `--message` |
| 4 | # - the commit will have the given `--message` |
| 5 | # - the branch will be checked out for you |
| 6 | gt create --all --message "feat(api): Add new API method for fetching users" |
| 7 | |
| 8 | # Push changes to your remote and create a new pull request |
| 9 | gt submit |
| 10 | |
| 11 | |
| 12 | # If you need to make any follow up changes to the PR, you can |
| 13 | # amend the existing commit with gt modify |
| 14 | echo "some more changes" >> file.js |
| 15 | gt modify --all |
| 16 | |
| 17 | |
| 18 | # Submit new changes |
| 19 | gt submit |
See gt --help for more.
Keep large generated artifacts out of git (SQLite DB/WAL/SHM files, captures, compiled binaries).
Key Endpoints
Core routes commonly used by the frontend:
/api/netflow/stats/api/netflow/files/[slug]/api/netflow/files/[slug]/structure-function
Other utility routes exist for protocol, IP, spectrum, singularities, and router metadata. Discover the full set in netflow-webapp/src/routes/api.
Commands
Frontend (netflow-webapp/):
| 1 | npm install |
| 2 | npm run build |
| 3 | npm run check |
| 4 | npm run lint |
| 5 | npm run format |
| 6 | npm run validate |
Do not start npm run dev or npm run preview unless the user explicitly asks. Assume a dev server may already be running.
Backend (netflow-db/) validation:
| 1 | python -m py_compile *.py |
Run backend compile checks after backend Python edits and before handing off work.
Style Conventions
- Frontend: TypeScript + Svelte, 2-space indent, PascalCase components, shared types in
src/lib/types/types.ts. - Python: 4-space indent, snake_case, prefer
pathlib.Pathand environment-driven config. - Keep comments short and only where logic is non-obvious.
Testing Expectations
- Frontend changes: run
npm run validateinnetflow-webapp/. - Backend changes: run
python -m py_compile *.pyinnetflow-db/. - Add or update route-level smoke coverage when introducing new pages or endpoints.
Environment & Data
Expected .env keys include:
NETFLOW_DATA_PATHAVAILABLE_ROUTERSDATABASE_PATHLOG_PATHFIRST_RUN
Router identities are environment-configured and must not be hardcoded in documentation or logic assumptions. Use YYYY-MM-DD HH:mm:ss for timestamp formatting.
Cursor Cloud specific instructions
Services overview
| Service | Directory | How to run |
|---|---|---|
| SvelteKit webapp | netflow-webapp/ | npm run dev (port 5173) |
| Python pipeline | netflow-db/ | python pipeline.py (batch job, not a server) |
Configuration files
The webapp requires two files in the repo root (both gitignored):
.env— copy from.env.exampleand adjust. The webapp reads it viaenv.dir: '..'insvelte.config.js.datasets.json— copy fromdatasets.json.exampleand update paths. Each dataset needs adb_pathpointing to an existing SQLite file.
Running the dev server
| 1 | cd netflow-webapp && npm run dev -- --host 0.0.0.0 |
The dev server loads datasets.json from the repo root. If the file is missing or a referenced db_path does not exist, API routes will return 500 errors.
Python backend
The Python backend (netflow-db/) uses only stdlib modules plus hll. It requires python3-dev for building hll. The pipeline (python pipeline.py) also requires nfdump CLI to read binary nfcapd files — this is not needed for the webapp alone.
Gotchas
better-sqlite3is a native C++ addon; if Node.js is upgraded, runnpm rebuildinnetflow-webapp/.- The webapp resolves the repo root as
path.resolve(process.cwd(), '..')from insidenetflow-webapp/, so always start the dev server fromnetflow-webapp/. - Sample data only exists if a database has been created. Without real nfcapd files, create a SQLite DB manually matching the schemas in
netflow-db/flow_db.py,ip_db.py,protocol_db.py,spectrum_db.py, andstructure_db.py.