commit f0b3dc4e1373c6696ec00d1b459e63d0393d04fb Author: admin Date: Wed Apr 8 14:30:50 2026 +0200 base: project structure and configuration diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9751b4f --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Binarios +*.exe +*.dll +*.so +*.dylib +verifactu-api.exe + +# Build +/build/ +/dist/ + +# Go +*.test +coverage.txt + +# IDE +.idea/ +.vscode/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# Configuración sensible +.env +.env.local +config.local.yml + +# Certificados y claves +certs/ +keys/ +*.p12 +*.pem +*.key + +# Documentación (no incluir en el repo) +Documentacion de Verifactu/ + +# Logs +*.log diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..65395fc --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,47 @@ +# 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 \ No newline at end of file diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..3983f60 --- /dev/null +++ b/config.yml @@ -0,0 +1,11 @@ +server: + port: 6789 + +verifactu: + environment: test + +certificates: + storage_path: ./certs/ + +crypto: + keys_path: ./keys/ diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..01159a4 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module VerifactuMidAPI + +go 1.26 + +require gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..4bc0337 --- /dev/null +++ b/go.sum @@ -0,0 +1,3 @@ +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=