Giter VIP home page Giter VIP logo

granulate's Introduction

Backend Assignment

This is a simple RESTful API for Chat application. Backend servers are written in Python using Bottle framework. The project built according to the design diagram in docs folder.

it uses MySQL (sqlalchemy as ORM) as database, and Redis as cache and message broker.

Project Services are:

  • Notification service

    • Exposes a RESTFUL API for sending notifications to users.
    • Stores notifications in a database.
  • Socket service

    • Bottle application for handling websocket connections to communicate with clients.

Requirements

  • python3.10
  • Docker (optional)
  • docker-compose version 1.29.2

Installation

To run the services using docker-compose (recommended):

  • execute these commands:
  cd granulate
  docker build . -f docker/Dockerfile -t chat-app:base
  docker build . -f docker/notification/Dockerfile -t chat-notification
  docker build . -f docker/socket/Dockerfile -t chat-socket
  docker-compose -f docker/docker-compose.yml up -d

To run the services locally:

  cd granulate/services
  ./rebuild_env.bat
  • open IDE from the root folder of the service
  • configure python interpreter to use: granulate/services/venv/bin/python
  cd granulate/services/SERVICE_NAME
  python main.py

Notification Service

API Reference

Send a new message

  curl --location --request POST '127.0.0.1:1337/api/notification' \
--header 'Content-Type: application/json' \
--data-raw '{
    "username": "test",
    "message": "test message"
    "room_name": "test_room"
}'
Parameter Type Description
username Str Required
message Str Required
room_name Str Optional

Test Client tool

connects to the socket service and waits for messages. it can also send messages to the socket service.

  cd granulate/services/socket
  python test_client.py
  cd granulate/services/tools
  python client.py --username=david --message
Parameter Type Description
username Str Required fetch messages for the given user
message Optional prompt message input
room Optional room name

To run the client in docker:

  • execute these commands:
  cd granulate
  docker build . -f docker/client/Dockerfile -t chat-app:client
  docker run --network="host" chat-app:client --username david

granulate's People

Contributors

almogalon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.