By Alex Beaver, Alex Krantz, and Aidan Sacco
This is a simple chat app with a backend written in Golang and a cross-platform React Native frontend. The name of the project was chosen by our teacher. The app uses a PostgreSQL database to store all the chat, message, and user data. It also uses a SMTP server to send emails about verification and password reset.
This project was for AP Computer Science Principles during the 2019-2020 school year.
The server can be deployed using either a Docker container or a standalone binary.
Either environment variables or a configuration file can be used to configure the server.
If you use environment variables, each key will be in all caps, prefixed with CHAT_
, and have the periods (.
) replaced with underscores (_
).
For example, the key database.host
would be CHAT_DATABASE_HOST
.
If you want to use a configuration file, it should be named config
and contain all the keys you want to change.
It supports either JSON, YAML or TOML.
To see a reference for all the keys, see the documentation.
This is the preferred way to deploy the server and arguably the easiest.
You can create the API container manually or use a docker-compose.yaml
file.
Running with a configuration file:
docker run --name chat-app -v $PWD/config.yaml:/config.yaml docker.pkg.github.com/akrantz01/apcsp/chat-app-api:latest
Running with environment variables:
docker run --name chat-app -e CHAT_DATABASE_HOST=127.0.0.1 [other environment variables] docker.pkg.github.com/akrantz01/apcsp/chat-app-api:latest
The compose file uses MailHog as a mock SMTP server without a proper domain.
It also has a web UI to see all outgoing emails.
The API will be accessible on port 8080
on the IP address of your machine.
wget -O docker-compose.yaml https://raw.githubusercontent.com/akrantz01/apcsp/master/docker-compose.yaml
docker-compose up -d
NOTE: The API container may fail to start saying that it cannot access the Postgres container.
This is because the Postgres container can sometimes take longer to be ready to accept connections.
To remedy this, simply restart the API container with the following command: docker container start <container name>
To run from a standalone binary, download it from the releases tab. Currently, only binaries for 64-bit Linux are built, but more architectures and operating systems are planned.
Steps to build:
- Download the server binary
- Mark as executable with
chmod +x chat-app_[arch]_[os]
- Ensure a mail server and Postgres instance are accessible
- Run the server with
./chat-app