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 # Git ignore rules
βββ requirements.txt # Backend Python dependencies
βββ README.md # This file
βββ CLEAN_FOLDER_STRUCTURE.md # Detailed folder structure
β
βββ app/ # Backend Application
β βββ __init__.py
β βββ main.py # FastAPI application entry point
β β
β βββ api/ # API Routes
β β βββ __init__.py
β β βββ auth.py # Authentication endpoints
β β βββ ml.py # ML prediction endpoints
β β βββ sites.py # Site management endpoints
β β
β βββ core/ # Core utilities
β β βββ __init__.py
β β βββ deps.py # Dependency injection
β β βββ security.py # Security utilities (JWT, hashing)
β β
β βββ db/ # Database layer
β β βββ __init__.py
β β βββ database.py # Database connection & session
β β βββ seed.py # Database seeding
β β
β βββ ml/ # Machine Learning Module
β β βββ __init__.py
β β βββ best_model.pth # Trained ML model (KEEP)
β β βββ cloud_detection.py # Cloud detection model
β β βββ cloud_forecasting.py # Cloud forecasting model
β β βββ gee_config.py # Google Earth Engine config
β β βββ gee_config_simple.py # Simplified GEE config
β β βββ requirements.txt # ML-specific dependencies
β β βββ setup_gee.py # GEE setup script
β β βββ solar_energy_output_prediction.py
β β βββ solar_irradiance_prediction.py
β β
β βββ models/ # SQLAlchemy models
β β βββ __init__.py
β β βββ models.py # Database models
β β
β βββ schemas/ # Pydantic schemas
β β βββ __init__.py
β β βββ schemas.py # Request/Response schemas
β β
β βββ services/ # Business logic
β βββ __init__.py
β βββ crud.py # CRUD operations
β βββ ml_service.py # ML service layer
β βββ model_monitor.py # Model monitoring
β
βββ Frontend/ # Frontend Application
β βββ Main/ # React + TypeScript + Vite
β β βββ src/
β β β βββ components/ # React components
β β β β βββ ui/ # UI component library (shadcn)
β β β β βββ ApiStatus.tsx
β β β β βββ CTASection.tsx
β β β β βββ DataSourcesSection.tsx
β β β β βββ FeaturesSection.tsx
β β β β βββ Footer.tsx
β β β β βββ Header.tsx
β β β β βββ HeroSection.tsx
β β β β βββ MLPredictor.tsx
β β β β βββ ProtectedRoute.tsx
β β β β βββ SitesManager.tsx
β β β β βββ TechnologySection.tsx
β β β β
β β β βββ contexts/ # React contexts
β β β β βββ AuthContext.tsx
β β β β βββ ThemeContext.tsx
β β β β
β β β βββ hooks/ # Custom React hooks
β β β β βββ use-api.ts
β β β β βββ use-mobile.tsx
β β β β βββ use-toast.ts
β β β β
β β β βββ lib/ # Utility libraries
β β β β βββ api.ts # API client
β β β β βββ utils.ts # Utility functions
β β β β
β β β βββ pages/ # Page components
β β β β βββ Dashboard.tsx
β β β β βββ Satellite.tsx
β β β β βββ Weather.tsx
β β β β βββ Solar.tsx
β β β β βββ Advanced.tsx
β β β β βββ ... (other pages)
β β β β
β β β βββ assets/ # Static assets
β β β β βββ earth-hero.jpg
β β β β βββ hero-earth-satellite.jpg
β β β β βββ ... (other images)
β β β β
β β β βββ App.css
β β β βββ App.tsx # Main App component
β β β βββ index.css # Global styles
β β β βββ main.tsx # React entry point
β β β βββ vite-env.d.ts # Vite type definitions
β β β
β β βββ public/ # Public static files
β β β βββ robots.txt
β β β
β β βββ components.json # shadcn/ui config
β β βββ env.example # Environment variables example
β β βββ eslint.config.js # ESLint configuration
β β βββ index.html # HTML entry point
β β βββ package.json # Node dependencies
β β βββ package-lock.json # Lock file (or bun.lockb)
β β βββ postcss.config.js # PostCSS configuration
β β βββ README.md # Frontend documentation
β β βββ tailwind.config.ts # Tailwind CSS configuration
β β βββ tsconfig.app.json # TypeScript config (app)
β β βββ tsconfig.json # TypeScript base config
β β βββ tsconfig.node.json # TypeScript config (node)
β β βββ vite.config.ts # Vite build configuration
β β
β βββ package-lock.json # Root package lock (if exists)
β
βββ scripts/ # Utility scripts (OPTIONAL)
βββ check_users.py # Database user checker
βββ force_seed_users.py # Database seeder
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 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- Model configuration is handled in respective Python files
# Run tests (if test files exist)
pytestcd Frontend/Main
npm run test# Check database users
python check_users.py
# Force seed users (resets database)
python 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
- 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 proprietary. All rights reserved.
For issues and questions:
- Check the documentation in
CLEAN_FOLDER_STRUCTURE.md - 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