# luis7gustavo/motor_decisao architecture

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

- Interactive diagram: https://gitdiagram.com/luis7gustavo/motor_decisao
- Repository: https://github.com/luis7gustavo/motor_decisao

## Overview

SILLO is a local-first resale buying-decision system: it gathers supplier and market evidence, organizes it into Bronze/Silver/Gold layers, scores opportunities, then exposes results for human review rather than automatic purchasing. Collection is coordinated by a source registry and runner; specialist ingestion paths cover marketplaces, suppliers, and price comparisons. The FastAPI application also provides operational and Mercado Livre OAuth capabilities. Relationships follow excerpts, SOURCE INDEX references, or README statements; some collection internals and medal-layer implementations were not sampled, so uncertain links are omitted.

Main entry points: [`pipelines/collection`](https://github.com/luis7gustavo/motor_decisao/tree/main/pipelines/collection) (Bronze Raw Data), [`pipelines/collection/runner.py`](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/collection/runner.py) (Collection Runner), [`app/api/decision_engine.py`](https://github.com/luis7gustavo/motor_decisao/blob/main/app/api/decision_engine.py) (Decision API), [`pipelines/mercado_livre/ingest.py`](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/mercado_livre/ingest.py) (Mercado Livre Ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection"]
  node_registry["Source Registry<br/>[registry.py]"]
  node_runner["Collection Runner<br/>[runner.py]"]
  node_collection_contracts["Collection Contracts<br/>[contracts.py]"]
  node_collection_models["Collection Models<br/>[models.py]"]
end

subgraph group_market_data["Market Data"]
  node_bronze[("Bronze Raw Data")]
  node_market_web["Market Web Ingestion<br/>[ingest.py]"]
  node_market_parsing["Market Parsing<br/>[parsing.py]"]
  node_suppliers["Supplier Ingestion<br/>[ingest.py]"]
  node_price_history["Price Comparisons<br/>[ingest.py]"]
  node_mercado_livre["Mercado Livre Ingestion<br/>[ingest.py]"]
  node_silver[("Silver Normalization")]
end

subgraph group_decision["Decision Engine"]
  node_gold[("Gold Opportunities")]
  node_decision_build["Scoring and Matching<br/>[build.py]"]
  node_catalog_imports["Catalog Imports"]
end

subgraph group_api["API and Review"]
  node_fastapi["FastAPI Application<br/>[main.py]"]
  node_decision_api["Decision API<br/>[decision_engine.py]"]
  node_review_api["Review Queue API<br/>[review.py]"]
  node_review_service["Review Service<br/>[review_service.py]"]
  node_review_repository["Review Repository"]
  node_review_schema["Review Schemas<br/>[review.py]"]
  node_review_store[("Review Decisions")]
  node_ml_oauth["Mercado Livre OAuth"]
end

subgraph group_runtime["Runtime Services"]
  node_settings["Settings<br/>[settings.py]"]
  node_database["Database Engine<br/>[database.py]"]
  node_ml_tokens["OAuth Tokens"]
end

node_operator(("Operator"))
node_prefect["Prefect"]
node_public_sources["Public Sources"]
node_ml_service["Mercado Livre API"]

node_operator -->|"starts collection"| node_runner
node_prefect -->|"schedules and retries"| node_runner
node_runner -->|"loads sources"| node_registry
node_runner -->|"uses models"| node_collection_models
node_runner -.->|"validates runs"| node_collection_contracts
node_public_sources -->|"provides listings"| node_market_web
node_public_sources -->|"provides catalogs"| node_suppliers
node_public_sources -->|"provides comparisons"| node_price_history
node_public_sources -->|"provides offers"| node_mercado_livre
node_market_web -->|"uses parsing"| node_market_parsing
node_market_web -->|"loads raw evidence"| node_bronze
node_suppliers -->|"loads raw catalogs"| node_bronze
node_price_history -->|"stores snapshots"| node_bronze
node_mercado_livre -->|"stores raw offers"| node_bronze
node_bronze -->|"normalizes data"| node_silver
node_silver -->|"forms opportunities"| node_gold
node_catalog_imports -.->|"imports catalogs"| node_bronze
node_decision_build -->|"writes scores"| node_gold
node_operator -->|"requests decisions"| node_decision_api
node_decision_api -->|"runs scoring"| node_decision_build
node_decision_api -->|"imports catalogs"| node_catalog_imports
node_decision_api -->|"reads results"| node_gold
node_fastapi -->|"registers routes"| node_decision_api
node_fastapi -->|"registers routes"| node_review_api
node_operator -->|"reviews opportunities"| node_review_api
node_review_api -->|"delegates review"| node_review_service
node_review_api -->|"validates input"| node_review_schema
node_review_service -->|"enriches evidence"| node_review_repository
node_review_repository -.->|"records decisions"| node_review_store
node_review_repository -.->|"reads opportunities"| node_gold
node_decision_build -->|"uses engine"| node_database
node_review_repository -.->|"uses engine"| node_database
node_settings -->|"configures connection"| node_database
node_ml_oauth -->|"manages tokens"| node_ml_tokens
node_mercado_livre -->|"uses credentials"| node_ml_tokens
node_mercado_livre -.->|"calls API"| node_ml_service

click node_registry "https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/collection/registry.py"
click node_runner "https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/collection/runner.py"
click node_collection_contracts "https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/collection/contracts.py"
click node_collection_models "https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/collection/models.py"
click node_bronze "https://github.com/luis7gustavo/motor_decisao/tree/main/pipelines/collection"
click node_market_web "https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/market_web/ingest.py"
click node_market_parsing "https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/market_web/parsing.py"
click node_suppliers "https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/suppliers/ingest.py"
click node_price_history "https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/price_history/ingest.py"
click node_mercado_livre "https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/mercado_livre/ingest.py"
click node_silver "https://github.com/luis7gustavo/motor_decisao/tree/main/pipelines/silver"
click node_gold "https://github.com/luis7gustavo/motor_decisao/tree/main/pipelines/gold"
click node_decision_build "https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/decision_engine/build.py"
click node_catalog_imports "https://github.com/luis7gustavo/motor_decisao/blob/main/scripts/import_megamix_catalog.py"
click node_fastapi "https://github.com/luis7gustavo/motor_decisao/blob/main/app/main.py"
click node_decision_api "https://github.com/luis7gustavo/motor_decisao/blob/main/app/api/decision_engine.py"
click node_review_api "https://github.com/luis7gustavo/motor_decisao/blob/main/app/api/review.py"
click node_review_service "https://github.com/luis7gustavo/motor_decisao/blob/main/app/services/review_service.py"
click node_review_repository "https://github.com/luis7gustavo/motor_decisao/blob/main/app/repositories/review_repository.py"
click node_review_schema "https://github.com/luis7gustavo/motor_decisao/blob/main/app/schemas/review.py"
click node_review_store "https://github.com/luis7gustavo/motor_decisao/blob/main/app/models/opportunity_review.py"
click node_settings "https://github.com/luis7gustavo/motor_decisao/blob/main/app/core/settings.py"
click node_database "https://github.com/luis7gustavo/motor_decisao/blob/main/app/core/database.py"
click node_ml_oauth "https://github.com/luis7gustavo/motor_decisao/blob/main/app/api/mercado_livre_oauth.py"
click node_ml_tokens "https://github.com/luis7gustavo/motor_decisao/blob/main/app/core/mercado_livre_tokens.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_registry,node_runner,node_collection_contracts,node_collection_models toneBlue
class node_bronze,node_market_web,node_market_parsing,node_suppliers,node_price_history,node_mercado_livre,node_silver toneAmber
class node_gold,node_decision_build,node_catalog_imports,node_ml_service toneMint
class node_fastapi,node_decision_api,node_review_api,node_review_service,node_review_repository,node_review_schema,node_review_store,node_ml_oauth toneRose
class node_settings,node_database,node_ml_tokens,node_operator,node_prefect,node_public_sources toneIndigo
```

## Components

### Collection

- [Source Registry](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/collection/registry.py): `pipelines/collection/registry.py`
- [Collection Runner](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/collection/runner.py): `pipelines/collection/runner.py`
- [Collection Contracts](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/collection/contracts.py): `pipelines/collection/contracts.py`
- [Collection Models](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/collection/models.py): `pipelines/collection/models.py`

### Market Data

- [Bronze Raw Data](https://github.com/luis7gustavo/motor_decisao/tree/main/pipelines/collection): `pipelines/collection`
- [Market Web Ingestion](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/market_web/ingest.py): `pipelines/market_web/ingest.py`
- [Market Parsing](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/market_web/parsing.py): `pipelines/market_web/parsing.py`
- [Supplier Ingestion](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/suppliers/ingest.py): `pipelines/suppliers/ingest.py`
- [Price Comparisons](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/price_history/ingest.py): `pipelines/price_history/ingest.py`
- [Mercado Livre Ingestion](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/mercado_livre/ingest.py): `pipelines/mercado_livre/ingest.py`
- [Silver Normalization](https://github.com/luis7gustavo/motor_decisao/tree/main/pipelines/silver): `pipelines/silver`

### Decision Engine

- [Gold Opportunities](https://github.com/luis7gustavo/motor_decisao/tree/main/pipelines/gold): `pipelines/gold`
- [Scoring and Matching](https://github.com/luis7gustavo/motor_decisao/blob/main/pipelines/decision_engine/build.py): `pipelines/decision_engine/build.py`
- [Catalog Imports](https://github.com/luis7gustavo/motor_decisao/blob/main/scripts/import_megamix_catalog.py): `scripts/import_megamix_catalog.py`

### API and Review

- [FastAPI Application](https://github.com/luis7gustavo/motor_decisao/blob/main/app/main.py): `app/main.py`
- [Decision API](https://github.com/luis7gustavo/motor_decisao/blob/main/app/api/decision_engine.py): `app/api/decision_engine.py`
- [Review Queue API](https://github.com/luis7gustavo/motor_decisao/blob/main/app/api/review.py): `app/api/review.py`
- [Review Service](https://github.com/luis7gustavo/motor_decisao/blob/main/app/services/review_service.py): `app/services/review_service.py`
- [Review Repository](https://github.com/luis7gustavo/motor_decisao/blob/main/app/repositories/review_repository.py): `app/repositories/review_repository.py`
- [Review Schemas](https://github.com/luis7gustavo/motor_decisao/blob/main/app/schemas/review.py): `app/schemas/review.py`
- [Review Decisions](https://github.com/luis7gustavo/motor_decisao/blob/main/app/models/opportunity_review.py): `app/models/opportunity_review.py`
- [Mercado Livre OAuth](https://github.com/luis7gustavo/motor_decisao/blob/main/app/api/mercado_livre_oauth.py): `app/api/mercado_livre_oauth.py`

### Runtime Services

- [Settings](https://github.com/luis7gustavo/motor_decisao/blob/main/app/core/settings.py): `app/core/settings.py`
- [Database Engine](https://github.com/luis7gustavo/motor_decisao/blob/main/app/core/database.py): `app/core/database.py`
- [OAuth Tokens](https://github.com/luis7gustavo/motor_decisao/blob/main/app/core/mercado_livre_tokens.py): `app/core/mercado_livre_tokens.py`

### Other components

- **Operator**
- **Prefect**
- **Public Sources**
- **Mercado Livre API**

## Connections

- Operator → Collection Runner: starts collection
- Prefect → Collection Runner: schedules and retries
- Collection Runner → Source Registry: loads sources (evidence: `pipelines/collection/runner.py`)
- Collection Runner → Collection Models: uses models (evidence: `pipelines/collection/runner.py`)
- Collection Runner → Collection Contracts: validates runs
- Public Sources → Market Web Ingestion: provides listings
- Public Sources → Supplier Ingestion: provides catalogs
- Public Sources → Price Comparisons: provides comparisons
- Public Sources → Mercado Livre Ingestion: provides offers
- Market Web Ingestion → Market Parsing: uses parsing
- Market Web Ingestion → Bronze Raw Data: loads raw evidence
- Supplier Ingestion → Bronze Raw Data: loads raw catalogs
- Price Comparisons → Bronze Raw Data: stores snapshots (evidence: `pipelines/price_history/ingest.py`)
- Mercado Livre Ingestion → Bronze Raw Data: stores raw offers (evidence: `pipelines/mercado_livre/ingest.py`)
- Bronze Raw Data → Silver Normalization: normalizes data
- Silver Normalization → Gold Opportunities: forms opportunities
- Catalog Imports → Bronze Raw Data: imports catalogs
- Scoring and Matching → Gold Opportunities: writes scores
- Operator → Decision API: requests decisions
- Decision API → Scoring and Matching: runs scoring (evidence: `app/api/decision_engine.py`)
- Decision API → Catalog Imports: imports catalogs (evidence: `app/api/decision_engine.py`)
- Decision API → Gold Opportunities: reads results (evidence: `app/api/decision_engine.py`)
- FastAPI Application → Decision API: registers routes (evidence: `app/main.py`)
- FastAPI Application → Review Queue API: registers routes (evidence: `app/main.py`)
- Operator → Review Queue API: reviews opportunities
- Review Queue API → Review Service: delegates review (evidence: `app/api/review.py`)
- Review Queue API → Review Schemas: validates input (evidence: `app/api/review.py`)
- Review Service → Review Repository: enriches evidence (evidence: `app/services/review_service.py`)
- Review Repository → Review Decisions: records decisions
- Review Repository → Gold Opportunities: reads opportunities
- Scoring and Matching → Database Engine: uses engine (evidence: `pipelines/decision_engine/build.py`)
- Review Repository → Database Engine: uses engine
- Settings → Database Engine: configures connection (evidence: `app/core/database.py`)
- Mercado Livre OAuth → OAuth Tokens: manages tokens (evidence: `app/api/mercado_livre_oauth.py`)
- Mercado Livre Ingestion → OAuth Tokens: uses credentials (evidence: `pipelines/mercado_livre/ingest.py`)
- Mercado Livre Ingestion → Mercado Livre API: calls API
