# ajayxr/pandaapi architecture

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

- Interactive diagram: https://gitdiagram.com/ajayxr/pandaapi
- Repository: https://github.com/ajayxr/pandaapi

## Overview

PandaAPI is an ASP.NET Core REST API for Brazilian document workflows. Its main paths are CPF/CNPJ validation (including CSV/XLSX batch validation), CNPJ lookup and PDF reporting, and account registration or login that returns JWTs. It also generates document numbers and exposes health checks. The graph includes the database and the external CNPJ data provider. Relationships reflect shown calls and README capabilities; unsampled controllers and runtime wiring are represented only where the source index or README supports them.

Main entry points: [`PandaAPI/Program.cs`](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Program.cs) (ASP.NET runtime), [`PandaAPI/Controllers/GetCnpjController.cs`](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/GetCnpjController.cs) (CNPJ lookup endpoints), [`PandaAPI/Services/AuthService.cs`](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/AuthService.cs) (Account and JWT service), [`PandaAPI/Services/CnpjValidator.cs`](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/CnpjValidator.cs) (CNPJ validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_runtime["ASP.NET runtime<br/>[Program.cs]"]
  node_validation_api["Validation endpoints"]
  node_batch_api["CPF batch endpoint"]
  node_generate_api["Document generation endpoint"]
  node_cnpj_api["CNPJ lookup endpoints"]
  node_auth_api["Authentication endpoints<br/>[AuthController.cs]"]
  node_health_api["Health endpoints"]
end

subgraph group_documents["Document services"]
  node_cpf_validator["CPF validation<br/>[CpfValidator.cs]"]
  node_cnpj_validator["CNPJ validation<br/>[CnpjValidator.cs]"]
  node_batch_service["Batch file processing"]
  node_cnpj_lookup["CNPJ data lookup<br/>[GetCnpjService.cs]"]
  node_pdf_report["PDF report generation<br/>[CnpjPdfService.cs]"]
end

subgraph group_identity["Identity and storage"]
  node_auth_contract["Authentication contract<br/>[IAuthService.cs]"]
  node_auth_service["Account and JWT service<br/>[AuthService.cs]"]
  node_user_store[("User database<br/>[AppDbContext.cs]")]
  node_auth_models["User and auth DTOs"]
  node_auth_config["JWT and provider options"]
end

subgraph group_operations["Health and integrations"]
  node_db_check["Database health check"]
  node_cnpj_provider["cnpj.ai provider"]
end

node_caller(("API consumer"))

node_caller -->|"sends requests"| node_runtime
node_runtime -->|"routes requests"| node_validation_api
node_runtime -->|"routes requests"| node_batch_api
node_runtime -->|"routes requests"| node_generate_api
node_runtime -->|"routes requests"| node_cnpj_api
node_runtime -->|"routes requests"| node_auth_api
node_runtime -->|"routes requests"| node_health_api
node_validation_api -->|"validates CPF"| node_cpf_validator
node_validation_api -->|"validates CNPJ"| node_cnpj_validator
node_batch_api -->|"processes upload"| node_batch_service
node_batch_service -->|"checks records"| node_cpf_validator
node_generate_api -->|"generates CPF"| node_cpf_validator
node_generate_api -->|"generates CNPJ"| node_cnpj_validator
node_cnpj_api -->|"checks CNPJ"| node_cnpj_validator
node_cnpj_api -->|"fetches company data"| node_cnpj_lookup
node_cnpj_api -->|"builds report"| node_pdf_report
node_pdf_report -->|"formats CNPJ"| node_cnpj_validator
node_auth_api -->|"calls auth operations"| node_auth_contract
node_runtime -->|"registers implementation"| node_auth_service
node_auth_service -->|"reads and writes users"| node_user_store
node_auth_service -->|"uses user and DTO types"| node_auth_models
node_auth_service -->|"reads JWT options"| node_auth_config
node_runtime -->|"configures JWT"| node_auth_config
node_runtime -->|"registers readiness check"| node_db_check
node_db_check -->|"checks connectivity"| node_user_store
node_cnpj_lookup -->|"requests company data"| node_cnpj_provider

click node_runtime "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Program.cs"
click node_validation_api "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/ValidationController.cs"
click node_batch_api "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/CpfBatchValidationController.cs"
click node_generate_api "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/GenerateController.cs"
click node_cnpj_api "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/GetCnpjController.cs"
click node_auth_api "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/AuthController.cs"
click node_health_api "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/HealthController.cs"
click node_cpf_validator "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/CpfValidator.cs"
click node_cnpj_validator "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/CnpjValidator.cs"
click node_batch_service "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/CpfBatchValidationService.cs"
click node_cnpj_lookup "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/GetCnpjService.cs"
click node_pdf_report "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/CnpjPdfService.cs"
click node_auth_contract "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Interfaces/IAuthService.cs"
click node_auth_service "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/AuthService.cs"
click node_user_store "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Data/AppDbContext.cs"
click node_auth_models "https://github.com/ajayxr/pandaapi/tree/master/PandaAPI/Models"
click node_auth_config "https://github.com/ajayxr/pandaapi/tree/master/PandaAPI/Configuration"
click node_db_check "https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/HealthChecks/DatabaseHealthCheck.cs"

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_runtime,node_validation_api,node_batch_api,node_generate_api,node_cnpj_api,node_auth_api,node_health_api toneBlue
class node_cpf_validator,node_cnpj_validator,node_batch_service,node_cnpj_lookup,node_pdf_report toneAmber
class node_auth_contract,node_auth_service,node_user_store,node_auth_models,node_auth_config,node_caller toneMint
class node_db_check,node_cnpj_provider toneRose
```

## Components

### API and access

- [ASP.NET runtime](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Program.cs): `PandaAPI/Program.cs`
- [Validation endpoints](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/ValidationController.cs): `PandaAPI/Controllers/ValidationController.cs`
- [CPF batch endpoint](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/CpfBatchValidationController.cs): `PandaAPI/Controllers/CpfBatchValidationController.cs`
- [Document generation endpoint](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/GenerateController.cs): `PandaAPI/Controllers/GenerateController.cs`
- [CNPJ lookup endpoints](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/GetCnpjController.cs): `PandaAPI/Controllers/GetCnpjController.cs`
- [Authentication endpoints](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/AuthController.cs): `PandaAPI/Controllers/AuthController.cs`
- [Health endpoints](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Controllers/HealthController.cs): `PandaAPI/Controllers/HealthController.cs`

### Document services

- [CPF validation](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/CpfValidator.cs): `PandaAPI/Services/CpfValidator.cs`
- [CNPJ validation](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/CnpjValidator.cs): `PandaAPI/Services/CnpjValidator.cs`
- [Batch file processing](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/CpfBatchValidationService.cs): `PandaAPI/Services/CpfBatchValidationService.cs`
- [CNPJ data lookup](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/GetCnpjService.cs): `PandaAPI/Services/GetCnpjService.cs`
- [PDF report generation](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/CnpjPdfService.cs): `PandaAPI/Services/CnpjPdfService.cs`

### Identity and storage

- [Authentication contract](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Interfaces/IAuthService.cs): `PandaAPI/Interfaces/IAuthService.cs`
- [Account and JWT service](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Services/AuthService.cs): `PandaAPI/Services/AuthService.cs`
- [User database](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/Data/AppDbContext.cs): `PandaAPI/Data/AppDbContext.cs`
- [User and auth DTOs](https://github.com/ajayxr/pandaapi/tree/master/PandaAPI/Models): `PandaAPI/Models`
- [JWT and provider options](https://github.com/ajayxr/pandaapi/tree/master/PandaAPI/Configuration): `PandaAPI/Configuration`

### Health and integrations

- [Database health check](https://github.com/ajayxr/pandaapi/blob/master/PandaAPI/HealthChecks/DatabaseHealthCheck.cs): `PandaAPI/HealthChecks/DatabaseHealthCheck.cs`
- **cnpj.ai provider**

### Other components

- **API consumer**

## Connections

- API consumer → ASP.NET runtime: sends requests (evidence: `PandaAPI/Program.cs`)
- ASP.NET runtime → Validation endpoints: routes requests (evidence: `PandaAPI/Program.cs`)
- ASP.NET runtime → CPF batch endpoint: routes requests (evidence: `PandaAPI/Program.cs`)
- ASP.NET runtime → Document generation endpoint: routes requests (evidence: `PandaAPI/Program.cs`)
- ASP.NET runtime → CNPJ lookup endpoints: routes requests (evidence: `PandaAPI/Program.cs`)
- ASP.NET runtime → Authentication endpoints: routes requests (evidence: `PandaAPI/Program.cs`)
- ASP.NET runtime → Health endpoints: routes requests (evidence: `PandaAPI/Program.cs`)
- Validation endpoints → CPF validation: validates CPF (evidence: `PandaAPI/Controllers/ValidationController.cs`)
- Validation endpoints → CNPJ validation: validates CNPJ (evidence: `PandaAPI/Controllers/ValidationController.cs`)
- CPF batch endpoint → Batch file processing: processes upload (evidence: `PandaAPI/Controllers/CpfBatchValidationController.cs`)
- Batch file processing → CPF validation: checks records (evidence: `PandaAPI/Services/CpfBatchValidationService.cs`)
- Document generation endpoint → CPF validation: generates CPF (evidence: `PandaAPI/Controllers/GenerateController.cs`)
- Document generation endpoint → CNPJ validation: generates CNPJ (evidence: `PandaAPI/Controllers/GenerateController.cs`)
- CNPJ lookup endpoints → CNPJ validation: checks CNPJ (evidence: `PandaAPI/Controllers/GetCnpjController.cs`)
- CNPJ lookup endpoints → CNPJ data lookup: fetches company data (evidence: `PandaAPI/Controllers/GetCnpjController.cs`)
- CNPJ lookup endpoints → PDF report generation: builds report (evidence: `PandaAPI/Controllers/GetCnpjController.cs`)
- PDF report generation → CNPJ validation: formats CNPJ (evidence: `PandaAPI/Services/CnpjPdfService.cs`)
- Authentication endpoints → Authentication contract: calls auth operations (evidence: `PandaAPI/Controllers/AuthController.cs`)
- ASP.NET runtime → Account and JWT service: registers implementation (evidence: `PandaAPI/Program.cs`)
- Account and JWT service → User database: reads and writes users (evidence: `PandaAPI/Services/AuthService.cs`)
- Account and JWT service → User and auth DTOs: uses user and DTO types (evidence: `PandaAPI/Services/AuthService.cs`)
- Account and JWT service → JWT and provider options: reads JWT options (evidence: `PandaAPI/Services/AuthService.cs`)
- ASP.NET runtime → JWT and provider options: configures JWT (evidence: `PandaAPI/Program.cs`)
- ASP.NET runtime → Database health check: registers readiness check (evidence: `PandaAPI/Program.cs`)
- Database health check → User database: checks connectivity (evidence: `PandaAPI/HealthChecks/DatabaseHealthCheck.cs`)
- CNPJ data lookup → cnpj.ai provider: requests company data (evidence: `PandaAPI/Services/GetCnpjService.cs`)
