Solar panels produce less energy when clouds block sunlight. If we can accurately forecast cloud movement and density, solar energy systems can be adjusted in real-time or planned more efficiently for example, by storing more energy in advance or adjusting grid supply strategies.
- Cloud Detection: Real-time satellite-based cloud coverage analysis
- Cloud Forecasting: Advanced weather monitoring and cloud forecast predictions
- Solar Energy Prediction: Deep-learning models for solar irradiance and energy output prediction
- Advanced Analytics: Live model health monitoring and performance tracking
- System Engagement Tracking: Real-time usage analytics using OpenWeatherMap API
The application features JWT-based authentication and authorization, interactive dashboards with real-time charts, a modern UI built with React, TypeScript, and Tailwind CSS, a FastAPI backend with async/await support, multiple ML models with confidence scoring, model performance monitoring, Google Earth Engine integration, and a PostgreSQL database with SQLAlchemy ORM.
- Framework: FastAPI 0.115.0
- Server: Uvicorn with ASGI
- Database: PostgreSQL with SQLAlchemy 2.0
- Authentication: JWT (python-jose)
- ML Libraries:
- PyTorch
- XGBoost
- scikit-learn
- NumPy, Pandas
- Image Processing: OpenCV, Pillow, scikit-image
- Google Earth Engine: earthengine-api, geemap
- Framework: React 18.3
- Language: TypeScript 5.8
- Build Tool: Vite 5.4
- UI Library: shadcn/ui (Radix UI)
- Styling: Tailwind CSS 3.4
- Charts: Chart.js, Recharts
- State Management: React Query (TanStack Query)
- Routing: React Router DOM 6.30
- Database: PostgreSQL
- API: RESTful API with FastAPI
- Deployment: Docker-ready (nginx configuration available)
SolarCastAI/
|
|-- .gitignore
|-- requirements.txt
|-- README.md
|
|-- app/
| |-- __init__.py
| |-- main.py
| |
| |-- api/
| | |-- __init__.py
| | |-- auth.py
| | |-- ml.py
| | `-- sites.py
| |
| |-- core/
| | |-- __init__.py
| | |-- deps.py
| | `-- security.py
| |
| |-- db/
| | |-- __init__.py
| | |-- database.py
| | `-- seed.py
| |
| |-- ml/
| | |-- __init__.py
| | |-- best_model.pth (local model file, usually git-ignored)
| | |-- cloud_detection.py
| | |-- cloud_forecasting.py
| | |-- gee_config.py
| | |-- gee_config_simple.py
| | |-- requirements.txt
| | |-- setup_gee.py
| | |-- solar_energy_output_prediction.py
| | `-- solar_irradiance_prediction.py
| |
| |-- models/
| | |-- __init__.py
| | `-- models.py
| |
| |-- schemas/
| | |-- __init__.py
| | `-- schemas.py
| |
| `-- services/
| |-- __init__.py
| |-- crud.py
| |-- ml_service.py
| `-- model_monitor.py
|
|-- Frontend/
| |-- Main/
| | |-- src/
| | | |-- components/
| | | | |-- ui/
| | | | |-- ApiStatus.tsx
| | | | |-- CTASection.tsx
| | | | |-- DataSourcesSection.tsx
| | | | |-- FeaturesSection.tsx
| | | | |-- Footer.tsx
| | | | |-- Header.tsx
| | | | |-- HeroSection.tsx
| | | | |-- MLPredictor.tsx
| | | | |-- ProtectedRoute.tsx
| | | | |-- SitesManager.tsx
| | | | `-- TechnologySection.tsx
| | | |
| | | |-- contexts/
| | | | |-- AuthContext.tsx
| | | | `-- ThemeContext.tsx
| | | |
| | | |-- hooks/
| | | | |-- use-api.ts
| | | | |-- use-mobile.tsx
| | | | `-- use-toast.ts
| | | |
| | | |-- lib/
| | | | |-- api.ts
| | | | `-- utils.ts
| | | |
| | | |-- pages/
| | | | |-- Dashboard.tsx
| | | | |-- Satellite.tsx
| | | | |-- Weather.tsx
| | | | |-- Solar.tsx
| | | | `-- Advanced.tsx
| | | |
| | | |-- assets/
| | | | |-- earth-hero.jpg
| | | | `-- hero-earth-satellite.jpg
| | | |
| | | |-- App.css
| | | |-- App.tsx
| | | |-- index.css
| | | |-- main.tsx
| | | `-- vite-env.d.ts
| | |
| | |-- public/
| | | `-- robots.txt
| | |
| | |-- components.json
| | |-- env.example
| | |-- eslint.config.js
| | |-- index.html
| | |-- package.json
| | |-- package-lock.json
| | |-- postcss.config.js
| | |-- README.md
| | |-- tailwind.config.ts
| | |-- tsconfig.app.json
| | |-- tsconfig.json
| | |-- tsconfig.node.json
| | `-- vite.config.ts
| |
| `-- package-lock.json
|
`-- scripts/
|-- check_users.py
`-- force_seed_users.py
Before you begin, ensure you have the following installed:
- Python 3.10+ (recommended: 3.11 or 3.12)
- Node.js 18+ (or Bun)
- PostgreSQL 12+
- Google Earth Engine Account (for satellite imagery features)
- OpenWeatherMap API Key (for weather data)
git clone <repository-url>
cd SolarCastAI# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate# Install main backend dependencies
pip install -r requirements.txt
# Install ML-specific dependencies
cd app/ml
pip install -r requirements.txt
cd ../..cd app/ml
python setup_gee.py
# Follow the authentication prompts
cd ../..cd Frontend/Main
# Install dependencies (using npm)
npm install
# OR using bun
bun installCREATE DATABASE sola_ai;Create a .env file in the root directory:
# Database Configuration
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_password
POSTGRES_DB=sola_ai
# JWT Configuration
SECRET_KEY=your-secret-key-here # REQUIRED: Generate a strong random key for production
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
# Google Earth Engine
GEE_CREDENTIALS_PATH=path/to/credentials.json
GEE_PROJECT_ID=your-gcp-project-id # Optional: Your Google Cloud Project ID for GEE
# OpenWeatherMap API
OPENWEATHERMAP_API_KEY=your-api-key-here# The database tables will be created automatically on first run
# Or manually seed users:
python scripts/check_users.py# From root directory
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000The API will be available at:
- API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Alternative Docs: http://localhost:8000/redoc
cd Frontend/Main
npm run dev
# or
bun run devThe frontend will be available at:
- Frontend: http://localhost:5173 (Vite default port)
cd Frontend/Main
npm run build
# Output will be in dist/ directory# Use a production ASGI server
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4POST /api/auth/login- User loginPOST /api/auth/register- User registrationGET /api/auth/me- Get current user
POST /api/ml/cloud-detection/run- Run cloud detection analysisPOST /api/ml/cloud-forecasting/run- Run cloud forecastingPOST /api/ml/solar-energy-prediction/run- Run solar energy predictionPOST /api/ml/irradiance- Predict solar irradiancePOST /api/ml/energy-output- Predict energy output
GET /api/ml/models/status- Get model health statusGET /api/ml/models/health- Detailed model health metrics
GET /api/sites- List all sitesPOST /api/sites- Create a new siteGET /api/sites/{id}- Get site detailsPUT /api/sites/{id}- Update siteDELETE /api/sites/{id}- Delete site
GET /- Health check endpoint
For detailed API documentation, visit http://localhost:8000/docs after starting the server.
| Variable | Description | Required |
|---|---|---|
POSTGRES_HOST |
PostgreSQL host | Yes |
POSTGRES_PORT |
PostgreSQL port | Yes |
POSTGRES_USER |
PostgreSQL username | Yes |
POSTGRES_PASSWORD |
PostgreSQL password | Yes |
POSTGRES_DB |
Database name | Yes |
SECRET_KEY |
JWT secret key | Yes |
ALGORITHM |
JWT algorithm | No (default: HS256) |
ACCESS_TOKEN_EXPIRE_MINUTES |
Token expiry | No (default: 30) |
GEE_CREDENTIALS_PATH |
GEE credentials path | Yes (for ML features) |
GEE_PROJECT_ID |
Google Cloud Project ID for GEE | No (has default) |
OPENWEATHERMAP_API_KEY |
OpenWeatherMap API key | Yes (for weather) |
ML models are located in app/ml/:
best_model.pth- Pre-trained model weights (kept locally in many setups)- Model logic and configuration are handled in the ML Python files
# Run tests (if test files exist)
pytestcd Frontend/Main
npm run test# Check database users
python scripts/check_users.py
# Force seed users (resets database)
python scripts/force_seed_users.py- Backend Files: ~25 Python source files
- Frontend Files: ~100 TypeScript/React files
- Total Production Files: ~120-150 files
- ML Models: 4 active models
- Cloud Detection Model
- Cloud Forecasting Model
- Solar Irradiance Prediction Model
- Solar Energy Output Prediction Model
Note: The Docker Deployment workflow below has not been fully implemented yet during the current development phase.
These items are planned as future development and will be completed in upcoming iterations.
- Build Docker images
- Configure environment variables
- Run with docker-compose
- Backend: Deploy using Gunicorn or Uvicorn with reverse proxy (nginx)
- Frontend: Build static files and serve with nginx or CDN
- Database: Use managed PostgreSQL service (AWS RDS, Azure, etc.)
- Development: Use local PostgreSQL and development servers
- Staging: Use staging database and test environment
- Production: Use production database with SSL and proper security
- JWT tokens with expiration
- Password hashing using bcrypt
- CORS configuration for API
- Environment variable protection
- SQL injection prevention (SQLAlchemy ORM)
- Input validation (Pydantic schemas)
- Backend: Follow PEP 8 Python style guide
- Frontend: Use ESLint and Prettier configurations
- TypeScript: Strict type checking enabled
- Use feature branches
- Commit messages should be descriptive
- Review code before merging
- Create feature branch
- Implement backend API endpoint
- Create frontend component/page
- Add tests
- Update documentation
- Submit pull request
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.
See the LICENSE file for full details.
For issues and questions:
- Check this
README.mdfirst - Review API documentation at
/docsendpoint - Contact the development team
- Additional ML model integrations
- Real-time data streaming
- Mobile app support
- Advanced analytics dashboard
- Multi-tenant support
- API rate limiting
- Caching layer implementation
Last Updated: 2025 Version: 1.0.0 Status: Production Ready