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
/
src
/
__pycache__
RSK World
real-estate-bot
Real Estate Bot - Python + Flask + OpenAI + SQLite + Property Search + AI Chatbot + Viewing Scheduler
__pycache__
  • __init__.cpython-313.pyc678 B
  • ai_recommendation_engine.cpython-313.pyc21.9 KB
  • app.cpython-313.pyc10.3 KB
  • blockchain_integration.cpython-313.pyc2.2 KB
  • chatbot.cpython-313.pyc15.7 KB
  • database.cpython-313.pyc18.9 KB
  • image_enhancer.cpython-313.pyc9.6 KB
  • multilang_support.cpython-313.pyc9 KB
  • neighborhood_analyzer.cpython-313.pyc6.7 KB
  • price_prediction_engine.cpython-313.pyc28.5 KB
  • property_search.cpython-313.pyc16 KB
  • virtual_tour_manager.cpython-313.pyc23.2 KB
  • voice_assistant.cpython-313.pyc27 KB
.gitignoreapp.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
src/app.py
Raw Download
Find: Go to:
"""
Real Estate Chatbot Application
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
"""

import os
import sqlite3
from datetime import datetime
from flask import Flask, render_template, request, jsonify, session
try:
    from flask_cors import CORS
except ImportError:
    CORS = None
from dotenv import load_dotenv
try:
    from openai import OpenAI
    openai_available = True
except ImportError:
    OpenAI = None
    openai_available = False
from src.chatbot import RealEstateChatbot
from src.database import DatabaseManager
from src.property_search import PropertySearchEngine
from src.ai_recommendation_engine import AIRecommendationEngine
from src.virtual_tour_manager import VirtualTourManager
from src.price_prediction_engine import PricePredictionEngine
from src.voice_assistant import VoiceAssistant
from src.neighborhood_analyzer import NeighborhoodAnalyzer
from src.blockchain_integration import BlockchainPropertyManager
from src.image_enhancer import ImageEnhancer
from src.multilang_support import MultiLanguageSupport

# Load environment variables
load_dotenv()

app = Flask(__name__)
app.secret_key = os.getenv('SECRET_KEY', 'default_secret_key')
if CORS:
    CORS(app)

# Initialize OpenAI
if openai_available:
    openai_client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))
else:
    openai_client = None

# Initialize components with error handling
db_manager = DatabaseManager()
property_search = PropertySearchEngine()

try:
    chatbot = RealEstateChatbot(openai_client, property_search, db_manager)
except Exception as e:
    print(f"Chatbot not available: {e}")
    chatbot = None

try:
    ai_recommender = AIRecommendationEngine(db_manager)
except Exception as e:
    print(f"AI Recommendation Engine not available: {e}")
    ai_recommender = None

try:
    virtual_tour_manager = VirtualTourManager(db_manager)
except Exception as e:
    print(f"Virtual Tour Manager not available: {e}")
    virtual_tour_manager = None

try:
    price_predictor = PricePredictionEngine(db_manager)
except Exception as e:
    print(f"Price Prediction Engine not available: {e}")
    price_predictor = None

try:
    voice_assistant = VoiceAssistant(chatbot, db_manager)
except Exception as e:
    print(f"Voice Assistant not available: {e}")
    voice_assistant = None

try:
    neighborhood_analyzer = NeighborhoodAnalyzer()
except Exception as e:
    print(f"Neighborhood Analyzer not available: {e}")
    neighborhood_analyzer = None

try:
    blockchain_manager = BlockchainPropertyManager()
except Exception as e:
    print(f"Blockchain Manager not available: {e}")
    blockchain_manager = None

try:
    image_enhancer = ImageEnhancer()
except Exception as e:
    print(f"Image Enhancer not available: {e}")
    image_enhancer = None

try:
    multilang_support = MultiLanguageSupport()
except Exception as e:
    print(f"Multi-Language Support not available: {e}")
    multilang_support = None

@app.route('/')
def index():
    """Render the main chat interface"""
    return render_template('index.html')

@app.route('/api/chat', methods=['POST'])
def chat():
    """Handle chat messages"""
    try:
        if chatbot is None:
            return jsonify({
                'success': False,
                'error': 'Chatbot is not available. Please check the configuration.'
            }), 503
        
        data = request.get_json()
        user_message = data.get('message', '')
        user_id = session.get('user_id', 'anonymous')
        
        # Get chatbot response
        response = chatbot.process_message(user_message, user_id)
        
        return jsonify({
            'success': True,
            'response': response,
            'timestamp': datetime.now().isoformat()
        })
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500

@app.route('/api/properties/search', methods=['POST'])
def search_properties():
    """Search for properties based on criteria"""
    try:
        data = request.get_json()
        criteria = data.get('criteria', {})
        
        properties = property_search.search(criteria)
        
        return jsonify({
            'success': True,
            'properties': properties,
            'count': len(properties)
        })
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500

@app.route('/api/properties/<int:property_id>')
def get_property(property_id):
    """Get detailed information about a specific property"""
    try:
        property_info = property_search.get_property_by_id(property_id)
        
        if property_info:
            return jsonify({
                'success': True,
                'property': property_info
            })
        else:
            return jsonify({
                'success': False,
                'error': 'Property not found'
            }), 404
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500

@app.route('/api/appointments/schedule', methods=['POST'])
def schedule_appointment():
    """Schedule a property viewing"""
    try:
        data = request.get_json()
        user_id = session.get('user_id', 'anonymous')
        
        appointment_id = db_manager.schedule_appointment(
            user_id=user_id,
            property_id=data.get('property_id'),
            date_time=data.get('date_time'),
            contact_info=data.get('contact_info')
        )
        
        return jsonify({
            'success': True,
            'appointment_id': appointment_id,
            'message': 'Appointment scheduled successfully'
        })
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500

@app.route('/api/appointments/<user_id>')
def get_appointments(user_id):
    """Get user's scheduled appointments"""
    try:
        appointments = db_manager.get_user_appointments(user_id)
        
        return jsonify({
            'success': True,
            'appointments': appointments
        })
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500

@app.route('/api/inquiries/submit', methods=['POST'])
def submit_inquiry():
    """Submit a property inquiry"""
    try:
        data = request.get_json()
        user_id = session.get('user_id', 'anonymous')
        
        inquiry_id = db_manager.create_inquiry(
            user_id=user_id,
            property_id=data.get('property_id'),
            message=data.get('message'),
            contact_info=data.get('contact_info')
        )
        
        return jsonify({
            'success': True,
            'inquiry_id': inquiry_id,
            'message': 'Inquiry submitted successfully'
        })
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500

@app.errorhandler(404)
def not_found(error):
    return render_template('404.html'), 404

@app.errorhandler(500)
def internal_error(error):
    return render_template('500.html'), 500

if __name__ == '__main__':
    # Initialize database
    db_manager.initialize_database()
    
    # Run the application
    host = os.getenv('FLASK_HOST', '0.0.0.0')
    port = int(os.getenv('FLASK_PORT', os.environ.get('PORT', 5000)))
    debug = os.getenv('FLASK_DEBUG', 'False').lower() == 'true'
    app.run(host=host, port=port, debug=debug)
268 lines•7.8 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