A sophisticated Personal AI Assistant built with Gemini API, Object-Oriented Programming (OOP), Streamlit, and MongoDB. Aurion provides intelligent assistance for learning, coding, productivity, and general queries with a modern ChatGPT-like interface.
- 💬 ChatGPT-like Interface - Clean, modern chat interface
- 🔐 User Authentication - Secure login and signup with MongoDB
- 🧠 Context Memory - Maintains conversation history across sessions
- 💾 Persistent Storage - Conversations saved permanently in MongoDB
- 🎭 Multiple Modes - General Assistant, Tutor, Coder, Career Mentor
- 💬 Multi-Conversation Support - Create and manage multiple conversations
- ⚡ Streaming Responses - Real-time response generation
- 🎤 Voice Commands - Speak to Aurion and get text responses
- 📱 Cross-Device Access - Access your conversations from anywhere
- ✅ Classes & Objects - Well-structured class hierarchy
- ✅ Encapsulation - Data hiding and controlled access
- ✅ Inheritance - Reusable and extensible code
- ✅ Modular Design - Separation of concerns
- 🔐 Password Hashing - SHA-256 encryption for secure password storage
- 🔐 Secure Sessions - Server-side session management with Streamlit
- 🔐 User Data Isolation - Each user's conversations are private
- 🔐 Environment Variables - API keys and sensitive data protection
- Python 3.10+
- Streamlit - Web interface
- Google Gemini API - AI intelligence
- MongoDB - Database for user authentication and data persistence
- PyMongo - MongoDB driver for Python
- SpeechRecognition - Voice input processing
- python-dotenv - Environment management
Aurion-OOp/
│
├── app.py # Main Streamlit application
│
├── auth/ # Authentication system
│ ├── __init__.py
│ └── auth_ui.py # Login/Signup UI components
│
├── database/ # Database management
│ ├── __init__.py
│ └── db_handler.py # MongoDB operations & user management
│
├── aurion/ # Core Aurion modules
│ ├── __init__.py
│ ├── assistant.py # Main assistant orchestrator
│ ├── gemini_engine.py # Gemini API handler
│ ├── prompt_controller.py # System prompts & personality
│ ├── memory.py # Temporary conversation storage
│ ├── user_memory.py # Persistent user conversations (MongoDB)
│ └── voice_handler.py # Voice recognition handler
│
├── config/ # Configuration management
│ ├── __init__.py
│ └── settings.py # Environment & settings
│
├── data/ # Data storage (auto-created)
│ └── memory.json # Conversation backup
│
├── .env # API keys & MongoDB URI (create this)
├── .env.example # Environment template
├── .gitignore # Git ignore rules
├── requirements.txt # Python dependencies
└── README.md # This file
git clone https://github.com/armanulalam/Aurion-OOP.git
cd Aurion-OOP# Windows
conda create -n oopaurion python=3.9 -y
conda activate oopaurionpip install -r requirements.txtChoose one option:
- Go to https://www.mongodb.com/cloud/atlas
- Create a free account and M0 cluster (free tier)
- Create a database user with username and password
- Whitelist your IP address (or use 0.0.0.0/0 for development)
- Get your connection string from "Connect" → "Connect your application"
Example connection string:
mongodb+srv://username:password@cluster.mongodb.net/aurion?retryWrites=true&w=majority
Windows:
- Download from https://www.mongodb.com/try/download/community
- Install MongoDB Community Server
- MongoDB runs on
mongodb://localhost:27017/
macOS:
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-communityLinux:
sudo apt-get install -y mongodb
sudo systemctl start mongodb
sudo systemctl enable mongodbCreate a .env file in the project root:
cp .env.example .envEdit .env and add your credentials:
# Gemini API Key (Required)
GEMINI_API_KEY=your_actual_api_key_here
# MongoDB Connection String (Required)
# For Local MongoDB:
MONGODB_URI=mongodb://localhost:27017/
# For MongoDB Atlas (Cloud):
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/aurion?retryWrites=true&w=majorityGet Gemini API Key: https://makersuite.google.com/app/apikey
Run the dependency checker:
python check_dependencies.pyThis will verify:
- ✅ Python version
- ✅ All packages installed correctly
- ✅ MongoDB connection working
- ✅ Gemini API key configured
streamlit run app.pyThe app will open in your browser at http://localhost:8501
-
Create Account
- Open the app
- Click "📝 Create New Account"
- Enter your name, email, and password (minimum 6 characters)
- Click "✅ Sign Up"
-
Login
- Enter your registered email and password
- Click "🔐 Login"
- Your previous conversations will be automatically loaded
- Application starts - A default conversation is created automatically
- Select Mode - Choose your preferred assistant mode from sidebar
- Start Chatting - Type your message in the input box or use voice input
- New Conversation - Click "➕ New Conversation" in sidebar
- Switch Conversations - Click on any conversation in the list
- Delete Conversation - Click the 🗑️ button next to a conversation
- Clear Conversation - Use "🧹 Clear Conversation" to reset current chat
- All conversations persist - Logout and login anytime, your chats are saved!
- Click the 🎤 button next to the chat input
- Wait for "Listening..." prompt
- Speak your question clearly
- Your speech will be converted to text
- Aurion will respond automatically
- Best for: Everyday questions, general help
- Example: "What is blockchain technology?"
- Best for: Study help, concept explanations
- Example: "Explain calculus derivatives step by step"
- Best for: Programming help, debugging
- Example: "Write a Python function to sort a list"
- Best for: Career advice, professional development
- Example: "How do I prepare for a data science interview?"
Stores user account information:
{
"_id": ObjectId("..."),
"name": "John Doe",
"email": "john@example.com",
"password": "hashed_sha256_password", // SHA-256 hashed
"created_at": ISODate("2025-12-26T10:00:00Z"),
"last_login": ISODate("2025-12-26T15:30:00Z")
}Stores all conversations for each user:
{
"_id": ObjectId("..."),
"user_id": "user_object_id", // Links to users collection
"conversations": {
"conv_abc123": [
{
"role": "user",
"message": "Hello Aurion",
"timestamp": "2025-12-26T10:00:00"
},
{
"role": "assistant",
"message": "Hello! How can I help you?",
"timestamp": "2025-12-26T10:00:05"
}
],
"conv_xyz456": [ /* more messages */ ]
},
"updated_at": ISODate("2025-12-26T15:30:00Z")
}User Login
↓
UserMemory loads conversations from MongoDB
↓
User sees all previous conversations
↓
User sends message
↓
Message instantly saved to MongoDB
↓
User logs out
↓
All data remains in MongoDB
↓
User logs in again
↓
All conversations restored! ✨
The DatabaseHandler class manages all MongoDB operations:
Key Methods:
register_user()- Create new user accountlogin_user()- Authenticate user credentialssave_user_conversations()- Save conversations to databaseload_user_conversations()- Load user's conversation historyis_connected()- Check database connection status
Example Usage:
from database import DatabaseHandler
# Initialize connection
db = DatabaseHandler()
# Register new user
result = db.register_user("John Doe", "john@example.com", "password123")
# Login user
result = db.login_user("john@example.com", "password123")
# Save conversations
db.save_user_conversations(user_id, conversations)Settings
↓
DatabaseHandler (MongoDB) ←──┐
↓ │
GeminiEngine ←──┐ │
│ │
PromptController ←─┼→ Assistant → Streamlit App
│ │
UserMemory ←────┴─────────────┘
↓
VoiceHandler
- Manages MongoDB connection and operations
- Handles user authentication (registration, login)
- Stores and retrieves user conversations
- Password hashing with SHA-256
- Manages Gemini API connection
- Handles response generation
- Supports streaming responses
- Defines assistant personalities (4 modes)
- Manages system prompts
- Builds contextualized prompts
- Temporary conversation storage (file-based)
- Used for non-authenticated users
- Manages multiple conversations
- Persistent conversation storage (database-backed)
- Automatically loads conversations on login
- Saves every message to MongoDB
- Used for authenticated users
- Main orchestrator
- Coordinates all components
- Manages conversation flow
- Environment configuration
- API key and MongoDB URI management
- Path handling
- Speech recognition
- Microphone input handling
- Voice-to-text conversion
- Login and signup pages
- User profile display in sidebar
- Session management
- SHA-256 Hashing - All passwords are hashed before storage
- No Plain Text - Passwords never stored in readable format
- Salted Hashing - Enhanced security through password hashing
- Server-Side Sessions - Streamlit manages sessions securely
- Auto Logout - Session clears on logout
- No Token Exposure - Session-based authentication
- Connection String Protection - Stored in .env file (not in code)
- User Isolation - Each user can only access their own data
- Input Validation - All inputs validated before database operations
- ✅ Always use
.envfor sensitive data - ✅ Never commit
.envto Git (included in.gitignore) - ✅ Use MongoDB Atlas with IP whitelisting for production
- ✅ Enable MongoDB authentication in production
- ✅ Use strong passwords (8+ characters, mixed case, numbers)
# Run diagnostic script
python check_dependencies.py
# Or test manually
python -c "from database import DatabaseHandler; db = DatabaseHandler(); print('✅ Connected!' if db.is_connected() else '❌ Failed')"from database import DatabaseHandler
db = DatabaseHandler()
# Test registration
result = db.register_user("Test User", "test@example.com", "test123")
print(result) # Should show success
# Test login
result = db.login_user("test@example.com", "test123")
print(result) # Should return user data# Open MongoDB shell
mongosh
# Switch to database
use aurion
# View users
db.users.find().pretty()
# View conversations
db.user_conversations.find().pretty()Problem: "Failed to connect to MongoDB"
Solutions:
# Check if MongoDB is running (local)
sudo systemctl status mongodb # Linux
brew services list | grep mongodb # Mac
# Start MongoDB
sudo systemctl start mongodb # Linux
brew services start mongodb-community # Mac
# Test connection
mongosh mongodb://localhost:27017/
# For Atlas: Check IP whitelist in MongoDB Atlas dashboardProblem: Import "pymongo" could not be resolved
Solutions:
# Install pymongo
pip install pymongo
# If using virtual environment, make sure it's activated
# VS Code: Select correct Python interpreter (Ctrl+Shift+P)
# See detailed guide
# Read: FIXING_IMPORTS.mdProblem: Microphone not detected or speech not recognized
Solutions:
# Install audio dependencies
# Windows: See VOICE_SETUP.md for PyAudio installation
# Mac: brew install portaudio
# Linux: sudo apt-get install portaudio19-dev python3-pyaudio
# Grant microphone permissions in browser/system settings
# Test microphone
python -c "from aurion import VoiceHandler; print(VoiceHandler().is_microphone_available())"Problem: "Invalid email or password"
Solutions:
- Verify email is correct (case-insensitive)
- Password is case-sensitive
- Ensure you registered first
- Try resetting: Delete user from MongoDB and re-register
Your conversations are now permanent!
- On Login - All your previous conversations are loaded from MongoDB
- While Chatting - Every message is automatically saved to the database
- On Logout - Your conversations remain safely stored in MongoDB
- Next Login - Everything is restored exactly as you left it
- ✅ Never Lose Data - Conversations persist forever
- ✅ Cross-Device - Access from any device by logging in
- ✅ Multiple Users - Each user has their own private conversations
- ✅ Automatic Saving - No manual save needed
- ✅ History Preserved - Full conversation context maintained
This project demonstrates:
- ✅ Object-Oriented Programming principles
- ✅ API integration and error handling
- ✅ Database design and operations (MongoDB)
- ✅ User authentication and session management
- ✅ State management in web applications
- ✅ File I/O and data persistence
- ✅ User interface design with Streamlit
- ✅ Clean code architecture and modularity
- ✅ Security best practices (password hashing, environment variables)
- ✅ Speech recognition integration
- QUICKSTART.md - Quick setup guide
- MONGODB_SETUP.md - Detailed MongoDB installation and configuration
- VOICE_SETUP.md - Voice commands setup and troubleshooting
- AUTH_COMPLETE.md - Authentication system implementation guide
- PERSISTENT_CONVERSATIONS.md - Conversation persistence details
- FIXING_IMPORTS.md - Import error troubleshooting
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
- Google Gemini - For the powerful AI API
- MongoDB - For the database platform
- Streamlit - For the amazing web framework
- Python Community - For excellent libraries
For questions or issues:
- Email: armaanularmaan@gmail.com
- GitHub Issues: Create an issue