help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
real-estate-bot
RSK World
real-estate-bot
Real Estate Bot - Python + Flask + OpenAI + SQLite + Property Search + AI Chatbot + Viewing Scheduler
real-estate-bot
  • __pycache__
  • data
  • src
  • static
  • templates
  • tests
  • .env608 B
  • .env.example608 B
  • .gitignore2.5 KB
  • AR_VR_FEATURES.md4.2 KB
  • CREATE_RELEASE.md2.1 KB
  • FEATURES.md6.1 KB
  • INSTALL.md2 KB
  • LICENSE1.3 KB
  • README.md7.8 KB
  • RELEASE_NOTES_v1.0.0.md7.3 KB
  • SETUP_GUIDE.md10.4 KB
  • STATUS_REPORT.md11.8 KB
  • requirements-optional.txt984 B
  • requirements.txt284 B
  • run.py2.7 KB
.gitignoreindex.html500.htmldatabase.pyneighborhood_analyzer.py
.gitignore
Raw Download
Find: Go to:
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
#   However, in case of collaboration, if having platform-specific dependencies or dependencies
#   having no cross-platform support, pipenv may install dependencies that don't work, or not
#   install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Project specific
real_estate_bot.db
*.db
*.sqlite
*.sqlite3

# Logs
logs/
*.log

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Temporary files
tmp/
temp/
*.tmp
*.temp

# Node modules (if using npm for frontend dependencies)
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Frontend build artifacts
static/dist/
static/build/

# Backup files
*.bak
*.backup
*.old

# Configuration files with sensitive data
config.json
secrets.json
credentials.json

# Upload directories
uploads/
media/
186 lines•2.5 KB
text
templates/index.html
Raw Download
Find: Go to:
<!DOCTYPE html>
<!--
Real Estate Bot - Main Interface
Author: RSK World (https://rskworld.in)
Founded by: Molla Samser
Designer & Tester: Rima Khatun
Contact: info@rskworld.com, +91 93305 39277
Year: 2026
Description: Real estate chatbot for property search, inquiries, and scheduling viewings
-->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Real Estate Bot - Find Your Dream Property</title>
    <meta name="description" content="AI-powered real estate chatbot for property search, inquiries, and scheduling viewings">
    <meta name="author" content="RSK World">
    <meta name="keywords" content="real estate, chatbot, property search, AI, RSK World">
    
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
    
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #3498db;
            --accent-color: #e74c3c;
            --success-color: #27ae60;
            --light-bg: #ecf0f1;
            --dark-text: #2c3e50;
        }
        
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            margin: 0;
            padding: 0;
        }
        
        .main-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        
        .header {
            text-align: center;
            color: white;
            margin-bottom: 30px;
            animation: fadeInDown 0.8s ease;
        }
        
        .header h1 {
            font-size: 2.5rem;
            font-weight: 700;
            margin-bottom: 10px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
        }
        
        .header p {
            font-size: 1.2rem;
            opacity: 0.9;
        }
        
        .chat-container {
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            overflow: hidden;
            animation: fadeInUp 0.8s ease;
        }
        
        .chat-header {
            background: var(--primary-color);
            color: white;
            padding: 20px;
            text-align: center;
            position: relative;
        }
        
        .chat-header h3 {
            margin: 0;
            font-size: 1.5rem;
        }
        
        .status-indicator {
            display: inline-block;
            width: 10px;
            height: 10px;
            background: #27ae60;
            border-radius: 50%;
            margin-left: 10px;
            animation: pulse 2s infinite;
        }
        
        .chat-messages {
            height: 500px;
            overflow-y: auto;
            padding: 20px;
            background: #f8f9fa;
        }
        
        .message {
            margin-bottom: 15px;
            animation: slideIn 0.3s ease;
        }
        
        .message.user {
            text-align: right;
        }
        
        .message.bot {
            text-align: left;
        }
        
        .message-bubble {
            display: inline-block;
            max-width: 70%;
            padding: 12px 18px;
            border-radius: 18px;
            word-wrap: break-word;
        }
        
        .message.user .message-bubble {
            background: var(--secondary-color);
            color: white;
            border-bottom-right-radius: 4px;
        }
        
        .message.bot .message-bubble {
            background: white;
            color: var(--dark-text);
            border: 1px solid #e0e0e0;
            border-bottom-left-radius: 4px;
        }
        
        .message-time {
            font-size: 0.75rem;
            color: #999;
            margin-top: 5px;
        }
        
        .typing-indicator {
            display: none;
            text-align: left;
            margin-bottom: 15px;
        }
        
        .typing-indicator .message-bubble {
            background: white;
            border: 1px solid #e0e0e0;
            padding: 15px 20px;
        }
        
        .typing-dots {
            display: inline-block;
        }
        
        .typing-dots span {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #999;
            margin: 0 2px;
            animation: typing 1.4s infinite;
        }
        
        .typing-dots span:nth-child(2) {
            animation-delay: 0.2s;
        }
        
        .typing-dots span:nth-child(3) {
            animation-delay: 0.4s;
        }
        
        .chat-input-container {
            padding: 20px;
            background: white;
            border-top: 1px solid #e0e0e0;
        }
        
        .chat-input {
            display: flex;
            gap: 10px;
        }
        
        .chat-input input {
            flex: 1;
            border: 2px solid #e0e0e0;
            border-radius: 25px;
            padding: 12px 20px;
            font-size: 16px;
            outline: none;
            transition: border-color 0.3s ease;
        }
        
        .chat-input input:focus {
            border-color: var(--secondary-color);
        }
        
        .chat-input button {
            background: var(--secondary-color);
            color: white;
            border: none;
            border-radius: 50%;
            width: 50px;
            height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        
        .chat-input button:hover {
            background: #2980b9;
        }
        
        .quick-actions {
            padding: 15px 20px;
            background: #f8f9fa;
            border-top: 1px solid #e0e0e0;
        }
        
        .quick-actions h6 {
            margin-bottom: 10px;
            color: var(--dark-text);
        }
        
        .quick-action-btn {
            background: white;
            border: 1px solid #e0e0e0;
            border-radius: 20px;
            padding: 8px 16px;
            margin: 5px;
            font-size: 0.9rem;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .quick-action-btn:hover {
            background: var(--secondary-color);
            color: white;
            border-color: var(--secondary-color);
        }
        
        .features-section {
            margin-top: 30px;
            background: white;
            border-radius: 15px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }
        
        .feature-card {
            text-align: center;
            padding: 20px;
            border-radius: 10px;
            background: #f8f9fa;
            transition: transform 0.3s ease;
        }
        
        .feature-card:hover {
            transform: translateY(-5px);
        }
        
        .feature-icon {
            font-size: 2.5rem;
            color: var(--secondary-color);
            margin-bottom: 15px;
        }
        
        .footer {
            text-align: center;
            color: white;
            margin-top: 30px;
            padding: 20px;
        }
        
        .footer a {
            color: white;
            text-decoration: none;
        }
        
        .footer a:hover {
            text-decoration: underline;
        }
        
        @keyframes fadeInDown {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateX(-20px);
            }
            to {
                opacity: 1;
                transform: translateX(0);
            }
        }
        
        @keyframes pulse {
            0%, 100% {
                opacity: 1;
            }
            50% {
                opacity: 0.5;
            }
        }
        
        @keyframes typing {
            0%, 60%, 100% {
                transform: translateY(0);
            }
            30% {
                transform: translateY(-10px);
            }
        }
        
        @media (max-width: 768px) {
            .header h1 {
                font-size: 2rem;
            }
            
            .chat-messages {
                height: 400px;
            }
            
            .message-bubble {
                max-width: 85%;
            }
            
            .features-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="main-container">
        <!-- Header -->
        <div class="header">
            <h1><i class="fas fa-home"></i> Real Estate Bot</h1>
            <p>Your AI-powered assistant for finding the perfect property</p>
        </div>
        
        <!-- Chat Container -->
        <div class="chat-container">
            <div class="chat-header">
                <h3>Property Assistant <span class="status-indicator"></span></h3>
                <small>Powered by RSK World • Online</small>
            </div>
            
            <div class="chat-messages" id="chatMessages">
                <div class="message bot">
                    <div class="message-bubble">
                        Hello! šŸ‘‹ I'm your Real Estate Assistant. I can help you find properties, schedule viewings, and answer all your real estate questions. What are you looking for today?
                    </div>
                    <div class="message-time">Just now</div>
                </div>
            </div>
            
            <div class="typing-indicator" id="typingIndicator">
                <div class="message-bubble">
                    <div class="typing-dots">
                        <span></span>
                        <span></span>
                        <span></span>
                    </div>
                </div>
            </div>
            
            <div class="quick-actions">
                <h6>Quick Actions:</h6>
                <button class="quick-action-btn" onclick="sendQuickMessage('Show me available apartments')">
                    <i class="fas fa-building"></i> Show Apartments
                </button>
                <button class="quick-action-btn" onclick="sendQuickMessage('Find houses under 1 crore')">
                    <i class="fas fa-home"></i> Budget Homes
                </button>
                <button class="quick-action-btn" onclick="sendQuickMessage('Schedule a property viewing')">
                    <i class="fas fa-calendar"></i> Schedule Viewing
                </button>
                <button class="quick-action-btn" onclick="sendQuickMessage('Tell me about Mumbai properties')">
                    <i class="fas fa-map-marker-alt"></i> Location Info
                </button>
            </div>
            
            <div class="chat-input-container">
                <div class="chat-input">
                    <input type="text" id="messageInput" placeholder="Type your message here..." onkeypress="handleKeyPress(event)">
                    <button onclick="sendMessage()">
                        <i class="fas fa-paper-plane"></i>
                    </button>
                </div>
            </div>
        </div>
        
        <!-- Features Section -->
        <div class="features-section">
            <h3 class="text-center mb-4">Features</h3>
            <div class="features-grid">
                <div class="feature-card">
                    <div class="feature-icon">
                        <i class="fas fa-search"></i>
                    </div>
                    <h5>Property Search</h5>
                    <p>Find properties based on location, price, type, and preferences</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">
                        <i class="fas fa-calendar-check"></i>
                    </div>
                    <h5>Viewing Scheduling</h5>
                    <p>Schedule property viewings at your convenience</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">
                        <i class="fas fa-info-circle"></i>
                    </div>
                    <h5>Property Details</h5>
                    <p>Get comprehensive information about any property</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">
                        <i class="fas fa-comments"></i>
                    </div>
                    <h5>24/7 Support</h5>
                    <p>Get instant answers to your real estate questions</p>
                </div>
            </div>
        </div>
        
        <!-- Footer -->
        <div class="footer">
            <p>&copy; 2026 RSK World. All rights reserved.</p>
            <p>
                Developed by <a href="https://rskworld.in" target="_blank">RSK World</a> • 
                Contact: <a href="mailto:info@rskworld.com">info@rskworld.com</a> • 
                <a href="tel:+919330539277">+91 93305 39277</a>
            </p>
            <p>
                <small>Founded by Molla Samser | Designer & Tester: Rima Khatun</small>
            </p>
        </div>
    </div>
    
    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- Custom JS -->
    <script src="{{ url_for('static', filename='js/chat.js') }}"></script>
    
    <script>
        // Initialize chat
        document.addEventListener('DOMContentLoaded', function() {
            initializeChat();
        });
        
        function handleKeyPress(event) {
            if (event.key === 'Enter') {
                sendMessage();
            }
        }
        
        function sendQuickMessage(message) {
            document.getElementById('messageInput').value = message;
            sendMessage();
        }
        
        function scrollToBottom() {
            const chatMessages = document.getElementById('chatMessages');
            chatMessages.scrollTop = chatMessages.scrollHeight;
        }
        
        function formatTime() {
            const now = new Date();
            return now.toLocaleTimeString('en-US', { 
                hour: '2-digit', 
                minute: '2-digit' 
            });
        }
        
        function addMessage(content, isUser = false) {
            const chatMessages = document.getElementById('chatMessages');
            const messageDiv = document.createElement('div');
            messageDiv.className = `message ${isUser ? 'user' : 'bot'}`;
            
            messageDiv.innerHTML = `
                <div class="message-bubble">${content}</div>
                <div class="message-time">${formatTime()}</div>
            `;
            
            chatMessages.appendChild(messageDiv);
            scrollToBottom();
        }
        
        function showTypingIndicator() {
            document.getElementById('typingIndicator').style.display = 'block';
            scrollToBottom();
        }
        
        function hideTypingIndicator() {
            document.getElementById('typingIndicator').style.display = 'none';
        }
        
        async function sendMessage() {
            const input = document.getElementById('messageInput');
            const message = input.value.trim();
            
            if (!message) return;
            
            // Add user message
            addMessage(message, true);
            input.value = '';
            
            // Show typing indicator
            showTypingIndicator();
            
            try {
                const response = await fetch('/api/chat', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({
                        message: message
                    })
                });
                
                const data = await response.json();
                
                hideTypingIndicator();
                
                if (data.success) {
                    addMessage(data.response);
                } else {
                    addMessage('Sorry, I encountered an error. Please try again.');
                }
                
            } catch (error) {
                hideTypingIndicator();
                addMessage('Connection error. Please check your internet connection and try again.');
            }
        }
        
        function initializeChat() {
            // Focus on input
            document.getElementById('messageInput').focus();
            
            // Add welcome message with delay
            setTimeout(() => {
                addMessage('I can help you with:\n\n• šŸ  Property search by location, price, and type\n• šŸ“… Schedule property viewings\n• šŸ’¬ Answer questions about properties\n• šŸ“ Provide location information\n\nWhat would you like to explore today?');
            }, 1000);
        }
    </script>
</body>
</html>
591 lines•18.5 KB
markup
templates/500.html
Raw Download
Find: Go to:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>500 - Server Error | Real Estate Bot</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        .error-container {
            text-align: center;
            color: white;
            padding: 40px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 20px;
            backdrop-filter: blur(10px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .error-code {
            font-size: 8rem;
            font-weight: 700;
            margin-bottom: 20px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
        }
        .error-message {
            font-size: 1.5rem;
            margin-bottom: 30px;
        }
        .btn-home {
            background: white;
            color: #667eea;
            padding: 12px 30px;
            border-radius: 25px;
            text-decoration: none;
            font-weight: 600;
            transition: all 0.3s ease;
            display: inline-block;
            margin-right: 10px;
        }
        .btn-home:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
            color: #667eea;
        }
        .btn-retry {
            background: rgba(255, 255, 255, 0.2);
            color: white;
            padding: 12px 30px;
            border-radius: 25px;
            text-decoration: none;
            font-weight: 600;
            transition: all 0.3s ease;
            display: inline-block;
            border: 2px solid white;
        }
        .btn-retry:hover {
            background: white;
            color: #667eea;
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
        }
    </style>
</head>
<body>
    <div class="error-container">
        <div class="error-code">
            <i class="fas fa-exclamation-triangle"></i> 500
        </div>
        <h1 class="error-message">Internal Server Error</h1>
        <p>We're sorry, but something went wrong on our end. Our team has been notified and is working to fix the issue.</p>
        <div style="margin-top: 30px;">
            <a href="/" class="btn-home">
                <i class="fas fa-arrow-left"></i> Go Back Home
            </a>
            <a href="javascript:location.reload()" class="btn-retry">
                <i class="fas fa-redo"></i> Try Again
            </a>
        </div>
        <p style="margin-top: 30px; font-size: 0.9rem; opacity: 0.8;">
            If the problem persists, please contact us at <a href="mailto:info@rskworld.com" style="color: white;">info@rskworld.com</a> or call +91 93305 39277
        </p>
    </div>
</body>
</html>
93 lines•3.3 KB
markup
src/neighborhood_analyzer.py
Raw Download
Find: Go to:
"""
Neighborhood Insights and Crime Rate Analysis
Author: RSK World (https://rskworld.in)
Founded by: Molla Samser
Designer & Tester: Rima Khatun
Contact: info@rskworld.com, +91 93305 39277
Year: 2026
"""

import os
import requests
import json
from typing import Dict, Any, List
from datetime import datetime
import numpy as np

class NeighborhoodAnalyzer:
    def __init__(self):
        self.api_keys = {
            'google_places': os.getenv('GOOGLE_PLACES_API_KEY'),
            'crime_api': os.getenv('CRIME_API_KEY')
        }
    
    def analyze_neighborhood(self, location: str) -> Dict[str, Any]:
        """Comprehensive neighborhood analysis"""
        return {
            'safety_score': self._get_safety_score(location),
            'amenities': self._get_nearby_amenities(location),
            'schools': self._get_school_ratings(location),
            'transport': self._get_transport_info(location),
            'demographics': self._get_demographics(location)
        }
    
    def _get_safety_score(self, location: str) -> float:
        """Get safety score for location (0-10 scale)"""
        # This would typically use crime data APIs
        # For now, return a mock score based on location
        location_lower = location.lower()
        
        # Higher safety scores for major metropolitan areas
        if any(city in location_lower for city in ['mumbai', 'bangalore', 'pune', 'hyderabad']):
            return 7.5
        elif any(city in location_lower for city in ['delhi', 'chennai', 'kolkata']):
            return 7.0
        else:
            return 6.5  # Default score
    
    def _get_nearby_amenities(self, location: str) -> List[Dict[str, Any]]:
        """Get nearby amenities for location"""
        # This would typically use Google Places API
        # For now, return mock data
        amenities = [
            {'type': 'hospital', 'name': 'Nearby Hospital', 'distance': '2 km', 'rating': 4.5},
            {'type': 'school', 'name': 'Local School', 'distance': '1 km', 'rating': 4.2},
            {'type': 'shopping', 'name': 'Shopping Mall', 'distance': '3 km', 'rating': 4.3},
            {'type': 'restaurant', 'name': 'Restaurant Hub', 'distance': '1.5 km', 'rating': 4.4},
            {'type': 'park', 'name': 'Community Park', 'distance': '0.5 km', 'rating': 4.6}
        ]
        return amenities
    
    def _get_school_ratings(self, location: str) -> Dict[str, Any]:
        """Get school ratings for location"""
        # Mock data - would use education APIs in production
        return {
            'primary_schools': [
                {'name': 'Local Primary School', 'rating': 4.3, 'distance': '1 km'},
                {'name': 'Community Primary', 'rating': 4.1, 'distance': '1.5 km'}
            ],
            'secondary_schools': [
                {'name': 'Local Secondary School', 'rating': 4.5, 'distance': '2 km'},
                {'name': 'High School', 'rating': 4.4, 'distance': '2.5 km'}
            ],
            'colleges': [
                {'name': 'Nearby College', 'rating': 4.2, 'distance': '5 km'}
            ],
            'average_rating': 4.3
        }
    
    def _get_transport_info(self, location: str) -> Dict[str, Any]:
        """Get transportation information for location"""
        # Mock data - would use transit APIs in production
        location_lower = location.lower()
        
        has_metro = any(city in location_lower for city in ['delhi', 'bangalore', 'mumbai', 'chennai', 'kolkata', 'hyderabad'])
        
        return {
            'metro_available': has_metro,
            'metro_stations': [
                {'name': 'Nearest Metro Station', 'distance': '2 km', 'line': 'Blue Line'}
            ] if has_metro else [],
            'bus_stops': [
                {'name': 'Bus Stop 1', 'distance': '0.3 km'},
                {'name': 'Bus Stop 2', 'distance': '0.5 km'}
            ],
            'railway_station': {
                'name': 'Nearest Railway Station',
                'distance': '5 km',
                'available': True
            },
            'airport_distance': '25 km',
            'connectivity_score': 8.5 if has_metro else 7.0
        }
    
    def _get_demographics(self, location: str) -> Dict[str, Any]:
        """Get demographic information for location"""
        # Mock demographic data - would use census/statistics APIs in production
        return {
            'population_density': 'Medium',
            'average_age': 32,
            'family_composition': {
                'families_with_children': 65,
                'young_professionals': 25,
                'senior_citizens': 10
            },
            'income_level': 'Upper Middle Class',
            'languages_spoken': ['Hindi', 'English', 'Local Language'],
            'religious_diversity': 'High',
            'education_level': 'Above Average'
        }
    
    def get_location_rating(self, location: str) -> Dict[str, Any]:
        """Get overall location rating with factors"""
        analysis = self.analyze_neighborhood(location)
        
        # Calculate overall rating
        safety_score = analysis['safety_score']
        connectivity_score = analysis['transport'].get('connectivity_score', 7.0)
        amenities_count = len(analysis['amenities'])
        schools_rating = analysis['schools'].get('average_rating', 4.0)
        
        overall_rating = (
            (safety_score / 10) * 0.3 +
            (connectivity_score / 10) * 0.25 +
            (min(amenities_count, 10) / 10) * 0.25 +
            (schools_rating / 5) * 0.2
        ) * 10
        
        return {
            'location': location,
            'overall_rating': round(overall_rating, 2),
            'safety_rating': round(safety_score, 2),
            'connectivity_rating': round(connectivity_score, 1),
            'amenities_rating': round((amenities_count / 10) * 10, 1),
            'schools_rating': round((schools_rating / 5) * 10, 1),
            'factors': analysis,
            'recommendation': 'Excellent' if overall_rating >= 8 else 'Good' if overall_rating >= 7 else 'Average'
        }
147 lines•6.1 KB
python
šŸš€ Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work ā¤ļø

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer