Skip to main content

API Service Setup

SDD Classification: L4-Operational Authority: Engineering Team Review Cycle: Quarterly
This document provides instructions for setting up the API Service development environment, including prerequisites, configuration, and common workflows.

Prerequisites

Required Software

Optional Software


Quick Start

1. Clone and Setup

2. Start Dependencies

3. Run Migrations

4. Start Development Server

The API is now available at http://localhost:8080.

Project Structure


Environment Configuration

Environment Files

Required Variables

Secret Management

For production, use environment variables or secret management:

Database Setup

Create Development Database

Run Migrations

Create New Migration

Seed Test Data


Development Workflow

Running the Server

Code Generation

Running Tests

Code Quality


IDE Setup

VS Code

Recommended extensions:
  • Go (golang.go)
  • Go Test Explorer
  • Error Lens
Settings (.vscode/settings.json):

GoLand / IntelliJ

  1. Enable Go modules: Preferences > Go > Go Modules
  2. Configure linter: Preferences > Tools > File Watchers
  3. Set test runner: Run > Edit Configurations

Docker Development

Build Container

Run Container

Docker Compose Services


Common Tasks

Adding a New Endpoint

  1. Define route in internal/controller/routes.go
  2. Create handler in internal/controller/
  3. Add service method in internal/service/
  4. Add repository method if database access needed
  5. Write tests for all layers
  6. Update OpenAPI spec if public endpoint

Adding a Database Migration

Adding a New Service Dependency

  1. Add to internal/infra/ or pkg/
  2. Update Wire providers in internal/wire/
  3. Run make generate
  4. Update health checks if needed

Troubleshooting

Database Connection Issues

Redis Connection Issues

Build Failures

Test Failures


Make Targets Reference



Document Status: Complete Version: 2.0