# snaven10/gofirmadordte-sv architecture

> Architecture diagram of the GitHub repository snaven10/gofirmadordte-sv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/snaven10/gofirmadordte-sv
- Repository: https://github.com/snaven10/gofirmadordte-sv

## Overview

Firmador is a Go HTTP service for signing El Salvador electronic tax documents (DTEs). A client submits a document, NIT, and password; the handler loads that NIT’s certificate file, validates the password, decodes and checks its RSA private key, serializes the DTE JSON, and returns a compact JWS or an error response. Signing and response construction are separate internal layers. The sampled source shows these calls; certificate files and clients are external to the repository.

Main entry points: [`main.go`](https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go) (Signing handler), [`response/response.go`](https://github.com/snaven10/gofirmadordte-sv/blob/main/response/response.go) (Response builder), [`models/certificado.go`](https://github.com/snaven10/gofirmadordte-sv/blob/main/models/certificado.go) (Request model), [`models/CertificadoMH.go`](https://github.com/snaven10/gofirmadordte-sv/blob/main/models/CertificadoMH.go) (Certificate model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["HTTP server<br/>[main.go]"]
  node_handler["Signing handler<br/>[main.go]"]
  node_filter["Request model<br/>[certificado.go]"]
  node_response["Response builder<br/>[response.go]"]
end

subgraph group_credentials["Credentials"]
  node_certfile[("Certificate file")]
  node_certloader["Certificate loader<br/>[main.go]"]
  node_certmodel["Certificate model<br/>[CertificadoMH.go]"]
  node_password["Password validation<br/>[main.go]"]
end

subgraph group_signing["Signing"]
  node_signer["Signing coordinator<br/>[main.go]"]
  node_keyparser["RSA key parser<br/>[keyprocessing.go]"]
  node_jws["JWS signer<br/>[jwsutils.go]"]
end

node_client(("DTE client"))

node_client -->|"submits request"| node_server
node_server -->|"routes POST"| node_handler
node_handler -->|"binds JSON"| node_filter
node_handler -->|"loads certificate"| node_certloader
node_certloader -->|"reads file"| node_certfile
node_certloader -->|"parses XML"| node_certmodel
node_handler -->|"checks password"| node_password
node_handler -->|"signs DTE"| node_signer
node_signer -->|"parses private key"| node_keyparser
node_signer -->|"creates JWS"| node_jws
node_handler -->|"builds response"| node_response
node_response -->|"returns result"| node_client

click node_server "https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go"
click node_handler "https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go"
click node_filter "https://github.com/snaven10/gofirmadordte-sv/blob/main/models/certificado.go"
click node_response "https://github.com/snaven10/gofirmadordte-sv/blob/main/response/response.go"
click node_certloader "https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go"
click node_certmodel "https://github.com/snaven10/gofirmadordte-sv/blob/main/models/CertificadoMH.go"
click node_password "https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go"
click node_signer "https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go"
click node_keyparser "https://github.com/snaven10/gofirmadordte-sv/blob/main/keyprocessing/keyprocessing.go"
click node_jws "https://github.com/snaven10/gofirmadordte-sv/blob/main/jwsutils/jwsutils.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_handler,node_filter,node_response,node_client toneBlue
class node_certfile,node_certloader,node_certmodel,node_password toneAmber
class node_signer,node_keyparser,node_jws toneMint
```

## Components

### HTTP API

- [HTTP server](https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go): `main.go`
- [Signing handler](https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go): `main.go`
- [Request model](https://github.com/snaven10/gofirmadordte-sv/blob/main/models/certificado.go): `models/certificado.go`
- [Response builder](https://github.com/snaven10/gofirmadordte-sv/blob/main/response/response.go): `response/response.go`

### Credentials

- **Certificate file**
- [Certificate loader](https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go): `main.go`
- [Certificate model](https://github.com/snaven10/gofirmadordte-sv/blob/main/models/CertificadoMH.go): `models/CertificadoMH.go`
- [Password validation](https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go): `main.go`

### Signing

- [Signing coordinator](https://github.com/snaven10/gofirmadordte-sv/blob/main/main.go): `main.go`
- [RSA key parser](https://github.com/snaven10/gofirmadordte-sv/blob/main/keyprocessing/keyprocessing.go): `keyprocessing/keyprocessing.go`
- [JWS signer](https://github.com/snaven10/gofirmadordte-sv/blob/main/jwsutils/jwsutils.go): `jwsutils/jwsutils.go`

### Other components

- **DTE client**

## Connections

- DTE client → HTTP server: submits request (evidence: `main.go`)
- HTTP server → Signing handler: routes POST (evidence: `main.go`)
- Signing handler → Request model: binds JSON (evidence: `main.go`)
- Signing handler → Certificate loader: loads certificate (evidence: `main.go`)
- Certificate loader → Certificate file: reads file (evidence: `main.go`)
- Certificate loader → Certificate model: parses XML (evidence: `main.go`)
- Signing handler → Password validation: checks password (evidence: `main.go`)
- Signing handler → Signing coordinator: signs DTE (evidence: `main.go`)
- Signing coordinator → RSA key parser: parses private key (evidence: `main.go`)
- Signing coordinator → JWS signer: creates JWS (evidence: `main.go`)
- Signing handler → Response builder: builds response (evidence: `main.go`)
- Response builder → DTE client: returns result
