sojorn/sojorn_docs/legacy/GO_BACKEND_README.md

1.6 KiB

Sojorn Backend Engine (Golang)

Production-grade Golang backend migrated from Supabase Edge Functions.

Tech Stack

  • Language: Go 1.21+
  • Framework: Gin Gonic
  • Database: PostgreSQL with PostGIS
  • Auth: JWT (compatible with Supabase)
  • Logging: Zerolog
  • Deployment: Docker / Systemd

Getting Started

Prerequisites

  • Go 1.21 or higher
  • PostgreSQL 15+ with PostGIS extension
  • golang-migrate CLI (for migrations)

Setup

  1. Clone the repository
  2. Copy .env.example to .env and fill in your details:
    cp .env.example .env
    
  3. Install dependencies:
    go mod download
    
  4. Run migrations:
    make migrate-up
    

Running Locally

go run cmd/api/main.go

The server will start on http://localhost:8080.

API Documentation

Auth & Profiles

  • POST /api/v1/signup: Complete profile creation after auth
  • GET /api/v1/profiles/:id: Get user profile
  • GET /api/v1/profile: Get current user profile

Posts & Feed

  • POST /api/v1/posts: Create a new post or beacon
  • GET /api/v1/feed: Get personal feed

Deployment

Using Systemd (Ubuntu/Debian)

  1. Edit scripts/deploy.sh with your VPS details.
  2. Run the deployment script:
    ./scripts/deploy.sh
    

Using Docker

docker build -t sojorn-api .
docker run -p 8080:8080 --env-file .env sojorn-api

Migration Notes

  • RLS policies have been moved to application-level middleware.
  • Supabase-specific triggers for metrics are maintained in SQL migrations.
  • E2EE session management is ported to handlers/services.