# AGENTS.md

## Project
- Go 1.26.1
- No external dependencies yet
- Entry point: `main.go`

## Architecture
```
proyecto/
├── api/          → HTTP exposure, endpoints, routing
├── internal/     → business logic, validation, normalization
└── verifactu/    → AEAT communication, XML, signing, crypto chaining
```

## VeriFactu Protocol
- **Transport:** SOAP 1.1 / HTTPS
- **Format:** XML (UTF-8), document/literal
- **Auth:** Qualified electronic certificate (.p12)
- **Hash:** SHA-256, hex uppercase, chained with previous record
- **Max records per request:** 1,000
- **Environments:** Testing (sandbox) / Production
- **Current:** Testing only
- **Config:** Change via config file or env var (not code)
- **PDF generation:** Handled by Dolibarr (not this API's responsibility)

## VeriFactu Documentation
See `Documentacion de Verifactu/` folder:
- `01_que_es_verifactu.md` - Overview, legal framework
- `02_como_funciona.md` - Flow, operations, responses
- `03_entornos_y_urls.md` - URLs for test/prod, XSD, WSDL
- `04_encadenamiento_hash.md` - Crypto chaining, hash calculation
- `05_estructura_xml.md` - XML structure, fields
- `06_operaciones.md` - Alta, anulación, subsanación
- `07_consultas.md` - Query sent records
- `08_errores_y_respuestas.md` - Error codes
- `09_control_de_flujo.md` - Rate limits
- `10_pasar_a_produccion.md` - Prod migration steps

## Dependencies
- Use Go modules (`go.mod`), no vendoring

## Pending Decisions (to discuss)
- Exact input JSON format
- Authentication mechanism
- Persistence (database, file, etc.)
- Documentation language