How isoledadss/sis-rev-ops works
1. High-level shape
This repository is a single-process Streamlit application with a shared PostgreSQL backend. There is no separate API service: app.py drives the UI, and the functional modules implement the business workflows directly against the database.
2. Entry point and navigation
app.py is the orchestration layer. It handles login, role-based access, and tab/routing logic for the main user flows: carga, bandeja, precios, asignaciones, reportes, métricas, and administración.
3. Configuration and runtime boundaries
config.py centralizes environment-driven settings, credentials, and domain mappings. The app depends on .env variables for DB access and user/admin lists, so secrets are kept out of source control. This makes configuration a clear boundary between code and deployment environment.
4. Persistence layer
db.py is the data-access and lifecycle core. It manages PostgreSQL connections/pooling, schema creation or migrations at startup, and database logging. The README indicates the schema is created automatically into about 12 tables, including contracts, operations, assignments, aliases, and audit/history tables.
5. Shared domain utilities
helpers.py holds cross-cutting business utilities: conversions, alias resolution, and user/contract mapping logic. This module is the main shared dependency used by multiple features to keep classification and normalization consistent.
6. Operation ingestion
carga.py owns import of CPASVTAS Excel files via openpyxl/pandas-style parsing. Its output is persisted operations plus load records in cargas, and it likely feeds downstream review and reporting tables. This is the first major inbound data flow from external files into PostgreSQL.
7. Review workflow
bandeja.py implements the contract-based review queue. It is the operational control plane: multiuser locking, review callbacks, and auto-close when a contract is completed. It reads/writes contract and operation state, so it sits between the imported data and finalized operational records.
8. Price enrichment
precios.py is the market-data enrichment boundary. It integrates with Yahoo Finance via yahooquery and also consumes local Vector analítico files for debt instruments. It updates or supplements instrument pricing data used by review, metrics, and reporting.
9. Mass assignments
asignaciones.py handles batch assignment workflows for purchases, including participation percentages and risk validations. It writes assignment entities and links them back to operations/cargas, making it a separate business process from the review queue even though both touch the same core data.
10. Reporting and analytics
reportes.py produces per-contract reports and Excel exports, while metricas.py builds the dashboard with Plotly and generates PDF/email outputs via ReportLab and .eml files. These modules are read-heavy consumers of the operational database, with export as the main outbound flow.
11. Administration and audit
admin.py groups operational tooling: database backup, operation search, alias management, and audit-log access. It depends on the same PostgreSQL core plus pg_dump for backups, making administration an internal tooling subsystem rather than a separate service.
12. Data model and traceability
The schema design emphasizes traceability: operacion_historial captures field-level changes, audit_log records security and maintenance events, and alias/assignment tables preserve lineage across enrichment and workflow steps. This makes the database the central system of record for both state and auditability.
13. Main data flow
The typical end-to-end path is: external Excel or reference files enter through carga.py or precios.py, records are normalized with helpers.py, persisted through db.py, reviewed in bandeja.py, enriched or assigned via precios.py and asignaciones.py, and finally surfaced in reportes.py, metricas.py, or admin.py.
14. Primary architectural boundary
The key boundary in this repo is not frontend/backend, but UI orchestration vs. domain modules vs. PostgreSQL persistence. Streamlit provides the presentation layer, the feature modules implement business logic, and PostgreSQL holds state, audit history, and workflow coordination.
Main entry points: app.py Main app · db.py Database core · bandeja.py Bandeja · carga.py Carga
Components 15
Presentation
Streamlit entry point and user navigation
- Main app · Login, role gating, and tab routing for the whole application
app.py
Workflows
Business modules for ingestion, review, pricing, assignments, and admin
- Carga · Imports CPASVTAS Excel files and persists load records
carga.py - Bandeja · Contract review workflow with locking, callbacks, and auto-close
bandeja.py - Precios · Updates instrument pricing from market and local reference inputs
precios.py - Asignaciones · Handles purchase assignments, participation percentages, and risk checks
asignaciones.py - Reportes · Builds per-contract reports and Excel outputs
reportes.py - Métricas · Dashboards and PDF/email style outputs for operational metrics
metricas.py - Admin · Backup, search, alias management, and audit-log access
admin.py
Data Layer
Shared persistence, configuration, and domain utilities
- Config · Environment-driven settings, credentials, and domain mappings
config.py - Database core · Connection handling, schema lifecycle, and database logging
db.py - Helpers · Shared normalization, alias resolution, and mapping logic
helpers.py
External Systems
Non-repository dependencies and data sources
- PostgreSQL · Central relational store for contracts, operations, assignments, aliases, and audit history
- Excel files · Imported CPASVTAS and reference spreadsheets
- Market data · Yahoo Finance and local Vector analítico inputs for pricing
- Exports · Generated Excel, PDF, and .eml artifacts
Connections 31
- Main app → Config: loads settings
- Main app → Database core: opens data access
- Main app → Carga: routes to
- Main app → Bandeja: routes to
- Main app → Precios: routes to
- Main app → Asignaciones: routes to
- Main app → Reportes: routes to
- Main app → Métricas: routes to
- Main app → Admin: routes to
- Carga → Excel files: imports
- Carga → Helpers: normalizes with
- Carga → Database core: persists loads
- Bandeja → Helpers: classifies with
- Bandeja → Database core: reads/writes workflow
- Precios → Market data: fetches pricing
- Precios → Helpers: resolves aliases
- Precios → Database core: updates prices
- Asignaciones → Helpers: validates mappings
- Asignaciones → Database core: stores assignments
- Reportes → Database core: reads operations
- Reportes → Exports: generates reports
- Métricas → Database core: reads metrics
- Métricas → Exports: generates dashboards
- Admin → Database core: administers
- Admin → PostgreSQL: backup via pg_dump
- Database core → PostgreSQL: connects to
- Helpers → PostgreSQL: supports consistent state
- Carga → Bandeja: feeds reviewed operations
- Bandeja → Reportes: finalized data to reports
- Bandeja → Métricas: feeds dashboards
- Asignaciones → Reportes: feeds summaries