refactor: reorganize project into monorepo with frontend scaffolding
Convert project from single backend to monorepo structure with separate frontend (Vue 3 + TypeScript + Vite) and backend directories. Updates all configuration files and build system to support both workspaces. Ref: T007 (specs/001-modbus-relay-control)
This commit is contained in:
38
backend/src/domain/mod.rs
Normal file
38
backend/src/domain/mod.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
//! Domain layer - Pure business logic with no external dependencies
|
||||
//!
|
||||
//! This module contains the core business domain for the StA relay control system.
|
||||
//! It follows **Domain-Driven Design** principles with rich domain models and clear
|
||||
//! ubiquitous language.
|
||||
//!
|
||||
//! # Architecture Principles
|
||||
//!
|
||||
//! - **No external dependencies**: Domain layer depends only on Rust standard library
|
||||
//! - **Inward-pointing dependencies**: Infrastructure/Application depend on Domain, never reverse
|
||||
//! - **Rich domain models**: Entities and value objects encapsulate business rules
|
||||
//! - **Ubiquitous language**: Code reflects real-world relay control domain concepts
|
||||
//!
|
||||
//! # Planned Submodules
|
||||
//!
|
||||
//! - `relay`: Core relay domain (RelayId, RelayState, RelayLabel, Relay entity)
|
||||
//! - Value objects with validation (newtypes following TyDD principles)
|
||||
//! - Domain entities (Relay, RelayCollection)
|
||||
//! - Repository traits (RelayLabelRepository)
|
||||
//! - Controller traits (RelayController)
|
||||
//! - Domain errors (DomainError, ValidationError)
|
||||
//!
|
||||
//! # Type-Driven Development (TyDD)
|
||||
//!
|
||||
//! Domain types follow "make illegal states unrepresentable" principle:
|
||||
//! - `RelayId`: Newtype wrapping u8, validated to 1..=8 range
|
||||
//! - `RelayLabel`: String wrapper, validated max 50 chars
|
||||
//! - `RelayState`: Enum (On, Off) - no invalid states possible
|
||||
//!
|
||||
//! See `specs/001-modbus-relay-control/types-design.md` for complete type design.
|
||||
//!
|
||||
//! # References
|
||||
//!
|
||||
//! - Architecture: `specs/constitution.md` - Hexagonal Architecture principles
|
||||
//! - Type design: `specs/001-modbus-relay-control/types-design.md`
|
||||
//! - Domain specification: `specs/001-modbus-relay-control/spec.md`
|
||||
|
||||
pub mod relay;
|
||||
9
backend/src/domain/relay/mod.rs
Normal file
9
backend/src/domain/relay/mod.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
//! Relay domain module.
|
||||
//!
|
||||
//! This module contains the core domain logic for relay control and management,
|
||||
//! including relay types, repository abstractions, and business rules.
|
||||
|
||||
/// Repository trait and error types for relay persistence.
|
||||
pub mod repository;
|
||||
/// Domain types for relay identification and control.
|
||||
pub mod types;
|
||||
15
backend/src/domain/relay/repository.rs
Normal file
15
backend/src/domain/relay/repository.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use super::types::RelayId;
|
||||
|
||||
/// Errors that can occur during repository operations.
|
||||
///
|
||||
/// This enum provides structured error handling for all data persistence
|
||||
/// operations related to relay management.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum RepositoryError {
|
||||
/// A database operation failed with the given error message.
|
||||
#[error("Database error: {0}")]
|
||||
DatabaseError(String),
|
||||
/// The requested relay was not found in the repository.
|
||||
#[error("Relay not found: {0}")]
|
||||
NotFound(RelayId),
|
||||
}
|
||||
14
backend/src/domain/relay/types.rs
Normal file
14
backend/src/domain/relay/types.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
/// Unique identifier for a relay in the system.
|
||||
///
|
||||
/// Uses the newtype pattern to provide type safety and prevent mixing relay IDs
|
||||
/// with other numeric values. Valid values range from 0-255, corresponding to
|
||||
/// individual relay channels in the Modbus controller.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
#[repr(transparent)]
|
||||
pub struct RelayId(u8);
|
||||
|
||||
impl std::fmt::Display for RelayId {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user