Skip to content

A web app for a fictional Bed and Breakfast, written in Go.

Notifications You must be signed in to change notification settings

BlackSound1/Go-B-and-B

Repository files navigation

Go B & B

A web app for a fictional Bed and Breakfast, written in Go.

Home Page

Features

  • 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.

Tech Stack

Server Setup

This project uses Linode/ Akamai for its server.

  1. Log in as root, connecting by the Linode IP address: ssh root@<IP ADDRESS>
  2. Update server:
    apt update && apt upgrade -y
  3. 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
  4. Install supervisor:
    apt install supervisor
  5. Install PostgreSQL (version 16 is used here. May not be available when reading this):
    apt install postgres-##
  6. Create new user (accept defaults):
    adduser <NAME>
  7. Give user root permissions:
    usermod -aG sudo <NAME>
  8. Log in as user: <NAME>@<IP ADDRESS>
  9. Install Make:
    sudo apt install make
  10. Download Go:
wget https://go.dev/dl/go1.23.1.linux-amd64.tar.gz
  1. Install Go:
    sudo tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz
  2. Add Go to PATH:
    export PATH=$PATH:/usr/local/go/bin
  3. To make sure this Go is always used for this user, update .profile with the above export
  4. Clone this repo: git clone https://github.com/BlackSound1/Go-B-and-B.git
  5. Adjust Postgres configuration located at /etc/postgresql/##/main/pg_hba.conf. Adjust IPv4 and IPv6 METHOD to 'trust' to keep it simple.
  6. Restart Postgres:
    sudo service postgresql stop && sudo service postgresql start
  7. Populate the database.yml file from the database.yml.example file and fill out the fieleds as appropriate.
    cp database.yml.example database.yml
  8. Get Pop: go install github.com/gobuffalo/pop/v6/soda@latest
  9. Add Soda to PATH by editing .profile to add export PATH=$PATH:~/go/bin
  10. Run migrations: soda migrate
  11. Populate the .env file from the .env.example file and fill out the fields as approprate (setting PROD to true).
cp .env.example .env
  1. In /etc/caddy, there is a Caddyfile. Change it to Caddyfile.dist with sudo mv Caddyfile Caddyfile.dist.
  2. Create own Caddyfile and edit it as in config_examples/Caddyfile.example.
  3. Create conf.d/go_b_and_b.conf. Populate it as in config_examples/go_b_and_b.conf.example.
  4. Create /var/www directory and move app into /var/www/go_b_and_b using sudo mv ~/Go-B-and-B/ go_b_and_b.
  5. In /var/www/go_b_and_b, create logs directory. Make it writable to all by sudo chmod 777 logs.
  6. Should now be able to access the site by using the Reverse DNS name for the public IP Address in Linode.
  7. Go to /etc/supervisor/conf.d. Create go_b_and_b.conf. Populate it as config_examples/supervisor.conf.d.example.
  8. Add the program defined above to supervisor by using sudo supervisorctl add bnb.
  9. Run the update.sh script to update the deployment when main has been merged to on GitHub.

How to Run

If you have Make installed: make run.

If you don't: go run ./cmd/web or go run ./....

How to Log in as Admin

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.

About

A web app for a fictional Bed and Breakfast, written in Go.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published