Files
pig-farm-controller/bmad/development-guide-main.md
2025-11-01 19:22:39 +08:00

79 lines
2.1 KiB
Markdown

# 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
1. **Clone the repository**:
```bash
git clone git.huangwc.com/pig/pig-farm-controller.git
cd pig-farm-controller
```
2. **Download Go modules**:
```bash
go mod tidy
```
3. **Configure the application**:
Copy `config.example.yml` to `config.yml` and update the necessary fields, especially `jwt_secret`, database credentials, and ChirpStack API token.
```bash
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.
```bash
# Using go run
go run main.go
# Using Makefile (if 'run' target exists)
make run
```
### 1.5. Testing
To run unit and integration tests:
```bash
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`.