Skill

Diagramación de Código con Mermaid

CULTIVA Leads Pipeline — cultiva-leads-pipeline/src/  ·  Python 3.12  ·  FastAPI + sklearn + HubSpot

diagramacion-codigo-mermaid IA-Ingenieria-MLOps Trailmark v0.9 4 diagramas
Comandos ejecutados
# 1. Análisis estático del repo uv run trailmark analyze --language python --summary src/ # 2. Call graph — centrado en score_lead (profundidad 3) uv run diagram.py -t src/ -T call-graph -f score_lead -d 3 # 3. Dependencias de módulos (izquierda → derecha) uv run diagram.py -t src/ -T module-deps --direction LR # 4. Heatmap de complejidad (threshold 5) uv run diagram.py -t src/ -T complexity --threshold 5 # 5. Flujo de datos → push_to_hubspot uv run diagram.py -t src/ -T data-flow -f push_to_hubspot
call-graph

Grafo de llamadas — score_lead

-T call-graph -f score_lead -d 3
score_lead() webhook.py parse_webhook() csv_import.py import_csv() main.py ingest_route() preprocess() scoring/model.py build_feature_vector() scoring/features.py load_model() scoring/model.py normalize() log_event() llamantes (profundidad 1–2) llamados directos
flowchart TB
    parse_webhook --> score_lead
    import_csv --> score_lead
    ingest_route --> score_lead
    score_lead --> preprocess
    score_lead --> build_feature_vector
    score_lead --> load_model
    preprocess --> normalize
    build_feature_vector --> log_event

    style score_lead fill:#1f3b54,stroke:#79c0ff,color:#79c0ff
module-deps

Dependencias de módulos

-T module-deps --direction LR
main.py ingestion.webhook ingestion.csv_import ingestion.linkedin enrichment.clearbit enrichment.fullcontact scoring.model scoring.features crm utils.db utils.logger entrypoint ingestion layer processing layer output shared utils
flowchart LR
    main --> ingestion.webhook
    main --> ingestion.csv_import
    main --> ingestion.linkedin
    ingestion.webhook --> enrichment.clearbit
    ingestion.csv_import --> enrichment.fullcontact
    ingestion.linkedin --> scoring.model
    scoring.model --> scoring.features
    enrichment.clearbit --> crm.hubspot
    enrichment.fullcontact --> crm.mapper
    scoring.model -.-> utils.db
    enrichment.clearbit -.-> utils.logger
complexity

Heatmap de complejidad ciclomática

-T complexity --threshold 5
20 15 10 5 0 18 enrich _contact 16 score _lead 13 parse _webhook 11 build_ feature 9 push_to _hubspot 7 import _csv threshold=5 ≥ 12 (refactorizar urgente) 6–11 (revisar) ≤ 5 (ok) Complejidad ciclomática por función (McCabe)
flowchart TB
    enrich_contact:::high -->|CC=18| score_lead:::high
    score_lead:::high -->|CC=16| parse_webhook:::med
    parse_webhook:::med -->|CC=13| build_feature_vector:::med
    build_feature_vector:::med -->|CC=11| push_to_hubspot:::med
    push_to_hubspot:::med -->|CC=9| import_csv:::med

    classDef high fill:#3d1f1f,stroke:#f85149,color:#f85149
    classDef med  fill:#3b2d00,stroke:#e3b341,color:#e3b341
    classDef low  fill:#1a3a2a,stroke:#3fb950,color:#3fb950
data-flow

Flujo de datos → push_to_hubspot

-T data-flow -f push_to_hubspot
HTTP POST /ingest CSV upload LinkedIn hook validate_payload() enrich_contact() score_lead() map_lead_fields() push_to_hubspot() crm/hubspot.py privilege boundary TAINT: email, phone, company
flowchart TB
    src_http[HTTP POST /ingest]:::entry --> validate_payload
    src_csv[CSV upload]:::entry --> validate_payload
    src_li[LinkedIn hook]:::entry --> enrich_contact
    validate_payload --> enrich_contact
    enrich_contact --> score_lead
    score_lead --> map_lead_fields
    map_lead_fields --> push_to_hubspot:::sink

    push_to_hubspot:::sink -.->|TAINT: email,phone,company| taint_note

    classDef entry fill:#2d1f54,stroke:#d2a8ff,color:#d2a8ff
    classDef sink  fill:#1a3a2a,stroke:#3fb950,color:#3fb950