Skip to content

mearaj/bhagad-house-booking

Repository files navigation

Bhagad-House-Booking

Bhagad House Booking

Bhagad House Booking is a private app created in golang with gioui and other libraries. It's a private app but it's code are open sourced and MIT-Licensed. You are free to use it.

Development using docker-compose

Docker Prerequisites

  1. Docker or Docker Desktop

  2. Build and run docker images for backend,frontend and postgresql.

docker compose up
  1. Refer to Local Development

For Local Development

Local Prerequisites

  1. golang
  2. gioui
  3. Docker or Docker Desktop
  4. golang-migrate
  5. Postgresql 14 or later

Database

  1. Make sure your postgresql database is running at 5432.
  2. Create a database named bhagad_house_booking locally (DB_URL=postgresql://root:secret@localhost:5432/bhagad_house_booking?sslmode=disable) and necessary tables.
postgres15 createdb --username=root --owner=root bhagad_house_booking
cd common && make migrateup
  1. Create a user (Optional, only if admin role is desired).
cd common && go run cmd/main.go

The above command will create a user named Owner Admin and email [email protected] and password 12345678.
You will need to add a role named Admin in the users table of bhagad_house_booking

Backend

  1. Run the backend app locally on port 8001
export PORT=8001 && cd backend && go run cmd/server/main.go

Frontend

  1. Build the static files for web
cd frontend && gogio -target js -o output/wasm ./cmd/main.go
  1. Copy generated wasm file to static directory
cd frontend && cp output/wasm/main.wasm cmd/static/dist/main.wasm
  1. Copy environment variables for frontend(client) app
echo "window.API_URL = 'http://localhost:8001';" >> frontend/cmd/static/dist/wasm.js
  1. Serve the static files
export window.STATIC_FOLDER = 'dist'
export window.INNER_PORT = '8002'
cd frontend/cmd/static && go run main.go

Compile for windows on Arch Linux

 CGO_ENABLED=1 GOOS=windows CC=x86_64-w64-mingw32-gcc go build -ldflags -H=windowsgui -o output/windows/booking.exe cmd/main.go

Note: -ldflags -H=windowsgui

Development

Dependencies

  • The frontend needs to be served as static app
  • The frontend also needs env vars
  • The backend in turn needs postgres database to be running.

Steps

Production

flyctl deploy -a bhagad-house-booking-frontend --build-arg API_URL=https://bhagad-house-booking-backend.fly.dev -e GIN_MODE=release -c frontend.fly.toml

flyctl deploy -a bhagad-house-booking-backend -e GIN_MODE=release -c backend.fly.toml

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published