This source code is AGPL-licensed. You can modify the source for this app, or for apps that communicate with this app through a network, but must make available any of your related code under the same license.
- liwords (this repo) is an API server, written in Go.
- liwords-ui (inside this repo) is a TypeScript front-end, built using
create-react-app
- liwords-ui (inside this repo) is a TypeScript front-end, built using
- liwords-socket is a socket server, written in Go. It handles all the real-time communication. It resides at https://github.com/woogles-io/liwords-socket.
- NATS for pubsub / req-response functionality between liwords, liwords-socket, and the user.
- PostgreSQL
You have two options for developing locally.
-
Using the entire Docker stack is the most straightforward option, but, unless you are on Linux, Docker has to spin up virtual machines for your code. Stopping and starting containers repeatedly, especially the frontend code container, is significantly slower than running these natively; rebuilding containers, etc is also quite slow.
-
The other option is to use Docker for the long-running services (postgres, Redis, NATS), and run your program executables locally. It is a bit more complex to set up initially, but may work better if you are developing on Mac OS (or Windows?).
Using the full stack on Docker
-
Download Docker for your operating system
-
Clone the
liwords-socket
repository fromhttps://github.com/woogles-io/liwords-socket
, and place it at the same level as this repo. For example, if your code resides at/home/developer/code
, you should have two repos, at/home/developer/code/liwords
(this repo) and/home/developer/code/liwords-socket
. -
Clone the
macondo
repository fromhttps://github.com/domino14/macondo
, and place it at the same level as this repo. -
cd
to this directory -
Run the following command in one of your terminal tabs, to run the backend, frontend, and databases.
docker compose up
- Edit your
hosts
file, typically/etc/hosts
, by adding this line:
127.0.0.1 liwords.localhost
(If you are on Windows and you want to use Chrome, you cannot use .localhost
. Use liwords.local
in your C:\Windows\System32\drivers\etc\hosts
.)
- Access the app at http://liwords.localhost
- If you wish to add a new front-end package, you need to run
npm i
INSIDE the Docker container. You can do this like:docker compose exec frontend npm i
when the docker compose is up. - You can register a user by going to http://liwords.localhost/ and clicking on
SIGN UP
at the top right.
To have two players play each other you must have one browser window in incognito mode, or use another browser.
- To register a bot, run the script in
scripts/utilities/register-bot.sh
. You can run it like this:
./scripts/utilities/register-bot.sh BotUsername
, replacing BotUsername with your desired bot username.
Tips
You can do docker compose up app
and docker compose up frontend
in two different terminal windows to bring these up separately. This may be desirable, for example, when making backend changes and not wanting to restart the frontend compilation everytime something changes.
Using a hybrid stack on Docker
NOTE: These instructions need to be updated and might not work currently.
- Download Docker for your operating system
- Download the latest stable version of Node.js for your operating system and install it
- Download and install Go from golang.org
- Copy the
local_skeleton.env
file in this directory tolocal.env
, and modify the copy to match your local paths. (See all the variables ending in _PATH). - Open up a few tabs or panels in your terminal so you can bring up the services separately. In each tab, you can do
source local.env
, or alternatively you can put this command in your profile to do it automatically. - Bring up the
dc-local-services.yml
file withdocker compose -f dc-local-services.yml up
in one tab. - You can bring up the other services in your other tabs:
- For the api server, do
go run cmd/liwords-api/*.go
- For the socket server, do
go run cmd/socketsrv/main.go
in theliwords-socket
repo. - For the frontend, do
npm start
in theliwords-ui
directory. - For the bot, do
go run cmd/bot/*.go
in themacondo
directory.
- Go to
http://localhost:3000
to see Woogles. - You can register a user by clicking on
SIGN UP
at the top right.
To have two players play each other you must have one browser window in incognito mode, or use another browser.
- To register a bot, register a user the regular way. Then run this following script, replacing the
$1
with the bot username you just registered.
docker compose exec db psql -U postgres liwords -c "UPDATE users SET internal_bot='t' WHERE username = '$1';"
liwords
has a dependency on https://github.com/domino14/macondo
macondo
provides the logic for the actual crossword board game. liwords
adds
the web app logic to allow two players to play against each other, or against
a computer, etc.
macondo
also provides a bot.
The app requires liwords-socket
as a socket server. See the instructions above for how to run it alongside this api server.
If you change any of the .proto
files (in this repo or in the Macondo repo) you will need to run the protoc
compiler to regenerate the appropriate code.
To do so, run in this directory:
go generate
We use sqlc
for generating Go code from our .sql
files. If you create new .sql
files in db/migrations
or db/queries
you can rerun sqlc as follows:
go generate
This app uses these sounds from freesound:
S: single dog bark 3 by crazymonke9 -- https://freesound.org/s/418105/
Part of the front-end timer code borrows from https://github.com/ornicar/lila's code (AGPL licensed, like this app).
Wolges-wasm is Copyright (C) 2020-2024 Andy Kurnia and released under the MIT license. It can be found at https://github.com/andy-k/wolges-wasm/.
Country flags created by https://hampusborgos.github.io/