Spaces:
Sleeping
A newer version of the Gradio SDK is available: 6.26.0
Chatty Installation Guide
This guide provides step-by-step instructions for installing and configuring the Chatty application.
System Requirements
- Python: 3.8 or higher
- Database: MongoDB (Atlas recommended) or local MongoDB installation
- Memory: Minimum 512MB RAM
- Storage: 100MB free space
- Network: Internet connection for external API calls
Installation Methods
Method 1: Quick Start (Recommended)
Clone and Setup
git clone <repository-url> cd chatty python -m venv atlas_env source atlas_env/bin/activate # Windows: atlas_env\Scripts\activate pip install -r requirements.txtConfigure Environment
python deploy.py setup-devEdit Configuration Edit
.envfile with your MongoDB connection details:SECRET_KEY=your-generated-secret-key MONGODB_URL=your-mongodb-connection-stringStart Application
./start.sh
Method 2: Manual Installation
Step 1: System Preparation
Ubuntu/Debian:
sudo apt update
sudo apt install python3 python3-pip python3-venv git
macOS:
# Install Homebrew if not installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install python3 git
Windows:
- Install Python from python.org
- Install Git from git-scm.com
Step 2: Application Setup
Clone Repository
git clone <repository-url> cd chattyCreate Virtual Environment
python3 -m venv atlas_env # Activate virtual environment # Linux/macOS: source atlas_env/bin/activate # Windows: atlas_env\Scripts\activateInstall Dependencies
pip install --upgrade pip pip install -r requirements.txt
Step 3: Database Setup
Choose one of the following database options:
Option A: MongoDB Atlas (Cloud - Recommended)
- Create account at MongoDB Atlas
- Create new cluster (free tier available)
- Create database user:
- Username:
chatty_user - Password: Generate secure password
- Roles:
readWriteon your database
- Username:
- Configure network access:
- Add your IP address
- Or allow access from anywhere (0.0.0.0/0) for development
- Get connection string from "Connect" → "Connect your application"
Option B: Local MongoDB
Install MongoDB
Ubuntu/Debian:
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add - echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list sudo apt update sudo apt install -y mongodb-orgmacOS:
brew tap mongodb/brew brew install mongodb-communityWindows: Download installer from MongoDB Download Center
Start MongoDB Service
Ubuntu/Debian:
sudo systemctl start mongod sudo systemctl enable mongodmacOS:
brew services start mongodb/brew/mongodb-communityWindows: MongoDB runs as a Windows service after installation
Create Database and User
mongoshuse chatty db.createUser({ user: "chatty_user", pwd: "your_secure_password", roles: [{ role: "readWrite", db: "chatty" }] })
Step 4: Configuration
Generate Configuration
python deploy.py setup-devEdit Environment File Edit
.envfile:For MongoDB Atlas:
SECRET_KEY=your-generated-secret-key MONGODB_URL=mongodb+srv://chatty_user:password@cluster.mongodb.net/chatty?retryWrites=true&w=majority MONGODB_DATABASE=chatty FLASK_ENV=developmentFor Local MongoDB:
SECRET_KEY=your-generated-secret-key MONGODB_URL=mongodb://chatty_user:password@localhost:27017/chatty MONGODB_DATABASE=chatty FLASK_ENV=developmentGenerate Secret Key
python deploy.py gen-secretCopy the generated key to your
.envfile.
Step 5: Validation and Testing
Validate Configuration
python config.pyTest Database Connection
python -c "from database import test_connection; test_connection()"Run Tests (Optional)
pip install -r Test/test_requirements.txt python Test/run_tests.py
Step 6: Start Application
Start with Script
chmod +x start.sh ./start.shOr Start Manually
python app.pyAccess Application Open browser to: http://localhost:7860
Post-Installation Setup
Create First User Account
- Navigate to http://localhost:7860
- Click "Register" to create your first account
- Fill in email and password
- Log in with your credentials
Verify Installation
Check Application Health
curl http://localhost:7860/healthTest Authentication
- Register a new account
- Log in and out
- Send a test chat message
Check Logs Monitor console output for any errors
Configuration Options
Environment Variables
Create or edit .env file with these options:
# Required
SECRET_KEY=your-64-character-secret-key
MONGODB_URL=your-mongodb-connection-string
MONGODB_DATABASE=chatty
# Optional
FLASK_ENV=development
SESSION_LIFETIME_HOURS=24
MAX_LOGIN_ATTEMPTS=5
RATE_LIMIT_WINDOW=900
API_TIMEOUT=30
LOG_LEVEL=INFO
PORT=7860
Advanced Configuration
For production deployment, see PRODUCTION_DEPLOYMENT.md.
Troubleshooting
Common Installation Issues
Python Version Issues
python --version # Should be 3.8+ python3 --versionVirtual Environment Issues
# Recreate virtual environment rm -rf atlas_env python3 -m venv atlas_env source atlas_env/bin/activate pip install -r requirements.txtMongoDB Connection Issues
# Test connection manually python -c " from pymongo import MongoClient client = MongoClient('your-connection-string') print(client.admin.command('ping')) "Permission Issues (Linux/macOS)
chmod +x start.sh chmod +x deploy.pyPort Already in Use
# Find process using port 7860 lsof -i :7860 # Kill process or change PORT in .env
Error Messages
"MONGODB_URL environment variable is required"
- Check
.envfile exists and containsMONGODB_URL - Verify environment variable is set correctly
"Configuration validation failed"
- Run
python config.pyto see specific issues - Check all required environment variables are set
"Database connection failed"
- Verify MongoDB is running (local) or accessible (Atlas)
- Check connection string format
- Verify credentials and network access
"Secret key errors"
- Generate new secret key:
python deploy.py gen-secret - Ensure key is at least 32 characters long
Getting Help
Check Logs
- Console output during startup
- Application logs if
LOG_FILEis configured
Validate Setup
python deploy.py check-prod # Even for development python config.pyTest Components
# Test database python -c "from database import test_connection; test_connection()" # Test configuration python -c "from config import validate_environment; validate_environment()"
Next Steps
After successful installation:
- Production Deployment: See PRODUCTION_DEPLOYMENT.md
- Customization: Modify templates and styles in
templates/andstatic/ - Monitoring: Set up logging and monitoring for production use
- Backup: Configure regular database backups
- Updates: Keep dependencies updated with
pip install -r requirements.txt --upgrade
Uninstallation
To remove the application:
Stop Application
- Press Ctrl+C if running in terminal
- Or stop systemd service if configured
Remove Files
# Remove application directory rm -rf /path/to/chatty # Remove virtual environment rm -rf atlas_envRemove Database (Optional)
- For MongoDB Atlas: Delete cluster from Atlas dashboard
- For local MongoDB: Drop database in MongoDB shell
use chatty db.dropDatabase()Remove System Dependencies (Optional)
- Uninstall MongoDB if no longer needed
- Remove Python if installed specifically for this application