Skip to content

Modular Architecture Refactoring Latest

Choose a tag to compare

@michaelkrasa michaelkrasa released this 11 Dec 17:22
· 26 commits to 70add048c4b826bbab7c65ef6e5638663979cd74 since this release

🚀 Overview

This release represents a major architectural refactoring, splitting the monolithic codebase into focused, maintainable modules. The optimizer now follows a clean separation of concerns, making it easier to test, maintain, and extend.

✨ New Features

Modular Component Architecture - Split ESS.py into focused, single-responsibility modules:

  • optimizer.py - Main orchestration and optimization logic
  • ess_client.py - AlphaESS API client abstraction with clean interface
  • battery_manager.py - Battery state calculations and capacity management
  • price_analyzer.py - Price analysis, valley/peak detection, and smoothing
  • price_cache.py - Price data caching with ephemeral storage support
  • models.py - Data models (PriceWindow, ArbitrageCycle, OptimizationPlan)

🔧 Improvements

Better Code Organization - Each module has a clear, single responsibility for improved maintainability

Configuration Fix - Fixed min_soc default value in config.yaml (changed from 0 to 10) as per AlphaESS API docs

📦 New Files

File Purpose
optimizer.py Main optimizer orchestration
ess_client.py AlphaESS API client wrapper
battery_manager.py Battery state and capacity calculations
price_analyzer.py Price analysis and valley/peak detection
price_cache.py Price data caching logic
models.py Data models and type definitions

🗑️ Removed Files

  • ESS.py - Split into modular components above
  • build.sh - Deprecated build script

⚙️ Configuration

No breaking changes - all existing configuration remains compatible. The refactoring maintains full backward compatibility with existing .env and config.yaml files.

Updated Defaults:

  • min_soc: Changed from 0 to 10 in config.yaml - AlphaESS API limit

This refactoring provides a solid foundation for future enhancements while maintaining all existing functionality.