1
0
Fork 0
forked from TWS/kalkutago
A multi-user tickmate clone for the web
Find a file
2023-06-25 14:32:02 -04:00
client Cleanly disconnect from the update stream if possible 2023-06-25 11:33:18 -04:00
server Add updates for track changes 2023-06-25 14:32:02 -04:00
traefik-config Whoops, didn't commit for a while. Added button toggling logic, doesn't work 2023-06-20 08:40:35 -04:00
.dockerignore initial project setup 2023-06-06 10:27:02 -04:00
.gitignore Add unsafe_import route 2023-06-13 10:19:14 -04:00
docker-compose.yml Whoops, didn't commit for a while. Added button toggling logic, doesn't work 2023-06-20 08:40:35 -04:00
docker-compose_dev.yml Build custom image for client dev server 2023-06-25 11:33:18 -04:00
docker-compose_prod.yml Whoops, didn't commit for a while. Added button toggling logic, doesn't work 2023-06-20 08:40:35 -04:00
Makefile Temporarily configure docker-compose for dev/debug 2023-06-14 11:40:59 -04:00
README.md Add README 2023-06-25 11:30:45 -04:00
traefik.yaml Whoops, didn't commit for a while. Added button toggling logic, doesn't work 2023-06-20 08:40:35 -04:00

Kalkutago

A multi-user Tickmate clone for the web

Development

Before you start

The backend uses a postgres server which is not tracked as a part of the repository, and neither is the password for it. You'll need to generate a password by doing something like

openssl rand -base64 36 > server/postgres.pw

The development environment uses Traefik to reverse-proxy the API and dev server. In production, the API will serve the client directly, but this system allows you to run the dev server behind a reverse proxy so that changes are rendered quickly without having to rebuild the container. Using the vite dev server also gets us better debugging in the browser.

However, that means that Traefik needs a hostname to listen for. The way I've done this is by adding the following entry to my /etc/hosts file:

127.0.0.1 kalkutago

Server

The server is written in Rust, using Rocket and SeaOrm. It uses Rust nightly, so you'll need to rustup override set nightly, though it gets built in docker so you really only need this for IDE support.

Client

The client is a Vue application. It has a central state in state.ts. On application load, the state is initialized by fetching the current tracks and ticks via the API, and then subscribes to updates from the server by opening an EventSource at /api/v1/updates.

The basic flow is:

  • a user interaction happens which should trigger a state change
  • the action is dispatched to the server (e.g. by making a PATCH request to /api/v1/tracks/<track_id>/ticked)
  • the server makes the appropriate change to the database
  • an event is dispatched to the event sources subscribed via /api/v1/updates
  • The client receives the event, the reactive state is updated, and the UI changes to match the expected state.

Running for development

docker-compose_dev.yml is symlinked to docker-compose.yml for now, so once the hostname is set up Just run docker-compose up --build and visit http://kalkutago/ to open the app

Populating the database

In order to see the UI components I add a track to the database like

curl --json '{"name": "test", "description": "test track", "icon": "❓", "enabled": 1}' kalkutago/api/v1/tracks