Development Guide
Development Guide
Section titled “Development Guide”Setting up your development environment - Complete guide for ION Flow development.
Prerequisites
Section titled “Prerequisites”| Requirement | Version | Purpose |
|---|---|---|
| Go | 1.24.3+ | Primary language |
| PostgreSQL | 14+ | Backend database |
| SQLite3 | 3.x | Flow workspace storage |
| Git | 2.x | Version control |
Initial Setup
Section titled “Initial Setup”1. Clone Repository
Section titled “1. Clone Repository”git clone https://gitlab.com/altacrest/flow_binaries.gitcd flow_binaries2. Install Dependencies
Section titled “2. Install Dependencies”# Root modulego mod download
# Core modulecd core && go mod download && cd ..
# Backend modulecd backend && go mod download && cd ..
# Server modulecd server && go mod download && cd ..
# Packagescd packages/channel && go mod download && cd ../..cd packages/helpers && go mod download && cd ../..3. Environment Setup
Section titled “3. Environment Setup”Create .env file in project root:
# ServerPORT=8000
# DatabaseDATABASE_URL=postgres://user:password@localhost:5432/ion_flow?sslmode=disable
# EnvironmentENVIRONMENT=development
# StorageFLOW_DB_PATH=./storage/dbsSTORE_DB_PATH=./storage/storeREPO_PATH=./storage/repos4. Database Setup
Section titled “4. Database Setup”# Create databasecreatedb ion_flow
# Run migrations (if applicable)# Migrations are handled by GORM auto-migrate5. Create Storage Directories
Section titled “5. Create Storage Directories”mkdir -p storage/dbsmkdir -p storage/storemkdir -p storage/reposRunning the Application
Section titled “Running the Application”Backend (Full)
Section titled “Backend (Full)”# From project rootgo run main.go
# Or with air for hot reloadairServer (Microservice)
Section titled “Server (Microservice)”cd servergo run . -port 8080 -path ../storage/dbsRunning Tests
Section titled “Running Tests”# All testsgo test ./...
# Core testscd core && go test ./...
# Backend testscd backend && go test ./...
# With coveragego test -cover ./...Project Structure
Section titled “Project Structure”ion-binaries/├── main.go # Entry point (runs backend)├── go.mod # Root module├── core/ # Flow engine (heart)├── backend/ # Full backend with WebSocket├── server/ # REST microservice├── packages/ # Reusable packages│ ├── channel/ # Auth engine│ └── helpers/ # Utilities├── cli/ # DEPRECATED├── storage/ # Runtime data (gitignored)└── docs/ # DocumentationModule Dependencies
Section titled “Module Dependencies”graph TD Main[main.go] --> Backend Backend --> Core Backend --> Channel[packages/channel] Backend --> Helpers[packages/helpers] Server --> Core Channel --> Core Channel --> HelpersReplace Directives
Section titled “Replace Directives”Go modules use replace directives for local development:
// In backend/go.modreplace gitlab.com/altacrest/flow_binaries/core => ../corereplace gitlab.com/altacrest/flow_binaries/packages/helpers => ../packages/helpersreplace gitlab.com/altacrest/flow_binaries/packages/channel => ../packages/channelCode Style
Section titled “Code Style”Naming Conventions
Section titled “Naming Conventions”| Item | Convention | Example |
|---|---|---|
| Package | lowercase | services, models |
| Exported | PascalCase | GetFlow, UserModel |
| Unexported | camelCase | findNode, parseData |
| Constants | PascalCase | StatusSuccess |
File Organization
Section titled “File Organization”package services
import ( "standard library"
"external packages"
"internal packages")
// Constantsconst (...)
// Typestype Service struct {...}
// Constructorfunc NewService() *Service {...}
// Methodsfunc (s *Service) DoSomething() {...}
// Private helpersfunc helperFunc() {...}Comments
Section titled “Comments”- All comments in English
- Document exported functions
- Explain non-obvious logic
// GetFlow retrieves a flow by ID from the company's schema.// Returns nil if not found without error.func GetFlow(company *models.Company, flowId uint) (*models.Flow, error) { // Check company context if company == nil { return nil, errors.New("company is required") } // ...}Adding New Features
Section titled “Adding New Features”New Node Type (Core)
Section titled “New Node Type (Core)”- Create directory:
core/actions/mynewnode/ - Implement
Executefunction - Add tests
- Document in
docs/core/actions/
New Backend Feature
Section titled “New Backend Feature”- Add model if needed:
backend/ion/models/ - Add service:
backend/ion/services/ - Add controller:
backend/ion/controllers/ - Add route:
backend/routes/api.go - Add params (DTO):
backend/ion/params/ - Document in
docs/backend/
New Generic Utility
Section titled “New Generic Utility”- Check if it exists in
packages/helpers/ - If generic: add to
packages/helpers/ - If core-specific: add to
core/helpers/ - If backend-specific: add to
backend/ion/helpers/
Debugging
Section titled “Debugging”Logging
Section titled “Logging”import "log"
log.Println("Debug message")log.Printf("Value: %v", variable)SQLite Inspection
Section titled “SQLite Inspection”sqlite3 storage/dbs/flow-123.db.tablesSELECT * FROM nodes;SELECT * FROM queue;WebSocket Testing
Section titled “WebSocket Testing”Use wscat or browser dev tools:
wscat -c ws://localhost:8000/tenant/123/wsIDE Setup
Section titled “IDE Setup”VS Code
Section titled “VS Code”Recommended extensions:
- Go (golang.go)
- GitLens
- Better Comments
Cursor
Section titled “Cursor”Same as VS Code, plus:
- Use workspace rules from
.cursor/rules/
Related Documentation
Section titled “Related Documentation”- Testing Guide - Testing practices
- Building Guide - Build process
- Architecture - System overview