Skip to content

sg721642/ExoDetect-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ExoDetect AI β€” Exoplanet Detection System

ExoDetect AI is a high-performance, full-stack exoplanet detection and analysis web application designed for the ISRO Bharatiya Antariksh Hackathon. It leverages NASA's Kepler Space Telescope light curve archives and an integrated machine learning classifier to identify orbiting exoplanets.


🌌 Key Features

  1. Genuinely Trained Machine Learning Classifier:

    • Performs real-time classification using an integrated Scikit-Learn Random Forest Classifier model trained on statistical and spectral features derived from light curves (including standard deviation, flux ranges, downsampled signatures, and Box Least Squares transit parameters).
  2. Transit Parameter Extraction:

    • Computes orbital period, transit depth, estimated planet radius (in Earth Radii $R_\oplus$), and transit duration on-the-fly using a fast, vectorized Box Least Squares (BLS) periodogram solver.
  3. Light Curve Format Auto-Detection:

    • Supports official NASA Kepler format (row-based flux values), generic column-based CSVs (time and flux columns), and raw sequence inputs (no headers).
  4. Stunning Interactive Visualizations:

    • Renders interactive Plotly.js charts featuring:
      • Raw Flux: the original noisy light curve.
      • Smoothed Flux: high-frequency instrument noise filtered out via a 1D Gaussian kernel ($\sigma=10$).
      • Phase Folded View: Aligned transit events showing the U-shape crossing with cyan/gold highlights.
  5. Session History Persistence:

    • Automatically synchronizes exoplanet detection history to the browser's localStorage so results persist across page refreshes.
  6. DevOps & Production Readiness:

    • Supports Docker and Docker Compose containerization.
    • Comprehensive environment variable configs (.env) for REST endpoints, ports, hosts, and CORS restrictions.
    • Robust automated unit test suite.

πŸ—ΊοΈ System Architecture

graph TD
    User([User]) -->|Uploads CSV| Frontend[React Frontend]
    User -->|Loads Demo| Frontend
    
    subgraph Frontend App
        Vite[Vite Dev Server] --> React[React UI Components]
        React -->|History| LS[(Browser LocalStorage)]
        React -->|Plotly.js| Chart[Interactive Charts]
    end
    
    Frontend -->|POST /api/predict| Backend[Flask API Server]
    Frontend -->|GET /api/sample| Backend
    
    subgraph Flask Backend
        Parser[Format Auto-detector] --> Preprocess[Gaussian Smoothing & Standardization]
        Preprocess --> BLS[Box Least Squares Periodogram]
        Preprocess --> Extract[Feature Extractor]
        BLS --> Extract
        Extract -->|Feature Vector| ML[Random Forest Classifier]
        ML -->|Predict & Probability| Response[JSON Result Structure]
    end
    
    Backend -->|JSON Data| Frontend
Loading

πŸ› οΈ Tech Stack

  • Frontend: React.js + Tailwind CSS (v4) + Lucide React + Plotly.js
  • Backend: Python Flask REST API + NumPy + SciPy + Pandas + Scikit-Learn + Joblib
  • Containerization: Docker + Docker Compose

πŸ“‚ Directory Structure

exoplanet-detector/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app.py             # Flask application server
β”‚   β”œβ”€β”€ model.py           # ML prediction classifier (loads model.pkl)
β”‚   β”œβ”€β”€ train.py           # Training pipeline (generates synthetic dataset & model.pkl)
β”‚   β”œβ”€β”€ preprocess.py      # Format detection & Gaussian filter
β”‚   β”œβ”€β”€ bls.py             # Box Least Squares periodogram calculations
β”‚   β”œβ”€β”€ test_backend.py    # Unit tests for backend features
β”‚   β”œβ”€β”€ Dockerfile         # Backend container configuration
β”‚   β”œβ”€β”€ requirements.txt   # Python dependencies
β”‚   β”œβ”€β”€ .env.example       # Example environment variables
β”‚   └── sample_data/       # Kepler demo csv files
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html         
β”‚   β”œβ”€β”€ vite.config.js     # Vite configuration
β”‚   β”œβ”€β”€ postcss.config.js  
β”‚   β”œβ”€β”€ Dockerfile         # Frontend container configuration
β”‚   β”œβ”€β”€ .env.example       
β”‚   └── src/
β”‚       β”œβ”€β”€ main.jsx       
β”‚       β”œβ”€β”€ App.jsx        # App wrapper & notification system
β”‚       β”œβ”€β”€ index.css      
β”‚       β”œβ”€β”€ components/    # UI Components (Starfield, Plotly Chart, ResultCard)
β”‚       └── pages/         # Page Containers (Home, Detector, HowItWorks, About)
β”œβ”€β”€ docker-compose.yml     # Service orchestrator
β”œβ”€β”€ .gitignore             
└── README.md

βš™οΈ Setup & Execution

Option A: Running with Docker (Recommended)

Make sure you have Docker and Docker Compose installed:

# Build and spin up both services
docker-compose up --build

The React frontend will be available at http://localhost:5173 and the Flask backend at http://localhost:5000.


Option B: Manual Setup

1. Setup Backend

cd backend

# Install dependencies
python -m pip install -r requirements.txt

# (Optional) Retrain the machine learning model
python train.py

# Run Flask server
python app.py

Note: Create a .env file in the backend/ folder based on .env.example to customize ports and host bindings.

2. Setup Frontend

cd frontend

# Install Node.js dependencies
npm install

# Run Vite development server
npm run dev

Note: Create a .env file in the frontend/ folder pointing VITE_API_URL to your Flask endpoint (e.g. http://localhost:5000).


πŸ§ͺ Running Automated Tests

A Python unit test suite is included to verify exoplanet classification and preprocessing pipelines:

cd backend
python -m unittest test_backend.py

πŸ“‘ API Endpoints

  • GET /api/health

    • Description: Returns the API status and checks if the model weights are loaded.
    • Response:
      {
        "model_loaded": true,
        "status": "healthy",
        "version": "1.0.0"
      }
  • GET /api/sample?name=<kepler69c|kepler22b|normal>

    • Description: Loads the selected Kepler target CSV file, computes physical parameters, runs the classifier, and returns analysis results.
    • Response:
      {
        "star_id": "Kepler-69c (Confirmed Planet)",
        "has_planet": true,
        "confidence": 73.3,
        "transit_depth_percent": 0.157,
        "orbital_period_days": 8.9,
        "planet_radius_earth": 43.23,
        "transit_duration_hours": 3.2,
        "time_array": [...],
        "raw_flux": [...],
        "smoothed_flux": [...]
      }
  • POST /api/predict

    • Description: Accepts a custom uploaded .csv file in a multipart form under the file field. Automatically parses structure, filters instrument noise, runs the BLS transit solver, and outputs ML prediction results.
    • Response: Matches the sample response structure.

🀝 Contributing

Contributions to ExoDetect AI are welcome! Please follow these guidelines:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/amazing-feature).
  3. Commit your changes (git commit -m 'feat: add amazing feature').
  4. Push to the branch (git push origin feature/amazing-feature).
  5. Open a Pull Request.

πŸ“„ License

This project is licensed under the MIT License - see below for details:

MIT License

Copyright (c) 2026 ExoDetect AI Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Releases

No releases published

Packages

 
 
 

Contributors