123 lines
3.1 KiB
Markdown
123 lines
3.1 KiB
Markdown
|
|
# 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):
|
||
|
|
```bash
|
||
|
|
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/"
|
||
|
|
```
|
||
|
|
|
||
|
|
2. Install dependencies:
|
||
|
|
```bash
|
||
|
|
make install
|
||
|
|
```
|
||
|
|
|
||
|
|
3. Copy environment variables:
|
||
|
|
```bash
|
||
|
|
cp .env.example .env
|
||
|
|
```
|
||
|
|
|
||
|
|
4. Generate sqlc code:
|
||
|
|
```bash
|
||
|
|
make sqlc
|
||
|
|
```
|
||
|
|
|
||
|
|
5. Run the server:
|
||
|
|
```bash
|
||
|
|
make run
|
||
|
|
```
|
||
|
|
|
||
|
|
### Docker Development
|
||
|
|
|
||
|
|
From the project root:
|
||
|
|
```bash
|
||
|
|
# 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
|
||
|
|
|
||
|
|
```bash
|
||
|
|
make test
|
||
|
|
```
|
||
|
|
|
||
|
|
### Building
|
||
|
|
|
||
|
|
```bash
|
||
|
|
make build
|
||
|
|
```
|
||
|
|
|
||
|
|
The binary will be output to `bin/server`
|