websocket-relay/.agents/summary/codebase_info.md
savinmax 905c241daa
Some checks failed
CI / test (push) Successful in 54s
CI / lint (push) Failing after 3m16s
Improve reliability, testing, and documentation
- Fix metrics: change MessagesTotal, ConnectionsTotal, DisconnectionsTotal
  from Gauge to Counter with proper _total naming convention
- Fix broadcast write-error handling: failed clients now get properly
  removed with accurate metrics updates
- Add graceful shutdown: SIGINT/SIGTERM handling with 10s timeout,
  CloseGoingAway frame sent to clients before disconnect
- Add integration tests: 11 tests using real WebSocket connections
  covering connect, broadcast, disconnect, concurrency, and shutdown
- Fix example client port: changed from 8000 to 8443 to match config
- Rewrite README.md to reflect current features and usage
- Add AGENTS.md and .agents/summary/ documentation for AI assistants
2026-06-11 19:14:19 +02:00

75 lines
2.6 KiB
Markdown

# Codebase Information
## Project Overview
| Field | Value |
|-------|-------|
| **Name** | websocket-relay |
| **Language** | Go 1.21 |
| **Type** | WebSocket relay server |
| **License** | Not specified |
| **Repository** | Gitea-hosted |
## Directory Structure
```
websocket-relay/
├── main.go # Application entry point
├── go.mod # Go module definition
├── go.sum # Dependency checksums
├── config.yaml # Runtime configuration
├── config.example.yaml # Example configuration with TLS enabled
├── Makefile # Build, test, release commands
├── cert.pem # TLS certificate (local dev)
├── key.pem # TLS private key (local dev)
├── README.md # Project readme
├── .gitignore # Git ignore rules
├── example/
│ └── index.html # Browser-based P2P chat demo
├── internal/
│ ├── config/
│ │ ├── config.go # YAML configuration loader
│ │ └── config_test.go # Config loader tests
│ ├── hub/
│ │ ├── hub.go # WebSocket hub (connection management + broadcast)
│ │ └── hub_test.go # Hub unit tests
│ └── metrics/
│ └── metrics.go # Prometheus metrics definitions
└── .gitea/
└── workflows/
├── ci.yml # CI pipeline (test + lint)
└── release.yml # Release pipeline (build + publish)
```
## Technology Stack
| Category | Technology | Version |
|----------|-----------|---------|
| Runtime | Go | 1.21 |
| WebSocket | gorilla/websocket | 1.5.1 |
| Metrics | prometheus/client_golang | 1.17.0 |
| Configuration | gopkg.in/yaml.v3 | 3.0.1 |
| CI/CD | Gitea Actions | — |
| Linting | golangci-lint | latest |
## Build Targets
| Command | Description |
|---------|-------------|
| `make build` | Build binary to `build/websocket-relay` |
| `make test` | Run all tests with verbose output |
| `make release` | Cross-compile for linux/amd64 and darwin/arm64 |
| `make clean` | Remove build artifacts |
| `make run` | Run from source |
| `make deps` | Tidy Go modules |
## Key Metrics
| Metric | Value |
|--------|-------|
| Total Go files | 5 (+ 2 test files) |
| Packages | 4 (`main`, `config`, `hub`, `metrics`) |
| Test files | 2 |
| CI Pipelines | 2 (CI + Release) |
| External dependencies | 3 direct, 9 indirect |