How gg-martins091/fundamentaldata-cli works
Project Overview and Purpose
• This project is a CLI tool designed to access fundamental data on Brazilian stocks (earnings, P/E ratio, etc.). It fetches data via the dadosdemercado.com.br API and stores responses/caches queries in a local PostgreSQL database.
• Although “incomplete yet functional,” the project has a defined modular structure covering data retrieval, data processing/plotting, and utility services (e.g., database interactions, HTTP communication, logging).
Key Components
a. CLI Entry and Command Processing:
• The entry point is main.py, which likely routes user commands to different modules.
• CLI as the “User Interface / CLI Layer.”
b. Modules:
• The “modules” directory is subdivided into:
• getinfos: Handles retrieval of fundamental data from the external API.
• loadcompanies: Likely responsible for loading or processing company data (perhaps to seed the database).
• plots: Contains several modules (balance, cashflow, gringos, income, marketratio, ratio) for generating visualizations or further analysis based on downloaded data.
• As functional blocks that the CLI interacts with for specified command execution.
c. Type Definitions:
• The “mytypes” folder is used to define type models (indicators and custom types). Represent this as a shared module for data structures employed across various business logics.
d. Services:
• The “services” directory includes:
• http.py: Likely used to manage API calls.
• pg.py: Used for PostgreSQL database interactions.
• log.py: Manages logging functionalities.
• utils.py: Miscellaneous utility functions.
• These support modules and may be invoked by various parts of the code base to ensure separation of concerns.
e. Database:
• The script.sql file and docker-compose.yml indicate that a PostgreSQL database is used.
• Local PostgreSQL DB as an external component, with the pg service interacting with it.
Relationships and Interactions
• The CLI (main.py) channels user commands to relevant modules. For example:
User Command → CLI (main.py) → Appropriate module (e.g., getinfos or loadcompanies) → Further processing (e.g., plotting via the plots modules).
• Modules (especially getinfos) interact with http services to fetch data from the external API.
• After retrieval, data may be passed to the services layer (via pg.py) to cache into the PostgreSQL database.
• The modules that handle plotting use gathered data (and calculations based on type models from mytypes) to generate visual representations.
Architectural Patterns and Technologies
• The project’s structure shows a clear separation between:
• User Interface/CLI – entry point via main.py.
• Business logic – implemented in modular subcomponents in the modules and mytypes directories.
• Infrastructure services – encapsulated in the services directory (HTTP calls, database access, logging).
• Technologies/Frameworks include:
• Python as the primary coding language.
• PostgreSQL as the database.
• External integration with dadosdemercado.com.br via custom HTTP interactions.
• Docker Compose (docker-compose.yml) suggests containerized or reproducible environments.
• That each component is clearly labeled (e.g., “CLI (main.py)”, “Get Infos Module”, “Load Companies Module”, “Plots Module”, “HTTP Service”, “PostgreSQL DB”, etc.).
• Annotating key interactions like “API Call”, “Data Caching”, and “Logging” between components.
• If applicable, show the Docker environment via docker-compose.yml as an outer layer encompassing the PostgreSQL container and possibly the application container.