3.2 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
GoGWAPI is a Go-based gateway API service that acts as a proxy/routing service for multiple target domains. It manages domain verification, record routing, and endpoint proxying through a PostgreSQL database backend using GORM.
Architecture
Main Components:
- Main App:
app/main.go- Entry point that loads configuration and initializes database connection - Database Layer:
app/database/conn.go- PostgreSQL connection management and auto-migration using GORM - Models:
app/models/- Data models for Domain, Record, Endpoint, and Group entities - Configuration:
app/config/yaml.go- YAML-based configuration with environment variable overrides - Repositories:
app/repositories/- Data access layer for interacting with models - Schema:
app/schema/- Database schema definitions and migrations - Utils:
app/utils/- Utility functions for environment variables, hashing, HTTP responses, and error handling
Data Model Hierarchy:
- Domain → Records → Endpoints (with optional grouping)
- Endpoint Groups for organizing related endpoints
- UUID-based primary keys throughout
Development Commands
Build and Run:
# Navigate to app directory first
cd app
# Build the application
go build -o gogwapi .
# Run the application
./gogwapi
Development:
cd app
# Install dependencies
go mod tidy
# Run with hot reload (if using air)
air
# Test application
go test ./...
# Test specific package
go test ./models
# Run specific test
go test -run TestFunction ./path/to/package
Configuration
The application uses a YAML configuration file (config.yaml) that should be located in the project root. Key sections:
- Server: Host and port settings (default: 0.0.0.0:3000)
- Database: PostgreSQL connection parameters
- Targets: Routing configuration for domains, records, and endpoints
Environment variables can override YAML config values (prefixed with appropriate env tags).
Database Setup
Uses PostgreSQL with GORM ORM. The application auto-migrates models on startup. Default database settings:
- Host: localhost:5432
- User/Password: postgres/postgres
- Database: gogwapi
Key Dependencies
git.secnex.io/secnex/masterlog- Internal logging librarygorm.io/driver/postgres+gorm.io/gorm- Database ORMgithub.com/google/uuid- UUID generationgolang.org/x/crypto- Cryptographic functionsgithub.com/goccy/go-yaml- YAML parsing
Notes
- No tests currently exist in the codebase
- Application is currently in early development state
- Configuration file path expects to be relative to the app directory (
../config.yaml) - Database connection is established during application startup with auto-migration
Commit Guidelines
Important: All commits must be AI-free and should not include any references to AI tools, Claude, or automated code generation. Focus commit messages on the technical changes made rather than how they were implemented.
Additional Notes
- The service includes reverse proxy functionality with path transformation
- Docker configuration is available for containerized deployment