This is a comprehensive RAG (Retrieval-Augmented Generation) based system for UN/UN Habitat SDG file management and searching. The system automatically processes documents, classifies them by Sustainable Development Goals, and provides intelligent search capabilities with real-time transportation data integration.
- Python 3.9+
- PostgreSQL 13+
- Redis (for caching and background tasks)
- 8GB+ RAM recommended
- Internet connection for API calls
# Navigate to project directory
cd "C:\Users\Unsub_Log\OneDrive\Desktop\Project Vault\RAG BASED SYSTEM"
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On Mac/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt# Install PostgreSQL if not already installed
# Windows: Download from postgresql.org
# Mac: brew install postgresql
# Linux: sudo apt-get install postgresql postgresql-contrib
# Create database
createdb sdg_rag_db
# Install pgvector extension (run in psql)
psql -d sdg_rag_db -c "CREATE EXTENSION vector;"# Copy environment template
cp .env.example .env
# Edit .env file with your API keys:
# - OPENAI_API_KEY (required)
# - ANTHROPIC_API_KEY (optional)
# - TFL_API_KEY (for London transit data)
# - OPEN_CHARGE_MAP_API_KEY (for EV charging stations)
# - UBER_API_KEY (for ride-sharing data)
# - DATABASE_URL (PostgreSQL connection string)# Start the API server
python main.py
# The system will be available at:
# http://localhost:8000
# API Documentation: http://localhost:8000/docs- Upload: PDF, DOCX, TXT, MD, PPTX files
- AI Classification: Automatic SDG goal classification
- Text Extraction: Advanced document parsing
- Vector Storage: Semantic search capabilities
- Semantic Search: Find documents by meaning, not just keywords
- SDG Filtering: Search by specific Sustainable Development Goals
- Similar Documents: Find related content automatically
- Public Transit: London TfL, and other city transit systems
- EV Infrastructure: Electric vehicle charging stations
- Aviation Data: Flight information and airport status
- Maritime Data: Vessel tracking and port information
- Ride-sharing: Uber and other mobility services
- Goal Classification: AI-powered SDG categorization
- Cross-reference Analysis: Find connections between goals
- Progress Tracking: Monitor SDG-related activities
- Dashboard Views: Comprehensive overview interfaces
POST /api/v1/documents/upload- Upload and process documentsGET /api/v1/documents/{document_id}- Get document informationDELETE /api/v1/documents/{document_id}- Delete documents
GET /api/v1/search/- Search documents with RAGGET /api/v1/search/semantic- Advanced semantic searchGET /api/v1/search/classify- Classify queries by SDG
GET /api/v1/sdg/goals- Get all SDG goalsGET /api/v1/sdg/goals/{goal_id}/documents- Get documents by SDGGET /api/v1/sdg/goals/overview- SDG overview dashboard
GET /api/v1/transportation/transit/london- London transit dataGET /api/v1/transportation/ev/charging-stations- EV charging stationsGET /api/v1/transportation/dashboard- Transportation dashboard
curl -X POST "http://localhost:8000/api/v1/documents/upload" \
-H "Content-Type: multipart/form-data" \
-F "file=@your_document.pdf"curl "http://localhost:8000/api/v1/search/?q=climate+action&sdg_goal=13&limit=10"curl "http://localhost:8000/api/v1/transportation/ev/charging-stations?latitude=51.5074&longitude=-0.1278&radius=10"The system integrates with numerous transportation APIs from the public-apis repository:
- Open Charge Map - EV infrastructure (SDG 7, 11, 13)
- Transport for London - Urban mobility (SDG 11)
- TransitLand - Global transit aggregation (SDG 11)
- ADS-B Exchange - Aviation monitoring (SDG 9, 11)
- Smartcar - Vehicle telematics (SDG 11, 13)
- Add API keys to
.envfile - Enable specific endpoints in configuration
- Monitor rate limits and usage quotas
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Web Frontend β β FastAPI β β AI Models β
β (React) βββββΊβ Backend βββββΊβ (OpenAI) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Vector DB β β PostgreSQL β β External APIs β
β (ChromaDB) β β (Metadata) β β (Transport) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- API Keys: Store securely in environment variables
- Data Privacy: Automatic PII removal from documents
- Access Control: Role-based permissions (configurable)
- Rate Limiting: Built-in API rate limiting
- Encryption: AES-256 for sensitive data
GET /health- System health statusGET /- API status and version
- Structured JSON logging
- Error tracking and alerting
- Performance metrics
- Horizontal scaling with load balancers
- Vector database sharding
- API gateway for high availability
- Fork the repository
- Create feature branch
- Make changes with tests
- Submit pull request
For issues and questions:
- Check API documentation at
/docs - Review logs for error details
- Verify API key configurations
- Check database connectivity
- Setup: Complete installation and configuration
- Test: Upload sample documents and test search
- Integrate: Add transportation API keys
- Customize: Adjust SDG classification prompts
- Deploy: Scale for production use
This system provides a comprehensive foundation for UN/UN Habitat SDG document management with real-time data integration and AI-powered search capabilities.