How tashifkhan/solarhelper works
Project Type and Purpose
• This is a full-stack Solar Helper application combining:
• A React/Vite frontend (TypeScript) delivering an interactive UI (calculator, chat, recommendations, community).
• A Python backend (FastAPI-style routers + Streamlit entrypoint + WSGI) that exposes REST endpoints for chat, power‐prediction, recommendations and web scraping.
• A separate weather-analysis ML training pipeline (LSTM models for monthly/yearly weather forecasts) used offline to produce model artifacts.
• Local file-based “data stores” (CSV/Excel context files, pre-trained ML model pickles and LSTM H5 models).
• External dependencies: OpenAI (LLM), public web sources (via Scrapy).
File-Structure Analysis
• Top level: .gitignore, LICENSE, README.md, plus three directories:
• backend/ – server code, routers, services, models, context, prediction_models, Streamlit/WSGI entrypoints.
• frontend/ – React/Vite app with src/components, src/pages, public assets, config files, Vercel deployment config.
• weather analysis/ – data + scripts for training LSTM weather models.
• backend/services contains business logic (chat_service, power_pipeline, recommendation_service, scrape_service).
• backend/routers routes map HTTP endpoints to service calls.
• backend/prediction_models holds pickled ML artifacts for power prediction; weather models live under weather analysis/models.
• Configuration: pyproject.toml, bun.lock, package.json, type configs for TS.
README Insights
• README only provides the project title “SolarHelper.” Detailed architecture isn’t specified there, so structure must be inferred from code layout.
a. Main Components
• Frontend UI (React/Vite)
• API Gateway (FastAPI server / Streamlit entrypoint)
• Service Layer (chat_service, power_prediction_service, recommendation_service, scrape_service)
• Model Store (pickle files / LSTM H5s)
• Context Data Store (CSV / Excel files)
• External Services:
– OpenAI (LLM)
– Public web sources (scraped via Scrapy)
• Training Pipeline (weather_analysis scripts & model trainer)
b. Relationships and Data Flows
1. User interacts with Frontend → HTTP calls to API Gateway.
2. API Gateway → routes request to appropriate service.
3. Service Layer →
– Loads context data (CSV / subsidy info)
– Loads prediction model artifacts → performs inference pipeline.
– Or invokes chat_service → llm_service → OpenAI API → returns LLM response.
– Or runs scrape_service → Scrapy spiders → external web data.
4. Service response → API Gateway → JSON → Frontend.
5. Offline: Training Pipeline reads historical weather data → trains LSTM models → writes to weather_analysis/models → artifacts may feed into backend’s prediction_models.
c. Architectural Patterns and Design Principles
• Clear separation of concerns: routers (API layer) vs. services (business logic) vs. models (data representations).
• File-based datastore for context and model artifacts (no external DB).
• Modular ML pipeline: preprocess → inference → postprocess.
• Extensible scraping and recommendation engines.
• Frontend ↔ Backend decoupling via REST API.
d. Key Technologies and Frameworks
• Frontend: React, Vite, TypeScript, ESLint, Vercel for hosting.
• Backend: Python, FastAPI (implied), Streamlit, Uvicorn/WSGI.
• ML: scikit-learn (pickle), TensorFlow/Keras (LSTM H5).
• Scraping: Scrapy.
• LLM integration: OpenAI API.
• Data processing: pandas reading CSV/Excel.