tPlace is a recreation of Reddit's r/place for Tembusu Welcome Week 2020. This implementation takes heavy inspiration from this blogpost by Reddit.
tPlace aims to be a multi-user online interactive canvas authenticated via Telegram accounts. Using valid Telegram chats, users can access the tPlace bot and start drawing on the canvas. tPlace supports 16 different color types, along with interactive real-time socket programming to ensure that users can view changes made by other users in real-time. Users can access the page via desktop or mobile.
Each user draws on the canvas by placing pixels. Users will encounter a cooldown timer after they place a pixel. This is to ensure that users must collaborate in order to make larger drawings. Users can also accumulate pixels up to a certain limit before placing them as they wish.
The stack that was used for this implementation is:
- PostgreSQL for the database
- Redis for the canvas cache
- Telegraf for Telegram integration
- Socket.io for real-time interactivity
- JavaScript for frontend programming elements
- ExpressJS for RESTful API implementation
- Docker for deployment
- Elastic Beanstalk on AWS for server hosting
- Sahil: PostgreSQL database and Telegram integration
- Sam: Redis cache and Frontend development
- Khairul: Telegram integration and ExpressJS
- Hui Ling: Main Frontend developer
- Yi Jia: Mobile integration and Socket.io
- Rohan: Dockerization, Deployment and DevOps
- A hosting server must be used and this program must be running on the server.
- Install the Telegram bot ('@TembusuPlaceBot') on any Telegram chat (instructions).
- Ensure that the chat is whitelisted via the Telegram bot.
- Access the canvas as desired.
- Follow the instructions in the section below to download Docker.
- Run this program via Docker.
- Go to your localhost on any web browser to access the API calls.
Docker is a useful tool in development. When using Docker, you do not need to download Redis or PostgreSQL separately on your machine. With docker-compose
, you can run multiple services at once, streamlining the otherwise cumbersome testing process.
- Download Docker Desktop (if your OS allows for it) from https://docs.docker.com/docker-for-windows/install/ (Windows Pro), https://docs.docker.com/docker-for-windows/install-windows-home/ (Windows Home), or https://docs.docker.com/docker-for-mac/install/ (Mac).
- Create an account at Docker Hub (https://hub.docker.com/)
- Click the whale icon and login
- (Optional) open Settings
- (Optional) In 'WSL Integration' under 'Resources', enable integration with additional WSL distros (e.g. Ubuntu) if you want to use said distros
- Navigate to the src folder using Terminal/a WSL2 client
- Run
docker-compose up --build
- After testing the environment, terminate the build gracefully with ^C
- Run
docker-compose down
. This will remove all the containers from your machine
This is only necessary to run as a standalone; not necessary in this program due to Dockerization:
- Download Redis using either https://redis.io/topics/quickstart (Linux, maybe Mac also) or https://redislabs.com/blog/redis-on-windows-10/ (Windows). For file access via WSL on Windows, refer to https://www.tenforums.com/tutorials/127857-access-wsl-linux-files-windows-10-a.html.
- Start up a Linux client and navigate to the directory where the files were extracted to.
- Start the Redis server using
sudo service redis-server start
. - If exploring the server via the command line, use
redis-cli
. Take note that the server must be started before this command is used. Otherwise, the CLI will be stuck in a loop ofnot connected>
commands. If you get stuck, use Ctrl-C to exit. - Use the command
sudo service redis-server stop
to stop the server when necessary. - While the server is running, code can be run from the same machine, and it will communicate with the server. Take
note that the default IP is
localhost
, with port number6379
. These parameters are located in the backend/redis_project package. In some cases, these parameters may not be valid if the port is already in use.