This guide helps coding agents make safe, high-signal changes in this repository.
- Keep API behavior stable unless a task explicitly requests behavior changes.
- Treat generated data schema and runtime query assumptions as coupled contracts.
- Keep PHP and AWS implementations behaviorally aligned unless the user explicitly approves divergence.
- Prefer minimal, targeted edits over broad refactors.
data/: ETL pipeline and SQL import scripts to generate database used by all endpointsphp/: PHP endpoint scriptsaws/: runtime and deployment config for an AWS = Lambda endpointREADME.md: top-level onboarding and documentation index
- Do not change output column names/order in generated CSVs without updating import SQL and runtimes.
- Do not change endpoint paths or required query parameters unless explicitly requested.
- Do not change behavior in only one runtime without checking whether the other runtime must be updated too.
- Treat
README.mdas the canonical API contract for shared endpoint behavior. - Do not add dependencies unless required by the task.
- Do not modify licensing text unless the task is licensing-focused.
cd data && ./generate
sqlite3 data.sqlite < data/import-sqlite.sql # or import-postgres.sql for Postgresnode --check aws/handler.js
bash -n data/generate
php -l php/reverse_geocode.php php/geocode.php php/ip2country.phpRequires data.sqlite placed at aws/data/data.sqlite (see aws/README.md).
cd aws && node test.jsRequires a running PHP server with data.sqlite path configured in each script.
curl "http://localhost:8080/reverse_geocode.php?lat=51.5&lon=-0.09"
curl "http://localhost:8080/geocode.php?q=London"
curl "http://localhost:8080/ip2country.php?ip=8.8.8.8"- Confirm behavior in implementation files first.
- Update
README.mdfirst when the shared API contract changes. - Update runtime-specific docs (
php/README.md,aws/README.md) for setup or runtime-specific differences. - Update root index links if new docs are added.
- Update
data/generate. - Verify expected output files and schema assumptions.
- Update
data/PIPELINE.mdanddata/README.mdfor changed flow. - Ensure PHP and AWS query logic still matches generated formats.
- Check whether the same change must be made in both
php/andaws/. - If the implementations intentionally diverge, document the reason in
README.mdand the runtime-specific README. - Keep parameter validation and error status conventions explicit.
- Keep docs and examples in sync with code in same change.
- Validate one positive and one negative request path per changed endpoint in every affected runtime.
- Update
data/generateand any generated CSV column order/names intentionally. - Update
data/import-sqlite.sqlanddata/import-postgres.sqlto match the new schema. - Update every affected query in
php/andaws/handler.jsbefore considering the change complete. - Update
README.mdif response field names, examples, or shared data-model docs changed. - Validate one positive and one negative request path per affected endpoint in both runtimes.
- For every changed shared endpoint, prepare matching PHP and AWS requests for: valid input, invalid input, and one edge or empty-result case.
- Compare status codes, response field names, JSON structure, and fallback behavior between runtimes.
- If behavior differs intentionally, document the reason in
README.mdand the relevant runtime README. - Do not hand off a shared endpoint change without confirming PHP and AWS still match the documented contract.
- Update the canonical rule in
README.mdfirst when shared validation behavior changes. - Update the matching validation logic in both
php/andaws/handler.js. - Keep error status conventions aligned across runtimes for the same invalid input.
- Validate boundary values and malformed input in both runtimes before handoff.
- Identify whether the change affects search ordering, reverse-geocode candidate selection, or IP lookup behavior.
- Update the equivalent logic in both
php/andaws/handler.jsunless the user explicitly approves divergence. - Update
README.mdif the visible behavior, ranking rules, or fallback rules changed. - Validate with the same dataset and inputs in both runtimes, checking result ordering as well as response shape.
- Add a new top-level folder for the endpoint.
- Ensure behaviour of the new endpoint is consistent with other endpoint implementations.
- Keep docs and examples in sync with code in same change.
- Don't change runtime behaviour at the same time as adding a new endpoint.
- Validate one positive and one negative request path for the new endpoint.
- Relevant docs updated in same PR/change set.
- Shared API behavior in
README.mdstill matches all implementations. - PHP and AWS behavior were compared for every changed shared endpoint.
- All links in edited markdown files resolve.
- Any changed command examples are runnable as written.
- Endpoint parameter and response docs match actual runtime behavior.
- No unrelated files changed.
A docs task is done when:
- Root README links users to all relevant subsystem docs.
- A new contributor can build data and run at least one runtime without guessing missing steps.
- Agent guidance reflects current repo structure and workflows.