Skip to content

reddam-charan-teja-reddy/Ocean-Disaster-Alerting-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌊 Samudra Sahayak - Coastal Safety & Emergency Reporting System

A comprehensive platform for coastal safety monitoring, emergency reporting, and community engagement.


πŸ“š Quick Navigation

πŸš€ Getting Started

πŸ“– Documentation

πŸ”§ Development


🎯 Project Overview

Samudra Sahayak is a full-stack application designed to help coastal communities report emergencies, receive alerts, and stay informed about coastal safety conditions.

Key Features

πŸ” Authentication & User Management

  • Email/phone registration with verification
  • JWT-based secure authentication
  • Role-based access (Citizen, Official)
  • Guest mode for quick reporting
  • Password reset via email

πŸ“ Report Management

  • Create reports with text, images, audio, and video
  • Geospatial queries (find reports near location)
  • Real-time status updates
  • Category-based filtering (hazards, incidents, requests)
  • Severity levels (low, moderate, high, critical)

🚨 Alert System

  • Official alerts creation (government officials only)
  • Geospatial area-based alerts
  • Alert expiration and status tracking
  • Push notifications (planned)

πŸ—ΊοΈ Interactive Map

  • Visualize reports and alerts on map
  • Filter by location, type, and severity
  • Real-time updates

πŸ“Š User Dashboard

  • Activity tracking
  • Report statistics
  • Profile management
  • Notification preferences

🎀 AI-Powered Voice Reports

  • Voice-to-text transcription
  • AI analysis via Gemini API
  • Automatic hazard detection
  • Sentiment and urgency analysis

πŸ—οΈ Technology Stack

Backend (FastAPI + Python)

  • Framework: FastAPI 0.104+
  • Database: MongoDB Atlas (Cloud)
  • Authentication: JWT (JSON Web Tokens)
  • File Storage: Google Cloud Storage
  • Email: SMTP (Gmail)
  • AI: Google Gemini API

Frontend (Next.js + React)

  • Framework: Next.js 14
  • UI Library: Tailwind CSS + shadcn/ui
  • State Management: Redux Toolkit
  • Maps: Leaflet + React-Leaflet
  • HTTP Client: Axios

Mobile (Flutter)

  • Framework: Flutter 3.x
  • State Management: Provider/Riverpod
  • Maps: Google Maps Flutter
  • Storage: SharedPreferences

πŸš€ Quick Start

Prerequisites

  • Python 3.10+ (for backend)
  • Node.js 18+ (for frontend)
  • MongoDB (local or Atlas account)
  • Google Cloud account (for file storage)
  • Gmail account (for email notifications)

1. Start Backend Server

cd backend
sih\Scripts\activate
cd sih
python main.py

βœ… Backend will run at: http://localhost:8000
πŸ“– API docs: http://localhost:8000/docs

First time? Follow the comprehensive setup guide

2. Start Frontend Development Server

cd frontend
npm install
npm run dev

βœ… Frontend will run at: http://localhost:3000

3. Run Tests

cd backend
python test_api.py

βœ… Expected: All 8 scenarios passing (100%)


πŸ“ Project Structure

sih2025/
β”‚
β”œβ”€β”€ backend/                      # Python FastAPI backend
β”‚   β”œβ”€β”€ sih/                      # Virtual environment & app code
β”‚   β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/          # API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ utils/           # Helper functions
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py        # Configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ database.py      # MongoDB connection
β”‚   β”‚   β”‚   └── schemas.py       # Pydantic models
β”‚   β”‚   └── main.py              # Application entry point
β”‚   β”‚
β”‚   β”œβ”€β”€ test_api.py              # Comprehensive test suite
β”‚   β”œβ”€β”€ requirements.txt         # Python dependencies
β”‚   β”œβ”€β”€ .env                     # Environment variables (not in git)
β”‚   β”‚
β”‚   └── πŸ“– Documentation:
β”‚       β”œβ”€β”€ GETTING_STARTED.md   # Setup guide
β”‚       β”œβ”€β”€ README.md            # Backend overview
β”‚       β”œβ”€β”€ API_REFERENCE.md     # API documentation
β”‚       └── COMPLETE_TEST_RESULTS.md
β”‚
β”œβ”€β”€ frontend/                     # Next.js React frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                 # Next.js app router pages
β”‚   β”‚   β”œβ”€β”€ components/          # React components
β”‚   β”‚   β”œβ”€β”€ store/               # Redux store
β”‚   β”‚   └── lib/                 # Utilities
β”‚   β”‚
β”‚   β”œβ”€β”€ public/                  # Static assets
β”‚   β”œβ”€β”€ package.json             # Node dependencies
β”‚   └── README.md                # Frontend docs
β”‚
β”œβ”€β”€ flutter_application/          # Flutter mobile app
β”‚   β”œβ”€β”€ lib/                     # Flutter source code
β”‚   β”œβ”€β”€ android/                 # Android config
β”‚   β”œβ”€β”€ ios/                     # iOS config
β”‚   β”œβ”€β”€ pubspec.yaml             # Flutter dependencies
β”‚   └── README.md                # Mobile docs
β”‚
β”œβ”€β”€ test_media/                   # Test files for uploads
β”‚   β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ audio/
β”‚   └── videos/
β”‚
└── πŸ“– Root Documentation:
    β”œβ”€β”€ QUICK_START.md           # Quick reference guide
    β”œβ”€β”€ QUICK_TESTING_GUIDE.md   # Testing instructions
    └── .gitignore               # Git ignore rules

πŸ§ͺ Testing

Backend Test Suite

The backend includes a comprehensive test suite covering all functionality:

cd backend
python test_api.py

Test Scenarios:

  1. βœ… User Registration & Email Verification
  2. βœ… Report Submission (Text + Image Upload)
  3. βœ… Report Fetching (Geospatial Queries)
  4. βœ… User Login (Email & Phone)
  5. βœ… Alert Creation (Official Role)
  6. βœ… Profile & Settings Updates
  7. βœ… Activity Tracking
  8. βœ… Reports Endpoint Comparison

Current Status: All 8 scenarios passing βœ… (100% success rate)

See COMPLETE_TEST_RESULTS.md for detailed results.


πŸ” Environment Configuration

Backend Environment Variables

Required in backend/.env and backend/sih/.env:

# Database
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/sih

# JWT Secrets
JWT_SECRET=your_secret_key_32_chars_minimum
JWT_REFRESH_SECRET=your_refresh_secret_32_chars_minimum

# Email (Gmail with App Password)
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-16-char-app-password

# Google Cloud Storage
GOOGLE_CLOUD_BUCKET_NAME=your-bucket-name
GOOGLE_CLOUD_PROJECT_ID=your-project-id
GOOGLE_CLOUD_KEYFILE={"type":"service_account",...}

# Application URLs
FRONTEND_URL=http://localhost:3000
BACKEND_URL=http://localhost:8000

⚠️ Important: .env files are excluded from git. Never commit credentials!


πŸ“Š API Endpoints Overview

Authentication (9 endpoints)

  • Register, login, logout
  • Email verification
  • Password reset
  • Guest mode
  • Token refresh

Reports (5 endpoints)

  • Create, read, update, delete
  • Geospatial filtering
  • User-specific reports

Alerts (5 endpoints)

  • Create, read, update, delete (officials only)
  • Area-based geospatial queries

User Profile (6 endpoints)

  • Profile CRUD
  • Settings management
  • Activity tracking
  • User statistics

File Uploads (3 endpoints)

  • Signed URL generation
  • File verification
  • URL refresh

Map Data (2 endpoints)

  • Combined reports + alerts
  • Geospatial data for visualization

Total: 30+ documented endpoints

See API_REFERENCE.md for complete documentation.


πŸ—ΊοΈ Features in Detail

Geospatial Queries

The system supports location-based queries using MongoDB's geospatial operators:

// Find reports within 50km of a location
GET /api/reports?lat=19.076&lng=72.8777&radius=50000

// Find active alerts affecting an area
GET /api/alerts?lat=19.076&lng=72.8777&radius=100000&isActive=true

Implementation:

  • Uses $geoWithin with $centerSphere for radius searches
  • 2dsphere indexes on location and affectedArea fields
  • Supports custom sorting (by date, severity, etc.)

File Upload System

Secure file uploads via signed URLs:

  1. Client requests signed URL from backend
  2. Backend generates GCS signed URL (valid for 1 hour)
  3. Client uploads directly to Google Cloud Storage
  4. File URL stored in database with expiration tracking
  5. Download URLs auto-refresh when expired

Supported file types:

  • Images: JPEG, PNG, WebP
  • Videos: MP4, MOV, AVI
  • Audio: MP3, WAV, M4A

Voice Report Processing

AI-powered voice report analysis:

  1. User records audio message
  2. Uploaded to Google Cloud Storage
  3. Gemini AI transcribes audio to text
  4. AI analyzes content for:
    • Hazard type detection
    • Severity assessment
    • Location extraction
    • Urgency level
    • Sentiment analysis
  5. Structured report created automatically

πŸ”„ Development Workflow

  1. Start backend:

    cd backend
    sih\Scripts\activate
    cd sih
    python main.py
  2. Start frontend:

    cd frontend
    npm run dev
  3. Make changes - Server auto-reloads on file changes

  4. Test changes:

Before Committing

  1. Run tests:

    cd backend
    python test_api.py
  2. Check for errors:

    • Review backend/logs/error.log
    • Check console for warnings
  3. Update documentation if API changed

  4. Commit with descriptive message:

    git add .
    git commit -m "feat: description of changes"
    git push

πŸ› Common Issues & Solutions

Issue: Port already in use

# Kill process on port 8000 (backend)
netstat -ano | findstr :8000
taskkill /PID <process_id> /F

# Kill process on port 3000 (frontend)
netstat -ano | findstr :3000
taskkill /PID <process_id> /F

Issue: MongoDB connection failed

  1. Check MONGODB_URI in .env file
  2. Verify IP is whitelisted (MongoDB Atlas)
  3. Test connection: python backend/check_geo.py

Issue: Module not found (Python)

cd backend
sih\Scripts\activate
pip install -r requirements.txt

Issue: Module not found (Node.js)

cd frontend
npm install

Issue: Email not sending

  1. Enable 2-Step Verification on Gmail
  2. Generate App Password (16 characters)
  3. Update EMAIL_PASS in .env
  4. Restart backend server

Issue: File upload failing

  1. Verify GCS credentials in .env
  2. Check bucket permissions
  3. Test with: python backend/verify_gcs_simple.py

More troubleshooting: backend/GETTING_STARTED.md#troubleshooting


πŸ“ˆ Project Status

βœ… Completed Features

  • Complete authentication system
  • JWT token management
  • Email verification
  • Password reset flow
  • Guest mode
  • Report CRUD operations
  • Alert system (officials)
  • Geospatial queries
  • File upload (images, audio, video)
  • User profile & settings
  • Activity tracking
  • AI voice report processing
  • Comprehensive test suite
  • API documentation
  • Database indexes optimization

🚧 In Progress

  • Frontend-backend integration
  • Real-time notifications
  • Advanced map visualization
  • Mobile app development

πŸ“‹ Planned Features

  • WebSocket support for real-time updates
  • Push notifications (web & mobile)
  • Analytics dashboard
  • Admin panel
  • Report comments & discussions
  • Social sharing
  • Multi-language support

πŸ“„ License

This project is developed as part of Smart India Hackathon 2025.


πŸ“ž Support

For help and support:

  1. Check documentation:

  2. Review test results:

  3. Check logs:

    • backend/logs/error.log
    • backend/logs/request.log
  4. Test interactively:


πŸŽ“ Learning Resources


Project Status: βœ… Backend Complete | 🚧 Frontend In Progress
Last Updated: 2025-01-28
Version: 1.0.0


Made with ❀️ for Smart India Hackathon 2025

About

Prototype version

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors