A web app for a fictional Bed and Breakfast, written in Go.
- Can book stays to 2 rooms for any length of time.
- Email confirmations for owner and guests.
- Admin dashboard hidden behind Auth.
- Admin can process new reservations.
- Admin can cancel new reservations.
- Admin can block off days when a room is not available.
- Admin can see all reservations.
- Admin can see new, unprocessed reservations.
- Admin can see monthly calendar of reservations.
- Log in/ out functionality.
- Go: 1.23.1
- Database: PostgreSQL with PGX
- Email: MailHog and Go Simple Mail
.env
Management: Go Dotenv- Form Validation: Go Validator
- CSRF Prevention: NoSurf
- HTTP Routing: Chi Router
- Session Management: SCS
- Database Migrations: Pop/ Soda
- Admin Dashboard: Royal UI Free Bootstrap Admin Template
- Frontend: Bootstrap
- Notifications: Notie
- Alerts: SweetAlert 2
- Datepickers: VanillaJS Datepicker
- Building: Make
- Cloud: Linode/ Akamai
- Cloud Webserver: Caddy
This project uses Linode/ Akamai for its server.
- Log in as root, connecting by the Linode IP address:
ssh root@<IP ADDRESS>
- Update server:
apt update && apt upgrade -y
- Install Caddy:
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl && \ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg && \ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list && \ apt update && apt install caddy
- Install supervisor:
apt install supervisor
- Install PostgreSQL (version 16 is used here. May not be available when reading this):
apt install postgres-##
- Create new user (accept defaults):
adduser <NAME>
- Give user root permissions:
usermod -aG sudo <NAME>
- Log in as user:
<NAME>@<IP ADDRESS>
- Install Make:
sudo apt install make
- Download Go:
wget https://go.dev/dl/go1.23.1.linux-amd64.tar.gz
- Install Go:
sudo tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz
- Add Go to PATH:
export PATH=$PATH:/usr/local/go/bin
- To make sure this Go is always used for this user, update
.profile
with the aboveexport
- Clone this repo:
git clone https://github.com/BlackSound1/Go-B-and-B.git
- Adjust Postgres configuration located at
/etc/postgresql/##/main/pg_hba.conf
. Adjust IPv4 and IPv6METHOD
to 'trust' to keep it simple. - Restart Postgres:
sudo service postgresql stop && sudo service postgresql start
- Populate the
database.yml
file from thedatabase.yml.example
file and fill out the fieleds as appropriate.cp database.yml.example database.yml
- Get Pop:
go install github.com/gobuffalo/pop/v6/soda@latest
- Add Soda to PATH by editing
.profile
to addexport PATH=$PATH:~/go/bin
- Run migrations:
soda migrate
- Populate the
.env
file from the.env.example
file and fill out the fields as approprate (settingPROD
totrue
).
cp .env.example .env
- In
/etc/caddy
, there is aCaddyfile
. Change it toCaddyfile.dist
withsudo mv Caddyfile Caddyfile.dist
. - Create own
Caddyfile
and edit it as inconfig_examples/Caddyfile.example
. - Create
conf.d/go_b_and_b.conf
. Populate it as inconfig_examples/go_b_and_b.conf.example
. - Create
/var/www
directory and move app into/var/www/go_b_and_b
usingsudo mv ~/Go-B-and-B/ go_b_and_b
. - In
/var/www/go_b_and_b
, createlogs
directory. Make it writable to all bysudo chmod 777 logs
. - Should now be able to access the site by using the Reverse DNS name for the public IP Address in Linode.
- Go to
/etc/supervisor/conf.d
. Creatego_b_and_b.conf
. Populate it asconfig_examples/supervisor.conf.d.example
. - Add the program defined above to
supervisor
by usingsudo supervisorctl add bnb
. - Run the
update.sh
script to update the deployment when main has been merged to on GitHub.
If you have Make installed: make run
.
If you don't: go run ./cmd/web
or go run ./...
.
Hit the "Log In" button on top. The admin username is: "[email protected]" and the password is: "cool_dude". These credentials can be exposed like this because the app is a proof-of-concept for portfolio purposes only.