Skip to content

Instantly share code, notes, and snippets.

@ragelo
Last active September 20, 2018 14:40
Show Gist options
  • Save ragelo/a1a9141c43ab6718cbe1f907aec47aed to your computer and use it in GitHub Desktop.
Save ragelo/a1a9141c43ab6718cbe1f907aec47aed to your computer and use it in GitHub Desktop.
Task: Python Chat

Spec

You should create web chat server and console or web client.

Server

Server should provice 2 intarfaces for the data:

  • Flask API - to make API requests (get data, create chat and etc)
  • SocketIO - socket to recieve/send realtime messages at the chat

Functions:

  • get list of all chats
  • create chat
  • join chat
  • leave chat
  • get messages of specific chat (using cursor pagination - max 20 on the page)
  • write a message
  • block user
  • unblock user
  • get list of blocked users
  • group admin can ban and kick user from the cannel (he can't more write and join to the cannel)

Models

Models can be modified if need

user

username: Unique

chat_room

name: Unique admin: User

  • has many chat users
  • has many messages

message

  • chat_room_name
  • text
  • created_at

you may block another one user - then you shouldn't show blocked user's messages at any chats for your user, but still show them for the others

Tech Spec

docker image: Linix Alpine

docker-compose to start server and database

DB: PostgreSQL 9+

Runtime: Python 3.5

Makefile to run and test

Py Libraries

Flask

SQLAlchemy

alembic

dotenv

SocketIO

pylint - code style check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment