# jrdandp/backendtest architecture

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

- Interactive diagram: https://gitdiagram.com/jrdandp/backendtest
- Repository: https://github.com/jrdandp/backendtest

## Overview

This is a FastAPI backend for automating Scordsoft cobros and service-order reports. Its main workflow accepts a request, validates date inputs, authenticates and downloads a report, then normalizes it; the order workflow can additionally synchronize orders and assignments to PostgreSQL. Separate capabilities include normalizing an existing cobros file and checking service/database health. The README documents the layered architecture; source-index references and excerpts support the shown calls. Unsampled endpoint and utility details are represented only where documented or indexed.

Main entry points: [`app/services/automation_service.py`](https://github.com/jrdandp/backendtest/blob/main/app/services/automation_service.py) (Automation service), [`app/infrastructure/scrapper_client.py`](https://github.com/jrdandp/backendtest/blob/main/app/infrastructure/scrapper_client.py) (Scrapper adapter), [`Scrapper/registroCobros.py`](https://github.com/jrdandp/backendtest/blob/main/Scrapper/registroCobros.py) (Cobros download), [`Scrapper/ordenes.py`](https://github.com/jrdandp/backendtest/blob/main/Scrapper/ordenes.py) (Orders download)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_routes["API v1 routes<br/>[api.py]"]
  node_automation_ep["Automation endpoints<br/>[automation.py]"]
  node_health_ep["Health endpoint<br/>[health.py]"]
  node_deps["Dependency injection<br/>[deps.py]"]
  node_schemas["Automation DTOs<br/>[automation.py]"]
  node_common_schema["Response DTOs<br/>[common.py]"]
end

subgraph group_usecases["Automation Use Cases"]
  node_service["Automation service"]
  node_dates["Date validation<br/>[utilsDate.py]"]
  node_cobros_normalizer["Cobros normalizer<br/>[dataNormalizer.py]"]
  node_normalizer_helpers["Normalization helpers<br/>[utilsNormalizer.py]"]
  node_orders_normalizer["Orders normalizer"]
end

subgraph group_scraping["Scordsoft Automation"]
  node_client["Scrapper adapter<br/>[scrapper_client.py]"]
  node_login["Portal login<br/>[login.py]"]
  node_cobros_scraper["Cobros download<br/>[registroCobros.py]"]
  node_orders_scraper["Orders download<br/>[ordenes.py]"]
  node_scraper_helpers["Scraper helpers<br/>[utilsScrapper.py]"]
  node_file_helpers["File utilities<br/>[utilsFiles.py]"]
end

subgraph group_data["Order Data"]
  node_repository["Order repository"]
  node_base_repo["Base repository<br/>[base.py]"]
  node_order_model["Order entities<br/>[orden.py]"]
  node_database[("PostgreSQL<br/>[database.py]")]
end

node_user(("API caller"))
node_portal(("Scordsoft portal"))
node_file_output["Report files"]

node_user -->|"sends request"| node_fastapi
node_fastapi -->|"mounts routes"| node_routes
node_routes -->|"registers"| node_automation_ep
node_routes -->|"registers"| node_health_ep
node_automation_ep -->|"invokes"| node_service
node_automation_ep -->|"gets dependencies"| node_deps
node_automation_ep -->|"validates and returns"| node_schemas
node_health_ep -->|"checks connection"| node_database
node_health_ep -->|"returns response"| node_common_schema
node_deps -->|"provides session"| node_database
node_deps -->|"provides service"| node_service
node_service -->|"validates dates"| node_dates
node_service -->|"orchestrates reports"| node_client
node_service -->|"normalizes orders"| node_orders_normalizer
node_service -->|"syncs orders"| node_repository
node_client -->|"authenticates"| node_login
node_client -->|"downloads cobros"| node_cobros_scraper
node_client -->|"downloads orders"| node_orders_scraper
node_client -->|"normalizes cobros"| node_cobros_normalizer
node_login -->|"authenticates with"| node_portal
node_cobros_scraper -->|"requests report"| node_portal
node_orders_scraper -->|"requests report"| node_portal
node_login -->|"extracts form tokens"| node_scraper_helpers
node_cobros_scraper -->|"extracts form values"| node_scraper_helpers
node_orders_scraper -->|"extracts form values"| node_scraper_helpers
node_cobros_scraper -->|"creates output directory"| node_file_helpers
node_orders_scraper -->|"creates output directories"| node_file_helpers
node_cobros_normalizer -->|"uses"| node_normalizer_helpers
node_repository -->|"extends"| node_base_repo
node_repository -->|"upserts entities"| node_order_model
node_repository -->|"commits changes"| node_database
node_login -.->|"returns session"| node_file_output
node_cobros_scraper -->|"writes report"| node_file_output
node_orders_scraper -->|"writes report"| node_file_output
node_cobros_normalizer -.->|"writes normalized file"| node_file_output
node_orders_normalizer -.->|"writes normalized file"| node_file_output

click node_fastapi "https://github.com/jrdandp/backendtest/blob/main/app/main.py"
click node_routes "https://github.com/jrdandp/backendtest/blob/main/app/api/v1/api.py"
click node_automation_ep "https://github.com/jrdandp/backendtest/blob/main/app/api/v1/endpoints/automation.py"
click node_health_ep "https://github.com/jrdandp/backendtest/blob/main/app/api/v1/endpoints/health.py"
click node_deps "https://github.com/jrdandp/backendtest/blob/main/app/api/deps.py"
click node_schemas "https://github.com/jrdandp/backendtest/blob/main/app/schemas/automation.py"
click node_common_schema "https://github.com/jrdandp/backendtest/blob/main/app/schemas/common.py"
click node_service "https://github.com/jrdandp/backendtest/blob/main/app/services/automation_service.py"
click node_dates "https://github.com/jrdandp/backendtest/blob/main/Utils/utilsDate.py"
click node_client "https://github.com/jrdandp/backendtest/blob/main/app/infrastructure/scrapper_client.py"
click node_login "https://github.com/jrdandp/backendtest/blob/main/Scrapper/login.py"
click node_cobros_scraper "https://github.com/jrdandp/backendtest/blob/main/Scrapper/registroCobros.py"
click node_orders_scraper "https://github.com/jrdandp/backendtest/blob/main/Scrapper/ordenes.py"
click node_scraper_helpers "https://github.com/jrdandp/backendtest/blob/main/Utils/utilsScrapper.py"
click node_file_helpers "https://github.com/jrdandp/backendtest/blob/main/Utils/utilsFiles.py"
click node_cobros_normalizer "https://github.com/jrdandp/backendtest/blob/main/dataNormalizer.py"
click node_normalizer_helpers "https://github.com/jrdandp/backendtest/blob/main/Utils/utilsNormalizer.py"
click node_orders_normalizer "https://github.com/jrdandp/backendtest/blob/main/ordenesNormalizer.py"
click node_repository "https://github.com/jrdandp/backendtest/blob/main/app/repositories/orden_repository.py"
click node_base_repo "https://github.com/jrdandp/backendtest/blob/main/app/repositories/base.py"
click node_order_model "https://github.com/jrdandp/backendtest/blob/main/app/models/orden.py"
click node_database "https://github.com/jrdandp/backendtest/blob/main/app/core/database.py"

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_fastapi,node_routes,node_automation_ep,node_health_ep,node_deps,node_schemas,node_common_schema toneBlue
class node_service,node_dates,node_cobros_normalizer,node_normalizer_helpers,node_orders_normalizer toneAmber
class node_client,node_login,node_cobros_scraper,node_orders_scraper,node_scraper_helpers,node_file_helpers,node_user toneMint
class node_repository,node_base_repo,node_order_model,node_database toneRose
class node_portal,node_file_output toneIndigo
```

## Components

### HTTP API

- [FastAPI app](https://github.com/jrdandp/backendtest/blob/main/app/main.py): `app/main.py`
- [API v1 routes](https://github.com/jrdandp/backendtest/blob/main/app/api/v1/api.py): `app/api/v1/api.py`
- [Automation endpoints](https://github.com/jrdandp/backendtest/blob/main/app/api/v1/endpoints/automation.py): `app/api/v1/endpoints/automation.py`
- [Health endpoint](https://github.com/jrdandp/backendtest/blob/main/app/api/v1/endpoints/health.py): `app/api/v1/endpoints/health.py`
- [Dependency injection](https://github.com/jrdandp/backendtest/blob/main/app/api/deps.py): `app/api/deps.py`
- [Automation DTOs](https://github.com/jrdandp/backendtest/blob/main/app/schemas/automation.py): `app/schemas/automation.py`
- [Response DTOs](https://github.com/jrdandp/backendtest/blob/main/app/schemas/common.py): `app/schemas/common.py`

### Automation Use Cases

- [Automation service](https://github.com/jrdandp/backendtest/blob/main/app/services/automation_service.py): `app/services/automation_service.py`
- [Date validation](https://github.com/jrdandp/backendtest/blob/main/Utils/utilsDate.py): `Utils/utilsDate.py`
- [Cobros normalizer](https://github.com/jrdandp/backendtest/blob/main/dataNormalizer.py): `dataNormalizer.py`
- [Normalization helpers](https://github.com/jrdandp/backendtest/blob/main/Utils/utilsNormalizer.py): `Utils/utilsNormalizer.py`
- [Orders normalizer](https://github.com/jrdandp/backendtest/blob/main/ordenesNormalizer.py): `ordenesNormalizer.py`

### Scordsoft Automation

- [Scrapper adapter](https://github.com/jrdandp/backendtest/blob/main/app/infrastructure/scrapper_client.py): `app/infrastructure/scrapper_client.py`
- [Portal login](https://github.com/jrdandp/backendtest/blob/main/Scrapper/login.py): `Scrapper/login.py`
- [Cobros download](https://github.com/jrdandp/backendtest/blob/main/Scrapper/registroCobros.py): `Scrapper/registroCobros.py`
- [Orders download](https://github.com/jrdandp/backendtest/blob/main/Scrapper/ordenes.py): `Scrapper/ordenes.py`
- [Scraper helpers](https://github.com/jrdandp/backendtest/blob/main/Utils/utilsScrapper.py): `Utils/utilsScrapper.py`
- [File utilities](https://github.com/jrdandp/backendtest/blob/main/Utils/utilsFiles.py): `Utils/utilsFiles.py`

### Order Data

- [Order repository](https://github.com/jrdandp/backendtest/blob/main/app/repositories/orden_repository.py): `app/repositories/orden_repository.py`
- [Base repository](https://github.com/jrdandp/backendtest/blob/main/app/repositories/base.py): `app/repositories/base.py`
- [Order entities](https://github.com/jrdandp/backendtest/blob/main/app/models/orden.py): `app/models/orden.py`
- [PostgreSQL](https://github.com/jrdandp/backendtest/blob/main/app/core/database.py): `app/core/database.py`

### Other components

- **API caller**
- **Scordsoft portal**
- **Report files**

## Connections

- API caller → FastAPI app: sends request (evidence: `README.md`)
- FastAPI app → API v1 routes: mounts routes (evidence: `app/main.py`)
- API v1 routes → Automation endpoints: registers (evidence: `app/api/v1/api.py`)
- API v1 routes → Health endpoint: registers (evidence: `app/api/v1/api.py`)
- Automation endpoints → Automation service: invokes (evidence: `app/api/v1/endpoints/automation.py`)
- Automation endpoints → Dependency injection: gets dependencies (evidence: `app/api/v1/endpoints/automation.py`)
- Automation endpoints → Automation DTOs: validates and returns (evidence: `app/api/v1/endpoints/automation.py`)
- Health endpoint → PostgreSQL: checks connection (evidence: `app/api/v1/endpoints/health.py`)
- Health endpoint → Response DTOs: returns response (evidence: `app/api/v1/endpoints/health.py`)
- Dependency injection → PostgreSQL: provides session (evidence: `app/api/deps.py`)
- Dependency injection → Automation service: provides service (evidence: `app/api/deps.py`)
- Automation service → Date validation: validates dates (evidence: `app/services/automation_service.py`)
- Automation service → Scrapper adapter: orchestrates reports (evidence: `app/services/automation_service.py`)
- Automation service → Orders normalizer: normalizes orders (evidence: `app/services/automation_service.py`)
- Automation service → Order repository: syncs orders (evidence: `app/services/automation_service.py`)
- Scrapper adapter → Portal login: authenticates (evidence: `app/infrastructure/scrapper_client.py`)
- Scrapper adapter → Cobros download: downloads cobros (evidence: `app/infrastructure/scrapper_client.py`)
- Scrapper adapter → Orders download: downloads orders (evidence: `app/infrastructure/scrapper_client.py`)
- Scrapper adapter → Cobros normalizer: normalizes cobros (evidence: `app/infrastructure/scrapper_client.py`)
- Portal login → Scordsoft portal: authenticates with (evidence: `Scrapper/login.py`)
- Cobros download → Scordsoft portal: requests report (evidence: `Scrapper/registroCobros.py`)
- Orders download → Scordsoft portal: requests report (evidence: `Scrapper/ordenes.py`)
- Portal login → Scraper helpers: extracts form tokens (evidence: `Scrapper/login.py`)
- Cobros download → Scraper helpers: extracts form values (evidence: `Scrapper/registroCobros.py`)
- Orders download → Scraper helpers: extracts form values (evidence: `Scrapper/ordenes.py`)
- Cobros download → File utilities: creates output directory (evidence: `Scrapper/registroCobros.py`)
- Orders download → File utilities: creates output directories (evidence: `Scrapper/ordenes.py`)
- Cobros normalizer → Normalization helpers: uses (evidence: `dataNormalizer.py`)
- Order repository → Base repository: extends (evidence: `app/repositories/orden_repository.py`)
- Order repository → Order entities: upserts entities (evidence: `app/repositories/orden_repository.py`)
- Order repository → PostgreSQL: commits changes (evidence: `app/repositories/orden_repository.py`)
- Portal login → Report files: returns session
- Cobros download → Report files: writes report (evidence: `Scrapper/registroCobros.py`)
- Orders download → Report files: writes report (evidence: `Scrapper/ordenes.py`)
- Cobros normalizer → Report files: writes normalized file
- Orders normalizer → Report files: writes normalized file
