A comprehensive platform for coastal safety monitoring, emergency reporting, and community engagement.
- New to the project? β QUICK_START.md - Start here!
- Backend setup? β backend/GETTING_STARTED.md - Comprehensive guide
- Frontend setup? β frontend/README.md
- API Reference β backend/API_REFERENCE.md
- Test Results β backend/COMPLETE_TEST_RESULTS.md
- Testing Guide β QUICK_TESTING_GUIDE.md
- Backend (Python/FastAPI) β backend/
- Frontend (Next.js/React) β frontend/
- Mobile (Flutter) β flutter_application/
Samudra Sahayak is a full-stack application designed to help coastal communities report emergencies, receive alerts, and stay informed about coastal safety conditions.
- Email/phone registration with verification
- JWT-based secure authentication
- Role-based access (Citizen, Official)
- Guest mode for quick reporting
- Password reset via email
- 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)
- Official alerts creation (government officials only)
- Geospatial area-based alerts
- Alert expiration and status tracking
- Push notifications (planned)
- Visualize reports and alerts on map
- Filter by location, type, and severity
- Real-time updates
- Activity tracking
- Report statistics
- Profile management
- Notification preferences
- Voice-to-text transcription
- AI analysis via Gemini API
- Automatic hazard detection
- Sentiment and urgency analysis
- 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
- Framework: Next.js 14
- UI Library: Tailwind CSS + shadcn/ui
- State Management: Redux Toolkit
- Maps: Leaflet + React-Leaflet
- HTTP Client: Axios
- Framework: Flutter 3.x
- State Management: Provider/Riverpod
- Maps: Google Maps Flutter
- Storage: SharedPreferences
- 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)
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
cd frontend
npm install
npm run devβ Frontend will run at: http://localhost:3000
cd backend
python test_api.pyβ Expected: All 8 scenarios passing (100%)
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
The backend includes a comprehensive test suite covering all functionality:
cd backend
python test_api.pyTest Scenarios:
- β User Registration & Email Verification
- β Report Submission (Text + Image Upload)
- β Report Fetching (Geospatial Queries)
- β User Login (Email & Phone)
- β Alert Creation (Official Role)
- β Profile & Settings Updates
- β Activity Tracking
- β Reports Endpoint Comparison
Current Status: All 8 scenarios passing β (100% success rate)
See COMPLETE_TEST_RESULTS.md for detailed results.
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.env files are excluded from git. Never commit credentials!
- Register, login, logout
- Email verification
- Password reset
- Guest mode
- Token refresh
- Create, read, update, delete
- Geospatial filtering
- User-specific reports
- Create, read, update, delete (officials only)
- Area-based geospatial queries
- Profile CRUD
- Settings management
- Activity tracking
- User statistics
- Signed URL generation
- File verification
- URL refresh
- Combined reports + alerts
- Geospatial data for visualization
Total: 30+ documented endpoints
See API_REFERENCE.md for complete documentation.
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=trueImplementation:
- Uses
$geoWithinwith$centerSpherefor radius searches - 2dsphere indexes on
locationandaffectedAreafields - Supports custom sorting (by date, severity, etc.)
Secure file uploads via signed URLs:
- Client requests signed URL from backend
- Backend generates GCS signed URL (valid for 1 hour)
- Client uploads directly to Google Cloud Storage
- File URL stored in database with expiration tracking
- Download URLs auto-refresh when expired
Supported file types:
- Images: JPEG, PNG, WebP
- Videos: MP4, MOV, AVI
- Audio: MP3, WAV, M4A
AI-powered voice report analysis:
- User records audio message
- Uploaded to Google Cloud Storage
- Gemini AI transcribes audio to text
- AI analyzes content for:
- Hazard type detection
- Severity assessment
- Location extraction
- Urgency level
- Sentiment analysis
- Structured report created automatically
-
Start backend:
cd backend sih\Scripts\activate cd sih python main.py
-
Start frontend:
cd frontend npm run dev -
Make changes - Server auto-reloads on file changes
-
Test changes:
- Use Swagger UI: http://localhost:8000/docs
- Test from frontend: http://localhost:3000
- Run test suite:
python backend/test_api.py
-
Run tests:
cd backend python test_api.py -
Check for errors:
- Review
backend/logs/error.log - Check console for warnings
- Review
-
Update documentation if API changed
-
Commit with descriptive message:
git add . git commit -m "feat: description of changes" git push
# 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- Check
MONGODB_URIin.envfile - Verify IP is whitelisted (MongoDB Atlas)
- Test connection:
python backend/check_geo.py
cd backend
sih\Scripts\activate
pip install -r requirements.txtcd frontend
npm install- Enable 2-Step Verification on Gmail
- Generate App Password (16 characters)
- Update
EMAIL_PASSin.env - Restart backend server
- Verify GCS credentials in
.env - Check bucket permissions
- Test with:
python backend/verify_gcs_simple.py
More troubleshooting: backend/GETTING_STARTED.md#troubleshooting
- 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
- Frontend-backend integration
- Real-time notifications
- Advanced map visualization
- Mobile app development
- WebSocket support for real-time updates
- Push notifications (web & mobile)
- Analytics dashboard
- Admin panel
- Report comments & discussions
- Social sharing
- Multi-language support
This project is developed as part of Smart India Hackathon 2025.
For help and support:
-
Check documentation:
-
Review test results:
-
Check logs:
backend/logs/error.logbackend/logs/request.log
-
Test interactively:
- FastAPI Documentation
- Next.js Documentation
- MongoDB Geospatial Queries
- JWT Best Practices
- Google Cloud Storage Python
Project Status: β
Backend Complete | π§ Frontend In Progress
Last Updated: 2025-01-28
Version: 1.0.0
Made with β€οΈ for Smart India Hackathon 2025