2.1 KiB
2.1 KiB
Development Guide - Main
This document outlines the development and operational aspects of the Pig Farm Controller application.
1. Development Setup
1.1. Technology Stack
- Language: Go 1.25
- Web Framework: Echo v4.13.4
- ORM: GORM v1.30.5
- Database: PostgreSQL (TimescaleDB)
- Logging: Zap v1.27.0
- API Documentation: Swaggo v1.16.6
1.2. Prerequisites
- Go 1.25 or higher
- PostgreSQL (with TimescaleDB extension if used)
1.3. Installation
- Clone the repository:
git clone git.huangwc.com/pig/pig-farm-controller.git cd pig-farm-controller - Download Go modules:
go mod tidy - Configure the application:
Copy
config.example.ymltoconfig.ymland update the necessary fields, especiallyjwt_secret, database credentials, and ChirpStack API token.cp config.example.yml config.yml # Edit config.yml
1.4. Running the Application
To run the application, you can use the go run command or make run if a Makefile target is defined.
# Using go run
go run main.go
# Using Makefile (if 'run' target exists)
make run
1.5. Testing
To run unit and integration tests:
go test ./...
2. Operational Information
2.1. Configuration
Application configuration is managed via config.yml. Key configurable parameters include:
app.jwt_secret: JWT signing key.server.port: HTTP server listening port.database: PostgreSQL connection details (host, port, username, password, dbname, sslmode, is_timescaledb).log: Logging level, format, and file output settings.chirp_stack: ChirpStack API host and token.lora_mesh: LoRa Mesh specific configurations (UART port, baud rate, etc.).
2.2. Logging
Logs are configured to output to console and file (./app_logs/app.log) as per config.yml. The log level can be adjusted.
2.3. Deployment
No explicit Dockerfiles or CI/CD pipeline configurations were found. Deployment is expected to be handled manually or via custom scripts based on the compiled Go binary and config.yml.