feat(api): generate TypeScript API client from OpenAPI specification

Create type-safe TypeScript API client automatically generated from the
OpenAPI specification. Includes generated schema types and documented client
wrapper for type-safe backend communication.

Ref: T008 (specs/001-modbus-relay-control)
This commit is contained in:
2026-01-01 23:29:31 +01:00
parent 614c82a6dc
commit 84ee4ef228
6 changed files with 498 additions and 38 deletions

View File

@@ -1,5 +1,7 @@
# STA - Smart Temperature & Appliance Control
> **🤖 AI-Assisted Development Notice**: This project uses Claude Code as a development assistant for task planning, code organization, and workflow management. However, all code is human-written, reviewed, and validated by the project maintainer. AI is used as a productivity tool, not as the author of the implementation.
Web-based Modbus relay control system for managing 8-channel relay modules over TCP.
> **⚠️ Development Status**: This project is in early development. Core features are currently being implemented following a specification-driven approach.
@@ -10,26 +12,33 @@ STA will provide a modern web interface for controlling Modbus-compatible relay
## Current Status
**Implemented:**
-Basic Rust web server with Poem framework
**Phase 1 Complete - Foundation:**
-Monorepo structure (backend + frontend at root)
- ✅ Rust web server with Poem 3.1 framework
- ✅ Configuration system (YAML + environment variables)
- ✅ Modbus TCP settings structure
- ✅ Modbus TCP and relay settings structures
- ✅ Health check and metadata API endpoints
- ✅ OpenAPI documentation with Swagger UI
- ✅ Rate limiting middleware
- ✅ SQLite schema and repository for relay labels
- ✅ Vue 3 + TypeScript frontend scaffolding with Vite
- ✅ Type-safe API client generation from OpenAPI specs
**In Progress:**
- 🚧 Domain model for relay control (Phase 2)
- 🚧 Modbus TCP client implementation (Phase 3)
**Phase 2 In Progress - Domain Layer:**
- 🚧 Domain types with Type-Driven Development (RelayId, RelayState, RelayLabel)
- 🚧 100% test coverage for domain layer
**Planned Features:**
- 📋 8-Channel Relay Control: Individual and bulk relay control (on/off/toggle)
- 📋 Real-Time Monitoring: Live relay state updates via HTTP polling
- 📋 Custom Labels: Name your relays for easy identification
- 📋 Health Monitoring: Connection status and device health tracking
- 📋 Vue 3 + TypeScript frontend
**Planned - Phases 3-8:**
- 📋 Modbus TCP client with tokio-modbus (Phase 3)
- 📋 Mock controller for testing (Phase 3)
- 📋 Health monitoring service (Phase 3)
- 📋 US1: Monitor & toggle relay states - MVP (Phase 4)
- 📋 US2: Bulk relay controls (Phase 5)
- 📋 US3: Health status display (Phase 6)
- 📋 US4: Relay labeling (Phase 7)
- 📋 Production deployment (Phase 8)
See [tasks.md](specs/001-modbus-relay-control/tasks.md) for detailed implementation roadmap.
See [tasks.md](specs/001-modbus-relay-control/tasks.md) for detailed implementation roadmap (94 tasks across 8 phases).
## Architecture
@@ -111,31 +120,41 @@ The server provides OpenAPI documentation via Swagger UI:
## Project Structure
**Current:**
**Monorepo Layout:**
```
src/
├── lib.rs - Library entry point
├── main.rs - Binary entry point
├── startup.rs - Application builder and server configuration
├── settings.rs - Configuration management
├── telemetry.rs - Logging and tracing setup
├── route/ - HTTP endpoint handlers
│ ├── health.rs - Health check endpoints
└── meta.rs - Application metadata
└── middleware/ - Custom middleware
└── rate_limit.rs
specs/ - Feature specifications and documentation
settings/ - YAML configuration files
```
**Planned (Hexagonal Architecture):**
```
src/
├── domain/ - Business logic and domain models (Phase 2)
├── application/ - Use cases and orchestration (Phase 3-4)
├── infrastructure/ - Modbus, persistence, external services (Phase 3)
└── presentation/ - API endpoints and DTOs (Phase 4)
sta/ # Repository root
├── backend/ # Rust backend workspace member
│ ├── src/
│ │ ├── lib.rs - Library entry point
│ │ ├── main.rs - Binary entry point
│ │ ├── startup.rs - Application builder and server config
├── settings.rs - Configuration management
│ ├── telemetry.rs - Logging and tracing setup
│ ├── domain/ - Business logic (Phase 2 in progress)
│ │ │ └── relay/ - Relay domain types and repository traits
│ ├── application/ - Use cases (planned Phase 3-4)
│ │ ├── infrastructure/ - External integrations (Phase 3)
└── persistence/ - SQLite repository implementation
│ │ ├── presentation/ - API layer (planned Phase 4)
│ │ ├── route/ - HTTP endpoint handlers
│ │ │ ├── health.rs - Health check endpoints
│ │ │ └── meta.rs - Application metadata
│ │ └── middleware/ - Custom middleware
│ │ └── rate_limit.rs
│ ├── settings/ - YAML configuration files
│ └── tests/ - Integration tests
├── src/ # Frontend source (Vue/TypeScript)
│ └── api/ - Type-safe API client
├── specs/ # Feature specifications and documentation
│ ├── constitution.md - Architectural principles
│ └── 001-modbus-relay-control/
│ ├── spec.md - Feature specification
│ ├── plan.md - Implementation plan
│ ├── tasks.md - Task breakdown (94 tasks)
│ └── research-cors.md - CORS configuration research
├── package.json - Frontend dependencies
├── vite.config.ts - Vite build configuration
└── justfile - Build commands
```
## Technology Stack