Battery storage is an important part of every microgrid. Battery storage works by absorbing electricity when it's abundant on the power grid and sending excess power back to the grid when it's most needed, such as during the evening after the sun sets and solar energy fades. This paper presents the development of a flexible hourly day-ahead power dispatch architecture for distributed energy resources in microgrids, with cost-based or demand-based operation, built up in a multi-class Python environment with SQLExpress and InfluxDB databases storing the dispatcher and. With the rising adoption of distributed energy resources (DERs), microgrid dispatch is facing new challenges: DER owners are independent stakeholders seeking to maximize their individual profits rather than being controlled centrally; and the dispatch of renewable generators may affect the. We have around 21 BESS and microgrid sites with 442 megawatts (MW) of utility-owned energy storage and another 40+ MW in development. Typically, these battery systems and microgrids are installed on SDG&E-owned property; they are adjacent to our existing substation facilities or in critical. The proposal to meet the energy demand considers: (a) interconnection to the main grid, (b) conventional diesel generators, (c) a photovoltaic system, (d) a hydroelectric turbine, (e) a wind system, (f) a battery-based storage system, (g) capacity to exchange energy with the main grid, (h).