Improve docs (#76)

This commit is contained in:
Erik Vroon
2023-01-13 09:53:32 -08:00
committed by GitHub
parent 6d8773d966
commit f85c5e31c8
2 changed files with 32 additions and 20 deletions

View File

@@ -4,40 +4,52 @@
[![frontend](https://github.com/evroon/bracket/actions/workflows/frontend.yml/badge.svg)](https://github.com/evroon/bracket/actions/workflows/frontend.yml)
Ladder tournament system meant to be easy to use.
Bracket written in async Python (with FastAPI) and Next.js as frontend using the [Mantine](https://mantine.dev/) library.
![Preview](misc/img/preview.png)
# Setup
### Frontend
```
yarn
npm run dev
```
### Backend
```
./run.sh
```
#### Database
Create a new `bracket` database in a `bracket` cluster:
## Database
First create a `bracket` cluster:
```shell
sudo pg_createcluster -u postgres -p 5532 13 bracket
pg_ctlcluster 13 bracket start
```
Subsequently, create a new `bracket_dev` database (and `bracket_ci` for tests):
```shell
sudo -Hu postgres psql -p 5532
CREATE USER bracket_ci WITH PASSWORD 'bracket_ci';
CREATE DATABASE bracket_ci OWNER bracket_ci;
```
```shell
sudo -Hu postgres psql -p 5532
CREATE USER bracket_dev WITH PASSWORD 'bracket_dev';
CREATE DATABASE bracket_dev OWNER bracket_dev;
You can do the same but replace the user and database name with:
- `bracket_ci`: for running tests
- `bracket_prod`: for a production database
The database URL can be specified per environment in the `.env` files (see [config](#config)).
## Config
Copy [ci.env](backend/ci.env) to `prod.env` and fill in the values:
- `PG_DSN`: The URL of the PostgreSQL database
- `JWT_SECRET`: Create a random secret using `openssl rand -hex 32`
- `CORS_ORIGINS` and `CORS_ORIGIN_REGEX`: Specify allowed frontend domain names for CORS (see the [FastAPI docs](https://fastapi.tiangolo.com/tutorial/cors/))
- `ADMIN_EMAIL` and `ADMIN_PASSWORD`: The credentials of the admin user, which is created when initializing the database
## Running the frontend and backend
The following starts the frontend and backend for local development:
### Frontend
```
cd frontend
yarn
npm run dev
```
### Config
Put JWT_SECRET in prod.env using `openssl rand -hex 32`
### Backend
```
cd backend
./run.sh
```

BIN
misc/img/preview.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB