A modern, realtime group chat application built with Flask that supports Google Sign‑In, room management, web push notifications, and live messaging via Socket.IO.
- Google Sign‑In (OAuth 2.0): One‑click login using Google accounts
- Realtime Messaging: Live chat using Flask‑SocketIO with Eventlet
- Room Management: Create rooms, add/remove members, and manage admins
- Message History: Persist messages and members in MongoDB
- Web Push Notifications: VAPID‑backed push for new messages
- Responsive UI: Clean templates with static assets for an app‑like feel
- Production‑Ready: Procfile, runtime pinning, and Gunicorn configuration
- Framework: Flask 2.0.1 (Jinja2, Werkzeug)
- Realtime: Flask‑SocketIO 5.1.1 + Eventlet 0.33.3
- Auth: Google OAuth (google‑auth‑oauthlib, google‑auth)
- Database: MongoDB (pymongo)
- Notifications: Web Push (pywebpush, py‑vapid, cryptography)
- Server: Gunicorn (eventlet worker)
- Deploy: Render Web Services
- Python 3.8.6
- A MongoDB connection string (Atlas or self‑hosted)
- Google OAuth 2.0 credentials (OAuth Client ID +
client_secrets.json) - VAPID key pair for web push (public and private)
- Clone the repository
git clone https://github.com/Aakarsh-Kumar/chatoos.git
cd chatoos- Create and activate a virtual environment
python -m venv .venv
. .venv/Scripts/activate # Windows PowerShell: .venv\Scripts\Activate.ps1- Install dependencies
pip install -r requirements.txt- Provide Google OAuth secrets
- Place your OAuth client file at
etc/secrets/client_secrets.json(local) - On Render, mount or upload it to
/etc/secrets/client_secrets.json
Set the following environment variables (locally in a .env file or via Render dashboard):
APP_SECRET_KEY: Flask secret keyapp_url: Public app URL (e.g.,https://chatoos.onrender.com)GOOGLE_CLIENT_ID: Google OAuth Client ID (must match client secrets)MONGODB_URI: MongoDB connection stringVAPID_PRIVATE_KEY: VAPID private key (PEM)VAPID_PUBLIC_KEY: VAPID public key (base64url)VAPID_CLAIMS_EMAIL: Contact email for VAPID claimsCHATOOS_ROOM_ID(optional): Seed room idCHATOOS_ROOM_NAME(optional): Seed room nameCHATOOS_ADDED_BY(optional): Seed room creator email
OAuth Redirect URI (Google Console):
https://chatoos.onrender.com/callback
Development (Socket.IO will pick the best async driver available):
python app.pyProduction‑like run with Gunicorn + Eventlet:
gunicorn -k eventlet -w 1 wsgi:appThis repo includes:
runtime.txt→python-3.8.6Procfile→web: gunicorn -k eventlet -w 1 wsgi:appwsgi.py→ exposesappfor Gunicorn
Steps:
- Push to GitHub
- Create a Render Web Service from the repo
- Set environment variables (see above)
- Upload/mount
client_secrets.jsonat/etc/secrets/client_secrets.json - Add the authorized redirect URI in Google Cloud Console
- Deploy — your app will be available at your Render URL
app.py
wsgi.py
Procfile
requirements.txt
runtime.txt
db.py
user.py
etc/
secrets/
client_secrets.json
static/
sw.js
css/
fonts/
img/
vendor/
templates/
create_room.html
edit_room.html
index.html
login.html
members.html
signup.html
view_room.html
/— Home, room list and join actions/login— Google Sign‑In start (OAuth authorization URL)/callback— OAuth2 callback handler/logout— End session/create-room— Create a new room (auth required)/rooms/<room_id>— View room and live messages (auth required)/rooms/<room_id>/members— List members (auth required)/rooms/<room_id>/messages— Paginated older messages (auth required)
- Google OAuth: Uses
google_auth_oauthlib.flow.Flowto initiate login and fetch tokens, with ID token verification viagoogle.oauth2.id_token. - MongoDB: Stores users, rooms, membership, and messages via helper functions in
db.py. - Web Push (VAPID): Sends push notifications with
pywebpushwhen room messages are posted. - Socket.IO: Real‑time events for join/leave/message flows (
@socketio.on(...)).
- Ensure
app_urlmatches your deployed URL to avoid OAuth redirect mismatches. - The Google Console redirect must exactly be
https://<your-domain>/callback. - On Render, ensure the secret file is available at
/etc/secrets/client_secrets.json. - If switching async workers, keep
eventlet.monkey_patch()at the very top ofapp.py.
Contributions, issues, and feature requests are welcome! Please open an issue or PR.
- Fork the repository
- Create a feature branch:
git checkout -b initials/feat/my-change - Commit your changes:
git commit -m "feat: add my change" - Push to your branch:
git push origin initials/feat/my-change - Open a Pull Request
Aakarsh Kumar
- GitHub: @Aakarsh-Kumar
- Email: aakarsh2504@gmail.com
- Website: https://aakarsh.is-a.dev
Made with ❤️ by Aakarsh