How betzamica/lib_bi works
Project type and purpose
• From the file tree and absence of a detailed README, we see this is a Python library (“lib_bi”) designed to provide a unified set of “handlers” for Business‐Intelligence–related operations: interacting with BigQuery, email, local files, FTP/SFTP, Google Sheets, and data replication tasks.
• It is not a full‐stack app but an integration/ETL toolkit intended to be imported into customer scripts or pipelines.
File structure
• Top‐level:
• .gitignore, .python-version, pyproject.toml, requirements.txt → standard Python project configuration
• src/lib_bi → single package containing all handler modules
• Inside lib_bi:
• bq_handler.py
• email_sender.py
• file_handler.py
• ftp_handler.py
• stfp_handler.py (SFTP)
• sheet_handler.py
• replica_handler.py
• py.typed → indicates type‐hint support
• No database or web server code; each module is a connector to an external service.
Key architectural insights
• Modular pattern: each handler encapsulates one external service or functionality
• Single‐package library with clear separation of concerns
• Designed for dependency injection into a higher‐level orchestration or pipeline (e.g., Airflow, Prefect, custom scripts)
a. Main components:
• lib_bi Package (central)
– BQHandler
– EmailSender
– FileHandler
– FTPHandler
– SFTPHandler
– SheetHandler
– ReplicaHandler
• External Services:
– Google BigQuery
– SMTP/IMAP or SendGrid (Email)
– Local/File System
– FTP Server
– SFTP Server
– Google Sheets API
– (Optionally) Upstream Data Sources or Downstream Consumers
b. Relationships and interactions:
• From each handler → corresponding external service.
• ReplicaHandler may orchestrate multiple handlers (e.g., pull from BigQuery → write to file → push via FTP).
c. Architectural patterns & principles:
• Separation of Concerns: one module per service
• Dependency Injection: callers supply credentials/config to handlers
• Adapter/Facade pattern: each handler adapts an external API into a uniform interface
d. Technologies & frameworks:
• Python 3.x
• Google Cloud BigQuery client library
• smtplib or transactional email API
• ftplib / paramiko
• google‐api‐python‐client for Sheets
• Standard pathlib / file I/O