SecureChat is a modern Flask-based communication platform designed around three core principles:
- 🔐 Security
- 🤖 Intelligence
- 🔎 Transparency
The project combines secure authentication, encrypted messaging, AI assistance, real-time communication, and a visual encryption inspector into a single web application.
- Google OAuth 2.0 authentication
- Secure Flask session management
- Environment-based configuration for sensitive credentials
- Authentication handled through Authlib
- Symmetric message encryption using the Python
cryptographylibrary - Fernet-based authenticated encryption
- Randomized encryption for each message
- Encrypted communication designed to protect message contents
- Google Gemini AI integration
- Dedicated AI chat mode
- Real-time interaction with the AI assistant
- Error handling for API limitations and failures
- Direct personal chat functionality
- Real-time communication using Flask-SocketIO
- Users can start a secure conversation using a peer's username or ID
- Dedicated interface for switching between personal chat and AI mode
- Displays plaintext and encrypted ciphertext
- Provides a visual demonstration of the encryption process
- Allows users to inspect encryption while composing messages
- Toggleable inspector interface
- Dark-mode interface
- Glassmorphism-inspired design
- Animated WebGL background
- Responsive layout
- Smooth transitions and interactive elements
| Component | Technology |
|---|---|
| Backend | Python, Flask |
| Real-Time Communication | Flask-SocketIO |
| Frontend | HTML5, CSS3, JavaScript |
| Encryption | Python Cryptography / Fernet |
| Authentication | Authlib, Google OAuth 2.0 |
| AI Integration | Google Gemini |
| Configuration | Python-dotenv |
| Logging | Python Logging |
The application follows a modular Flask architecture.
User Interface
↓
Flask Application
↓
Authentication / Chat / AI / Encryption Modules
↓
Encrypted Communication & Real-Time Socket Communication
The major components are separated into dedicated Python modules for authentication, encryption, AI processing, logging, and application control.
SecureChat/
├── app.py
├── auth.py
├── encryption.py
├── ai_handler.py
├── logger.py
├── requirements.txt
├── FINAL_PROJECT_REPORT.md
├── static/
│ ├── style.css
│ └── shader.js
├── templates/
│ ├── index.html
│ └── login.html
└── .gitignore
| File | Purpose |
|---|---|
app.py |
Main Flask application and application routes |
auth.py |
Authentication and Google OAuth functionality |
encryption.py |
Message encryption and decryption functionality |
ai_handler.py |
Google Gemini AI integration |
logger.py |
Application logging functionality |
requirements.txt |
Python dependencies |
FINAL_PROJECT_REPORT.md |
Detailed project report |
static/style.css |
Application styling and UI design |
static/shader.js |
Animated WebGL background |
templates/index.html |
Main chat interface |
templates/login.html |
Login interface |
.gitignore |
Prevents sensitive and unnecessary files from being committed |
Security is one of the main design principles of SecureChat.
Sensitive credentials and local configuration files are excluded from version control using .gitignore.
The project excludes:
.envfiles- Encryption keys
- API credentials
- OAuth secrets
- Virtual environments
- Local logs
- Python cache files
- IDE-specific files
Never commit API keys, OAuth client secrets, encryption keys, or other sensitive credentials to GitHub.
- OAuth 2.0 authentication through Google
- Environment-based secret management
- Authenticated message encryption using Fernet
- Separation of security functionality into dedicated modules
- Secure session configuration
- Application logging
SecureChat includes a dedicated AI communication mode powered by Google Gemini.
Users can switch from personal communication to AI-assisted communication through the application's AI interface.
The AI functionality is separated into ai_handler.py, allowing AI-related processing to remain independent from the main application logic.
SecureChat includes an Encryption Inspector to make the encryption process visible to the user.
The inspector provides a visual representation of:
Plaintext Message → Encrypted Ciphertext
This feature demonstrates how readable message content is transformed by the encryption layer before being handled by the secure communication system.
SecureChat was developed as a security-focused modernization project.
The goal was to transform a basic Flask-based chat application into a more secure, intelligent, and transparent communication platform.
The project demonstrates practical implementation of:
- Authentication
- Encryption
- Secure configuration
- Real-time communication
- AI integration
- Security logging
- Modular application design
- Security transparency
- Modern web interface development
git clone https://github.com/Mannat29/securechat.git
cd securechatOn Windows:
python -m venv .venvActivate the virtual environment:
.venv\Scripts\activatepip install -r requirements.txtCreate a .env file in the project directory and configure the required credentials.
Example:
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GEMINI_API_KEY=your_gemini_api_key
SECRET_KEY=your_secret_keyDo not commit the .env file or any credentials to GitHub.
python app.pyThe application will start using the Flask development server.
Open the local address displayed in the terminal to access SecureChat.
SecureChat uses environment variables to keep sensitive configuration separate from the source code.
Typical configuration includes:
- Google OAuth Client ID
- Google OAuth Client Secret
- Gemini API Key
- Flask Secret Key
- Encryption-related configuration
The actual values should remain local and must not be committed to the repository.
SecureChat is primarily an educational and demonstration project developed to explore practical security concepts in a web application.
It demonstrates how multiple security mechanisms can be combined within a Flask application while maintaining a modern user experience.
This project is intended primarily for educational and demonstration purposes and should not be considered production-ready without additional security hardening.
For production deployment, additional controls should include:
- HTTPS/TLS
- Secure production secret management
- Production-grade OAuth configuration
- Secure cookie configuration
- CSRF protection
- Rate limiting
- Strong input validation
- Production-grade logging and monitoring
- Proper authorization and access control
- Secure database/storage configuration
- Production server configuration
- Dependency and vulnerability management
A detailed project report describing the project overview, implemented features, technical architecture, security mechanisms, and design is available in:
FINAL_PROJECT_REPORT.md
Mannat Tomar
BCA (Hons.) Data Science
Minor in Cybersecurity