How bgreen39/ghg_calc works
Main Components
• Calculator Module (Backend): This contains the business logic for emissions calculation. It has separate files for calculating emissions from residential electricity (res_ele_emissions.py), residential gas (res_gas_emissions.py), transportation DSL (transport_dsl_emissions.py), and transportation gas (transport_gas_emissions.py).
• Testing Suite: Includes tests (e.g., tests/test_electricity_emissions.py) to verify that the calculations are correct.
• Website (Frontend): This is the user-facing component that includes HTML pages (index.html, contact.html, demo.html, documentation.html) and a set of assets (JavaScript files like demo.js, form_handler.js, main.js; and a CSS file) that handle user interactions and presentation.
Relationships and Interactions
• The website will interact with the calculator module. User inputs on the website likely trigger calculation requests, which are then processed using the logic in the calculator package.
• The backend (calculator module) could be exposed either as an API (if integrated into a web framework not directly seen here) or may be called directly in an environment where the interface interacts with Python code.
• There is a clear testing component ensuring the calculator's accuracy.
Architectural Patterns and Design Principles
• Separation of Concerns: Calculation logic is isolated in the calculator directory, while user interface code is maintained under the website directory.
• Layered Architecture: The system has at least two layers—the calculation logic layer and the presentation layer.
• Modularity: Each GHG calculation type is modularized in its own file, making it easier to understand, maintain, or extend.
Relevant Technologies and Frameworks
• Python: For implementing the calculation logic.
• HTML/CSS/JavaScript: For the website’s frontend.
• Testing Framework: Although not explicitly mentioned, the tests directory implies that a testing framework like pytest could be used.