# `emi_app.py` ## Overview This is the primary entry point for the Flask web server. Running this script initializes the HTTP application, binds all necessary modules, sets up error monitoring, and exposes the REST API to the internet. ## Key Initializations ### 1. Error Monitoring - **Bugsnag**: Configures the `bugsnag` client with `config.BUGSNAG_KEY` to catch and monitor exceptions occurring inside the Flask app, specifically mapped with `handle_exceptions(app)`. ### 2. Dependency Injection - Initializes `EMIContainer()` and `CoreApp()` and attaches them to `app.container`. This effectively bootstraps the repository layer, service layer, and utilities layer that will be injected into the blueprints later. ### 3. Middleware & Security - **Rate Limiting (`Flask-Limiter`)**: Sets up a global memory-based rate limit of `60 requests per minute` utilizing the client's remote address. - **CORS (`Flask-Cors`)**: Configures Cross-Origin Resource Sharing based on the `config.domain` list. Enables `supports_credentials=True`. ### 4. Blueprints Routing Registers two primary Blueprints: - **`emi_api`**: Imported from `applications.routes`. Maps to standard EMI processes. - **`no_touch_api`**: Imported from `applications.no_touch`. Maps to "no touch" / fast-track solar processes. ## Execution When run as main (`__name__ == '__main__'`), the application binds to the host and port defined in the `config.py` module.