DEV Community

Cover image for Building an Appointment Booking app in Go
Marcus Kohlberg for Encore

Posted on • Updated on

Building an Appointment Booking app in Go

TL;DR

In this short guide we'll deploy the foundation for an appointment booking app (similar to Calendly) in Go using Encore.

We'll use an example project to get started, and in just a few minutes you will have an app running in Encore's free development cloud β€” ready for you to keep building on top of.

If you want to build it yourself step-by-step, check out the complete tutorial here.

The finished appointment booking app will look like this:

appointment booking app

πŸš€ What's on deck

  • Install Encore
  • Create your app
  • Run locally
  • Save SendGrid API key using Encore's secret manager
  • Deploy to Encore's free development cloud

🏁 Let's go!

πŸ’½ Install Encore

Install the Encore CLI to run your local environment:

  • macOS: brew install encoredev/tap/encore
  • Linux: curl -L https://encore.dev/install.sh | bash
  • Windows: iwr https://encore.dev/install.ps1 | iex

Create your app

Let's create our app from a starter template by running:



encore app create my-app --example=booking-system


Enter fullscreen mode Exit fullscreen mode

This will create an Encore app using a template for an Appointment Booking System.

It has both a user facing section (finding and booking appointments) and an admin section (setting availability and managing scheduled appointments).

The frontend is a React app and the backend is a Go microservices application with an event-driven architecture using Pub/Sub.

When a new appointment is booked, the backend sends a confirmation email to the user (using a Sendgrid integration).

Not implemented in the example:

  • Calendar integration with e.g. Google Calendar
  • Authentication for admin login

Here's the architecture diagram, generated by Encore:

Architecture

(White boxes are services, and the black box is a Pub/Sub topic.)

🏁 Run the app locally

To run locally you need to have Docker installed and running.

Then run your application:



encore run


Enter fullscreen mode Exit fullscreen mode

You should see this:

run locally

πŸ›  Open the Local Development Dashboard

While encore run is running, open http://localhost:9400/ to access Encore's local development dashboard.

Here you can see API docs, make requests in the API explorer, and view traces of the responses.

local dev dashboard

πŸ–₯ Open the app in your browser

While encore run is running, head over to http://localhost:4000/frontend/ to view the frontend for your appointment booking system.

appointment booking frontend

πŸ”‘ Set SendGrid API Key

Before we deploy our app to the cloud, we need to set an API key for the SendGrid integration. We can use Encore's built-in secrets manager to securely store our key.

You will need an API key from SendGrid to use this package. You can get one by signing up for a free account at https://sendgrid.com/.

(Or if you just want to test out the deployment flow, you can just use any random string.)

Once you have the API key, set it as a secret using the name SendGridAPIKey.



encore secret set --dev SendGridAPIKey


Enter fullscreen mode Exit fullscreen mode

This sets the key for development environments. It is good practice to separate API keys for development and production environments, so for prod we can set a separate key using:



encore secret set --prod SendGridAPIKey


Enter fullscreen mode Exit fullscreen mode

Please note that emails will only be sent in the production environment to avoid spending your email sending limits.

PS. You can also use the Secret Manager UI in Encore's Cloud Dashboard.

secret manager

πŸš€ Deploy to the cloud

Simply push to deploy your application to a staging environment in Encore's free development cloud:



git add -A .
git commit -m 'First commit'
git push encore


Enter fullscreen mode Exit fullscreen mode

Then head over to the Cloud Dashboard to monitor your deployment.

Encore will automatically provision all the necessary infrastructure, including compute instances, databases, Pub/Sub, and more.

infra provisioning in progress detailed view

infra provisioning in progress

Once the deploy is completed, you can find your app's URL by opening the staging environment in the Cloud Dashboard, it will be something like:
https://staging-my-app-gfoi.encr.app/frontend/

Deployed app

πŸŽ‰ Great job, you're done!

You now have a scalable Go based app running in the cloud, ready for you to extend further or use as inspiration for your next project.

Explore the Cloud Dashboard

From the Cloud Dashboard you can also connect your own AWS or GCP account to use for production deployment, connect GitHub, and view traces, metrics, and API docs for your cloud environments.

Wrapping up

Top comments (3)

Collapse
 
louisquach profile image
Minh Luan Quach

What a joke! What you do is just to run an Encore template but the title of the post like you gonna teach people something new and valuable

Collapse
 
marcuskohlberg profile image
Marcus Kohlberg • Edited

Hey @louisquach, yes this guide was condensed for a few reasons.
If you're interested in a more comprehensive tutorial, here's a longer version: encore.dev/docs/tutorials/booking-...

I will update the article and include this at the start.

Collapse
 
matinmollapur0101 profile image
Matin Mollapur

Great article, Thanks for Sharing!