Skip to content

Roar1ngDuck/webchat

Repository files navigation

WebChat

Overview

This repository contains the code for a discussion application, which facilitates the creation and interaction within various discussion areas based on different topics. Each area contains threads consisting of messages. Users can either be administrators or basic users, with administrators having additional privileges.

Live Demo

The live project can be accessed at https://nikoweb.eu/projects/webchat/

Installation & Setup

Minimal Setup

This setup is for quickly getting the application running with a basic configuration. It is not a secure configuration and for a real deployment the settings should be customized.

  1. Clone the Repository:
    git clone https://github.com/Roar1ngDuck/webchat
  2. Configure Environment:

    Copy .env.example to .env:

    cp .env.example .env
  3. Run Docker Compose:

    Use Docker Compose to start the application:

    docker compose up
  4. Access

    The app will be accessible at http://127.0.0.1:8001/ by default

Advanced Setup

Detailed setup steps for a more customized configuration:

  1. Clone the Repository:
    git clone https://github.com/Roar1ngDuck/webchat
  2. Configure Environment Variables:

    Set up the environment variables by copying the example files:

    • .env for running the application. Copy .env.example to .env.
    • .env.test for running tests. Copy .env.test.example to .env.test.
    cp .env.example .env
    cp .env.test.example .env.test

    Required Variables in .env:

    • SECRET_KEY: Flask secret key.
    • ADMIN_PASSWORD: Default admin user password.

    Optional Variables:

    • DB_URL: External database URL (if not using Docker with predefined value in Dockerfile).
    • USE_TURNSTILE: True/False to toggle Cloudflare CAPTCHA (Turnstile)
    • TURNSTILE_SECRET: Turnstile secret key.
    • TURNSTILE_SITEKEY: Turnstile site key.
    • ENV: Environment setting, which affects certain application behaviors:
      • PROD: Sets secure cookie attributes (SECURE, HTTP_ONLY, SAMESITE) for enhanced security.
      • DEV: Does not set secure cookie attributes, suitable for development environments.
      • TEST: Used for pytest; does not set secure cookie attributes and resets the database with each execution.
  3. Run Docker Compose:

    Start the application with Docker Compose:

    docker compose up
  4. Access

    The app will be accessible at http://127.0.0.1:8001/ by default

  5. Running Tests:

    For running tests the app needs to be executed without Docker. For this, make sure you have a postgres database which corresponds to the name in ".env.test", which by default is "webchat_test".

    To run the test suite, execute pytest:

    pytest

Features

User Account Management

  • User Registration: Allows new users to create an account.
  • Login/Logout: Users can log in to access the application and log out after they're done.
  • Admin Users: Administrator users with additional privileges.

Discussion Areas

  • Area Creation: Administrators can create new discussion areas.
  • Secret Areas: Administrators can create secret areas with restricted user access.
  • Viewing Areas: Users can see a list of all discussion areas on the homepage along with the number of threads and messages in each area, and when the last message was sent.
  • Thread Creation: Users can create a new thread in an area by providing a thread title and the content of the initial message.
  • Search: Users can search area topics, thread titles, and message content for given text.
  • Subscriptions: Users can subscribe to threads and they will receive a notification when another user posts a message.

Messaging

  • Posting Messages: Users can write a new message in an existing thread and edit previously sent ones. Messages can optionally include images.
  • Message Deletion and Editing: Users can delete their messages and threads they have created.
  • Thread and Area Deletion: Administrators can delete threads and areas.

Implementation Details

  • Database Schema: Defined and initialized in utils/db.py, including the creation of tables and an admin user. The Database class is implemented as a singleton.
  • Password Hashing: User passwords are securely hashed using bcrypt.
  • CAPTCHA Verification: Cloudflare Turnstile is integrated to prevent automated spam and bot registrations
  • Password Strength Measurement: Password strength is evaluated using the zxcvbn library, which estimates password crack times based on various factors such as dictionary words, predictable patterns, and password length.
  • Gunicorn: Gunicorn is used as the WSGI HTTP server, enhancing the ability to handle concurrent requests efficiently compared to the default Flask server.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published