cmc-sales/go
2025-12-08 21:41:22 +11:00
..
cmd Reworking attachment logic in Go, bumping Nginx max file upload size, fixing local dev env, changes to .gitignore 2025-12-08 20:39:45 +11:00
internal/cmc Changing attachments to use php path 2025-12-08 21:41:22 +11:00
sql Fixing some quotes not showing up 2025-12-07 19:04:20 +11:00
static Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
templates Quick fix 2025-12-08 00:04:40 +11:00
tmp Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
.air.toml Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
.env.example adding back .env.example 2025-12-04 00:08:27 +11:00
go.mod Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
go.sum Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
goose.env.example Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
Makefile Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
MIGRATIONS.md Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
README.md Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
server Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
sqlc.yaml Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00

CMC Sales Go Application

Modern Go web application for CMC Sales system, designed to work alongside the legacy CakePHP application.

Architecture

  • Backend: Go with Gorilla Mux for HTTP routing
  • Database: sqlc for type-safe SQL queries
  • Frontend: Go templates with HTMX for dynamic interactions
  • Styling: Bulma CSS framework
  • Database Driver: MySQL/MariaDB

Quick Start

Local Development

  1. Configure private module access (required for code.springupsoftware.com):
go env -w GOPRIVATE=code.springupsoftware.com
# If using SSH keys with git:
git config --global url."git@code.springupsoftware.com:".insteadOf "https://code.springupsoftware.com/"
  1. Install dependencies:
make install
  1. Copy environment variables:
cp .env.example .env
  1. Generate sqlc code:
make sqlc
  1. Run the server:
make run

Docker Development

From the project root:

# Standard build (requires Go 1.23+)
docker compose up cmc-go

# If you encounter Go version issues, use the legacy build:
# Edit docker-compose.yml to use: dockerfile: Dockerfile.go.legacy

Web Interface

The application provides a modern web interface accessible at:

  • Home: / - Dashboard with quick links
  • Customers: /customers - Customer management interface
  • Products: /products - Product catalog management
  • Purchase Orders: /purchase-orders - Order tracking

Features

  • Real-time search with HTMX
  • Responsive design with Bulma CSS
  • Form validation and error handling
  • Pagination for large datasets
  • CRUD operations with dynamic updates

API Endpoints

REST API endpoints are available under /api/v1:

Customers

  • GET /api/v1/customers - List customers (JSON)
  • GET /api/v1/customers/{id} - Get customer by ID
  • POST /api/v1/customers - Create new customer
  • PUT /api/v1/customers/{id} - Update customer
  • DELETE /api/v1/customers/{id} - Delete customer
  • GET /api/v1/customers/search?q={query} - Search customers

Products

  • GET /api/v1/products - List products (JSON)
  • GET /api/v1/products/{id} - Get product by ID
  • POST /api/v1/products - Create new product
  • PUT /api/v1/products/{id} - Update product
  • DELETE /api/v1/products/{id} - Delete product
  • GET /api/v1/products/search?q={query} - Search products

Purchase Orders

  • GET /api/v1/purchase-orders - List purchase orders (JSON)
  • GET /api/v1/purchase-orders/{id} - Get purchase order by ID
  • POST /api/v1/purchase-orders - Create new purchase order
  • PUT /api/v1/purchase-orders/{id} - Update purchase order
  • DELETE /api/v1/purchase-orders/{id} - Delete purchase order
  • GET /api/v1/purchase-orders/search?q={query} - Search purchase orders

Health Check

  • GET /api/v1/health - Service health check

Development

Adding New Queries

  1. Add SQL queries to sql/queries/
  2. Run make sqlc to generate Go code
  3. Create handler in internal/cmc/handlers/
  4. Register routes in cmd/server/main.go

Testing

make test

Building

make build

The binary will be output to bin/server