oktopus/
├── agent/ # USP Agent configuration and examples
├── backend/ # Core backend services
│ └── services/
│ ├── controller/ # Main controller service
│ └── mtp/ # Message Transfer Protocol adapters
├── frontend/ # Next.js web application
├── deploy/ # Deployment configurations
└── docs/ # GitBook documentation
The backend is built with Go and follows a modular service architecture:
Controller Service
Located in backend/services/controller/, this is the core service that manages devices and handles protocol communications.
Key Components:
- API Layer (
internal/api/): REST API endpoints for device managementapi.go: Main API router and middleware setup- Device message handlers (GET, SET, ADD, DELETE operations)
- CWMP Support (
internal/cwmp/): TR-069 protocol implementation- Handles CWMP-specific operations like GetParameterNames, SetParameterValues
- Entity Layer (
internal/entity/): Core business entities and data models - Database Layer (
internal/db/): Database abstraction and persistence - Bridge (
internal/bridge/): Communication bridge between services
MTP Adapters
The Message Transfer Protocol adapters handle different communication protocols:
- WebSocket Adapter (
backend/services/mtp/ws-adapter/): Implements WebSocket MTP for USP - MQTT Adapter: Handles MQTT-based communication
- STOMP Adapter: Handles STOMP protocol
As mentioned in the USP MTP documentation, USP supports multiple MTPs including WebSockets, MQTT, and STOMP.
The frontend is built with Next.js and located in frontend/. It provides a web interface for managing devices.
- Go: Version 1.23+
- Node.js: Version 18+
- NATS: Message broker for inter-service communication
- Docker: For containerized development (optional)
Docker Development
From the root build/ directory, you can build all services at once:
cd build/
make build # Build all services (backend + frontend)
make build-backend # Build only backend services
make build-frontend # Build only frontendBuilding Individual Microservices
Each microservice has its own build directory with a Makefile and Dockerfile. The general pattern is:
cd backend/services/<service-name>/build/
make buildAvailable Backend Services:
-
Controller Service - Core device management
cd backend/services/controller/build/ make build- Built from:
cmd/controller/main.go - Binary:
controller - Base image: Alpine Linux
- Built from:
-
ACS Service - Auto Configuration Server (CWMP)
cd backend/services/acs/build/ make build- Built from:
cmd/acs/main.go - Binary:
acs - Base image: Alpine Linux
- Built from:
-
MTP Adapters - Message Transfer Protocol handlers
WebSocket Adapter:
cd backend/services/mtp/ws-adapter/build/ make build- Built from:
cmd/ws-adapter/main.go - Handles WebSocket connections for USP
WebSocket Service:
cd backend/services/mtp/ws/build/ make build- Built from:
cmd/ws/main.go
MQTT Adapter:
cd backend/services/mtp/mqtt-adapter/build/ make build- Built from:
cmd/mqtt-adapter/main.go - Handles MQTT connections for USP
MQTT Service:
cd backend/services/mtp/mqtt/build/ make build- Built from:
cmd/mqtt/main.go
STOMP Adapter:
cd backend/services/mtp/stomp-adapter/build/ make build- Built from:
cmd/stomp-adapter/main.go - Handles STOMP connections for USP
STOMP Service:
cd backend/services/mtp/stomp/build/ make build- Built from:
cmd/stomp/main.go
Generic Adapter:
cd backend/services/mtp/adapter/build/ make build- Built from:
cmd/adapter/main.go
- Built from:
-
Utility Services
Socket.IO Service:
cd backend/services/utils/socketio/build/ make build- Node.js service for real-time communication
- Base image: Node 16.20.2-alpine
File Server:
cd backend/services/utils/file-server/build/ make build- Serves firmware files and other static content
-
Bulk Data Collector
cd backend/services/bulkdata/http/build/ make build- Built from:
cmd/http-bulk-collector/main.go - Collects bulk data from devices [WIP]
- Built from:
Building the Frontend
cd frontend/build/
make build- Next.js application
- Node.js 18.18.0-alpine base image
- Production build with optimizations
Backend Services (Go):
# Navigate to the service directory
cd backend/services/controller # or any other service
# Install dependencies
go mod download
# Run locally
go run cmd/controller/main.go # adjust path for the specific service cmd/{service}/main.go
# Build binary
go build -o controller cmd/controller/main.go
# Run binary
./controller
# Run without build (for development purposes)
go run cmd/controller/main.goFrontend (Next.js):
cd frontend
# Install dependencies
npm install
# Development server
npm run dev
# Production build
npm run build
npm run startMakefile Commands
Each service's Makefile supports these commands:
make build- Build Docker imagemake push- Push image to registrymake run- Create and start containermake stop- Stop running containermake remove- Remove containermake delete- Delete Docker imagemake logs- Show container logsmake bash- Access container shellmake release- Tag as latest and push
Customization:
# Build with custom Docker user
make build DOCKER_USER=myuser
# Build with specific tag
make build DOCKER_TAG=v1.0.0
# Use different shell for container access
make bash CONTAINER_SHELL=/bin/bashThe project includes:
- Build configurations in
build/Makefile - Docker Compose deployment in
deploy/compose/ - Kubernetes deployment in
deploy/kubernetes/
The controller service follows a clean architecture pattern:
backend/services/controller/
├── cmd/ # Application entry points
├── internal/
│ ├── api/ # HTTP API handlers
│ ├── bridge/ # Service communication bridge
│ ├── config/ # Configuration management
│ ├── cwmp/ # CWMP protocol implementation
│ ├── db/ # Database layer
│ ├── entity/ # Domain entities
│ └── utils/ # Utility functions
└── main.go
- Fork the repository and create a feature branch
- Make your changes following the code style guidelines
- Write clear commit messages describing what and why
- Test thoroughly with both protocols if applicable
- Update documentation if you're adding new features
- Submit a pull request to the main repository
Include in your PR description:
- What problem does it solve?
- How was it tested?
- Any breaking changes?
- Screenshots (for UI changes)
- Device connects via MTP adapter (WebSocket/MQTT/STOMP for USP, or ACS connection for CWMP)
- Adapter ingest and digest messages through NATS message broker
- API endpoint at Controller processes the user requests
- Message is queued and sent to the device
- Response is awaited with timeout
- Result is returned to the client
The codebase supports both protocols:
CWMP (TR-069):
- Synchronous request/response model
- XML-based RPC
- Direct parameter paths (e.g.,
InternetGatewayDevice.LANDevice.*.WLANConfiguration.*) - See
internal/cwmp/for implementation
USP (TR-369):
- Supports multiple MTPs (MQTT, WebSocket, STOMP)
- Protocol Buffers encoding
- More flexible messaging model
When adding features, update:
- Code comments: Especially for exported functions
- GitBook docs in
docs/: Add user-facing documentation - README files: Update relevant README files
- API documentation: If adding new endpoints
- Main Repository: github.com/OktopUSP/oktopus
- Documentation: github.com/OktopUSP/docs
- Community Slack: Join the Oktopus Slack
- Rest API Spec: Oktopus Postman Documentation
- USP Specification: Broadband Forum TR-369
- CWMP Specification: Broadband Forum TR-069
- Community Support: Available on Slack
- Enterprise Support: support@oktopus.app.br
- Issues: Report bugs on GitHub Issues
Oktopus is released under the license specified in the LICENSE file. Make sure your contributions comply with this license.