Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chatapp

A Flask + Socket.IO real-time group chat server with registration, login and an admin page, backed by PostgreSQL.

Previous README was inaccurate. It described React, Node.js, Express, MongoDB, private and group chats, message history and online-status indicators. None of that exists in this repository. What follows is what the code actually contains.

This is one of three near-identical copies of the same project on this account, alongside chatbot (the minimal version) and chatbotapp.github.io (adds Alembic migrations). app.py here is byte-identical to chatbotapp.github.io's and differs from chatbot's only in binding to 0.0.0.0. Consider keeping one and archiving the others.

There is also no bot: despite the UI title "Chatbot", every message is simply broadcast to all connected clients. No NLP, no AI, no automated replies.

What it does

app.py (~145 lines) is the whole application:

  • / — landing page
  • /register — create an account; bcrypt password hashing; all new users get the role User
  • /login, /logout — Flask-Login sessions
  • /chat — the chat room (login required)
  • /admin — all users and all chat history, gated by a role_required('Admin') decorator

Socket.IO: the browser emits send_message, the server writes it to the chathistory table and re-emits receive_message to every connected client. One global room, no private messaging, no history replay on load.

Tech stack

Python 3, Flask, Flask-SocketIO, Flask-SQLAlchemy, Flask-Login, Flask-Bcrypt, Flask-Migrate, psycopg2 (PostgreSQL), Bootstrap 5 and the Socket.IO 4.0 client from a CDN.

Setup

git clone https://github.com/Haroldke13/chatapp.git
cd chatapp
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt

requirements.txt is unpinned and does not list eventlet or gevent, which Flask-SocketIO generally needs; you may have to pip install eventlet too.

PostgreSQL is required

app.py hardcodes:

app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:password@localhost/chatbot_db'

Create a chatbot_db database and either match those credentials or edit the line. Tables are created at startup by db.create_all().

Run

python app.py      # socketio.run(app, host='0.0.0.0', debug=True) → http://127.0.0.1:5000

The Procfile (web: python app.py) targets a PaaS such as Heroku or Render.

Repository contents worth knowing about

  • venv/ is committed — 2,605 tracked files and ~54 MB of installed site-packages. This should be removed from the repo and added to a .gitignore, which does not currently exist.
  • build/ holds six HTML files that look like an attempt to publish the app as a static site. They are not usable: build/index.html still contains unrendered Jinja ({{ url_for('home') }}), and a Socket.IO chat server cannot run on static hosting anyway.
  • base.html and index.html at the repository root are stray duplicates of the files in templates/.
  • As in the sibling repos, app.py redefines User and ChatHistory locally after importing them from user.py and db.py, making those two modules dead code.

Status

Working prototype. Last commit January 2025. The chat, auth and admin flows work against a local PostgreSQL instance. No tests. The repository needs a .gitignore and the committed venv/ removed.

Licence

Proprietary software — all rights reserved. Copyright © 2026 Joel Harold Onyango.

This repository is not open source. The full terms are in LICENSE; in summary, you may not copy, redistribute, modify, sublicense, publish, re-host or commercially exploit this software, in whole or in part, without the prior written permission of the copyright holder. Access to this repository does not grant any licence beyond reading it.

About

Flask + Socket.IO real-time group chat server with registration, login, an admin view and PostgreSQL-backed message history.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages