# go-mad A web application for managing tenant database connections and running migration scripts. ## Overview go-mad is a Go web application that helps administrators manage database connections for multiple tenants. When a new tenant is added, the application contains all the database connection information for the applications associated with that tenant. The frontend is built with React and provides a beautiful, intuitive interface for managing tenants, applications, and database migrations. ## Features - **Tenant Management**: Create and manage tenants with their database connections - **Application Management**: Register and manage applications per tenant - **Database Connection Management**: Track database connections and status per tenant - **Migration Scripts**: Run goose-style SQL migration scripts per tenant database - **Role-Based Access Control**: System administrators and tenant-specific permissions - **Beautiful React UI**: Inspired by go-loose with dark/light theme support ## Quick Start ### Using Docker Compose ```bash make compose-up ``` This will start: - PostgreSQL database (`postgres:15-alpine`) - go-mad application Access the application at `http://localhost:8080` ### Manual Development ```bash # Format and vet make fmt make vet # Build and run make build ./go-mad # Or run with docker compose make compose-up ``` ## Configuration go-mad can be configured via environment variables or a `config.yaml` file: | Variable | Default | Description | |---|---|---| | `GO_MAD_DATABASE_URL` | `postgres://mad:mad@localhost:5432/mad?sslmode=disable` | PostgreSQL connection string | | `GO_MAD_SERVER_PORT` | `8080` | HTTP server port | | `GO_MAD_JWT_SECRET` | `change-me-to-a-32-plus-char-secret` | JWT secret for authentication | | `GO_MAD_CONFIG_PATH` | `config.yaml` | Path to YAML config file | ### config.yaml example ```yaml server: host: "0.0.0.0" port: "8080" database: url: "postgres://mad:mad@localhost:5432/mad?sslmode=disable" jwt: secret_key: "your-32-plus-char-secret-here" ``` ## API Endpoints ### Dashboard - `GET /api/v1/dashboard` - Get dashboard data including tenants, applications, and databases ### Tenants - `GET /api/v1/tenants` - List all tenants - `POST /api/v1/tenants` - Create a new tenant ### Applications - `GET /api/v1/applications` - List applications for a tenant - `POST /api/v1/applications` - Register a new application ### Databases - `GET /api/v1/databases` - List databases for a tenant - `POST /api/v1/databases` - Add a database connection for a tenant - `POST /api/v1/databases/{id}/migrations` - Run migrations for a database ### Authentication - `GET /login` - Login page - `POST /api/v1/auth/login` - Authenticate ## Development Workflow ```bash # Build the Go binary make build # Build the React frontend make web-build # Start with docker compose make compose-up # View logs make compose-logs # Stop make compose-down ``` ## Docker ### Build ```bash docker build -t go-mad:latest . ``` ### Push ```bash docker push go-mad:latest ``` ## Kubernetes Deploy using Helm: ```bash helm repo add go-mad ./helm/go-mad helm install go-mad go-mad/go-mad ``` ## License MIT