Prerequisites

Ensure you have the following installed:
  • Go 1.21+: Download and Install
  • PostgreSQL: Used for all persistence.
  • Redis: Used for authentication caching.
  • NATS: Used for cross-service event synchronization (Orders, CRM, Invoices, and permission cache invalidation).

Installation

  1. Navigate to the Go backend directory:
  2. Download dependencies:
  3. Initialize the environment file:

Configuration

Edit the .env file with the following required variables:

Database (PostgreSQL)

Authentication (Better Auth)

Note: The Go backend queries user, organization, and role data from the shared PostgreSQL database, which is populated by Better Auth plugins (admin and organization) running on the Bun backend. Ensure the Bun backend is deployed with Better Auth plugins configured before using the Go backend.

Infrastructure

Database Migrations

The project uses GORM’s AutoMigrate for schema synchronization. To run migrations and seed default data (plans, etc.):
To seed sample data (demo organizations, users):

Running the Server

Development Mode (with Live Reload)

We use air for hot reloading:

Standard Run

The server will be available at http://localhost:8080.

Health Check

Verify the setup by visiting http://localhost:8080/health. It returns 200 OK if PostgreSQL, NATS, and the server are all functioning correctly.