This paper presents a methodology to systematically formulate a hybrid renewable energy system (HRES), which consists of solar, wind and diesel generator as a backup resource as well as battery storage, from the preliminary design stage to the optimal operation. Detailed modeling of each system component is introduced as the basis for the simulation study. System sizing considering energy flows is conducted to obtain the optimal combination of photovoltaic (PV) panels and wind turbines. Energy management strategies from both the demand-side and generation-side are developed to realize the objectives of meeting the electricity demand while minimizing the overall operating and environmental costs. Day-ahead and real-time weather forecasting, demand response and model updating are also integrated into the proposed methodology using a receding horizon optimization strategy. The method is demonstrated through an application to a single-family residential home.