Technical Architecture ImplementationΒΆ
Purpose: Technical architecture specification for the Property Management System implementation.
Architecture OverviewΒΆ
graph TB
subgraph "Frontend Layer"
Web[Web App - Next.js 15 + React 19]
Mobile[Mobile App - React Native]
Admin[Admin Portal - React + TypeScript]
end
subgraph "API Gateway Layer"
Gateway[API Gateway - YARP]
Auth[Auth Service - Duende IdentityServer]
end
subgraph "Microservices Layer"
Identity[Identity Service - Port 5001]
User[User Service - Port 5002]
Organization[Organization Service - Port 5003]
Property[Property Service - Port 5004]
Financial[Financial Service - Port 5005]
Operations[Operations Service - Port 5006]
Community[Community Service - Port 5007]
Notifications[Notifications Service - Port 5008]
end
subgraph "Data Layer"
PostgreSQL[(PostgreSQL - Single DB, 6 Schemas)]
Redis[(Redis Cache)]
MessageQueue[Message Queue - RabbitMQ]
end
Web --> Gateway
Mobile --> Gateway
Admin --> Gateway
Gateway --> Auth
Gateway --> Identity
Gateway --> User
Gateway --> Organization
Gateway --> Property
Gateway --> Financial
Gateway --> Operations
Gateway --> Community
Gateway --> Notifications
Identity --> PostgreSQL
User --> PostgreSQL
Organization --> PostgreSQL
Property --> PostgreSQL
Financial --> PostgreSQL
Operations --> PostgreSQL
Community --> PostgreSQL
Notifications --> PostgreSQL
Property --> MessageQueue
Operations --> MessageQueue
Community --> MessageQueue
Notifications --> MessageQueue System Architecture PrinciplesΒΆ
1. Microservices ArchitectureΒΆ
- Service Independence: Each service operates independently with its own database schema
- Loose Coupling: Services communicate through well-defined APIs and message queues
- Technology Consistency: All services use .NET 8 with Clean Architecture
- Scalability: Services can be scaled independently based on demand
2. Event-Driven ArchitectureΒΆ
- Asynchronous Communication: Services communicate through events and messages
- Loose Coupling: Services don't need to know about each other directly
- Scalability: Easy to add new services that react to existing events
- Reliability: Message queues provide reliability and retry mechanisms
3. Multi-Tenant DesignΒΆ
- Data Isolation: Complete separation of data between organizations
- Schema-Based Separation: Single database with multiple schemas for logical separation
- Row-Level Security: Additional security layer for sensitive data
- Customization: Each tenant can customize branding and features
Authentication & AuthorizationΒΆ
Identity Service (Port 5001)ΒΆ
- Technology: Duende IdentityServer 7
- Authentication: OAuth 2.0, OpenID Connect, SAML, LDAP
- Authorization: Role-based access control (RBAC) with fine-grained permissions
- Security: JWT tokens, MFA, audit logging
JWT Token StructureΒΆ
{
"sub": "user-id",
"org_id": "organization-id",
"org_roles": ["PropertyManager", "Admin"],
"permissions": ["property:read", "tenant:manage"],
"tenant_profile_id": "tenant-id",
"exp": 1516242622,
"aud": "PropertyManagement"
}
π’ Multi-Tenant Data ModelΒΆ
Database Schema OrganizationΒΆ
PostgreSQL Database (PropertyManagementDB)
βββ identity Schema (Identity Service)
β βββ users, roles, user_roles, permissions
βββ core Schema (User, Organization, Property Services)
β βββ organizations, properties, units, user_profiles, tenants, leases
βββ financial Schema (Financial Service)
β βββ invoices, payments, expenses, budgets
βββ operations Schema (Operations Service)
β βββ work_orders, maintenance_requests, vendors, assets
βββ communication Schema (Community, Notifications Services)
β βββ messages, notifications, announcements, templates
βββ shared Schema (Common Resources)
βββ documents, settings, audit_logs
Data Isolation StrategyΒΆ
- Schema Separation: Each business domain has its own schema
- Organization Context: All business data includes organization_id
- Row-Level Security: PostgreSQL RLS policies enforce data isolation
- Cross-Schema Queries: Views and functions provide cross-domain access
π Property Management ArchitectureΒΆ
Property Service (Port 5004)ΒΆ
- Core Entities: Properties, Units, Tenants, Leases, Amenities
- Business Logic: Property creation, unit management, tenant onboarding
- Data Access: Entity Framework Core with repository pattern
- Integration: Message queue for domain events
Key Data ModelsΒΆ
erDiagram
ORGANIZATION ||--o{ PROPERTY : owns
PROPERTY ||--o{ UNIT : contains
UNIT ||--o{ TENANT : occupied_by
UNIT ||--o{ LEASE : has
ORGANIZATION {
UUID id PK
VARCHAR name
JSONB branding
JSONB settings
}
PROPERTY {
UUID id PK
UUID organization_id FK
VARCHAR name
VARCHAR address
VARCHAR property_type
JSONB specifications
}
UNIT {
UUID id PK
UUID property_id FK
VARCHAR unit_number
VARCHAR unit_type
DECIMAL square_feet
VARCHAR status
} π° Financial Management ArchitectureΒΆ
Financial Service (Port 5005)ΒΆ
- Core Entities: Invoices, Payments, Expenses, Budgets
- Business Logic: Invoice generation, payment processing, expense tracking
- External Integrations: Stripe/PayPal, accounting systems, banking APIs
- Reporting: Financial analytics and budget management
Financial OperationsΒΆ
- Invoice Generation: Automated invoice creation and management
- Payment Processing: Multiple payment methods and gateway integration
- Expense Management: Expense tracking and approval workflows
- Budget Management: Budget planning and variance analysis
π§ Operations Management ArchitectureΒΆ
Operations Service (Port 5006)ΒΆ
- Core Entities: Maintenance Requests, Work Orders, Vendors, Assets
- Business Logic: Request management, work order tracking, vendor management
- Integration: File storage, notifications, message queue
- Quality Control: Work completion verification and customer satisfaction
Operations WorkflowΒΆ
sequenceDiagram
participant Tenant
participant Operations
participant Vendor
participant Notifications
Tenant->>Operations: Submit Maintenance Request
Operations->>Operations: Create Work Order
Operations->>Vendor: Assign Work Order
Vendor->>Operations: Update Work Progress
Operations->>Notifications: Send Status Updates
Operations->>Tenant: Complete Work Order π’ Communication ArchitectureΒΆ
Communication Service (Port 5007)ΒΆ
- Core Entities: Messages, Notifications, Announcements, Templates
- Business Logic: Message management, notification delivery, template management
- Delivery Channels: Email (SendGrid/AWS SES), SMS (Twilio), Push notifications
- Integration: In-app messaging and community features
Notification SystemΒΆ
- Multi-Channel Delivery: Email, SMS, push notifications, in-app
- Template Management: Customizable message templates with variables
- Scheduling: Configurable notification timing and frequency
- Delivery Tracking: Analytics and delivery confirmation
π API Design & IntegrationΒΆ
RESTful API StandardsΒΆ
- HTTP Methods: GET, POST, PUT, DELETE for CRUD operations
- Status Codes: Appropriate HTTP status codes for responses
- Error Handling: Consistent error response format
- Versioning: API versioning for backward compatibility
Message Queue IntegrationΒΆ
- Technology: RabbitMQ for reliable message delivery
- Event Types: Domain events, integration events, system events
- Patterns: Producer-consumer pattern with dead letter queues
- Reliability: Message persistence and retry mechanisms
π Performance & ScalabilityΒΆ
Caching StrategyΒΆ
- Application Cache: In-memory caching for frequently accessed data
- Database Cache: Query result caching and connection pooling
- Redis Cache: Distributed caching for session and shared data
- CDN Integration: Static content delivery through CDN
Scalability PatternsΒΆ
- Horizontal Scaling: Load balancing across multiple service instances
- Auto-scaling: Automatic scaling based on demand metrics
- Service Discovery: Dynamic service registration and discovery
- Health Checks: Service health monitoring and failover
π Security ArchitectureΒΆ
Security LayersΒΆ
- Network Security: HTTPS/TLS, VPN access, firewall rules
- Application Security: Input validation, SQL injection protection, XSS protection
- Data Security: Encryption at rest and in transit, key management
- Compliance: GDPR compliance, data retention, audit logging
Authentication & AuthorizationΒΆ
- JWT Tokens: Stateless authentication with refresh token rotation
- RBAC: Role-based access control with fine-grained permissions
- Multi-Factor Authentication: Additional security layer
- API Security: Rate limiting, API keys, scope-based access
π± Frontend ArchitectureΒΆ
Web Application (Next.js 15)ΒΆ
- Technology: React 19, TypeScript, Tailwind CSS
- Architecture: Server-side rendering with React Server Components
- State Management: React Query for server state, Zustand for client state
- Routing: Next.js App Router for navigation
Mobile Application (React Native)ΒΆ
- Technology: React Native, TypeScript, Expo
- State Management: Zustand for state management
- Navigation: React Navigation 6
- Offline Support: Local storage with sync capabilities
π³ Infrastructure & DeploymentΒΆ
ContainerizationΒΆ
- Docker: Containerized services for consistency
- Kubernetes: Container orchestration and scaling
- Service Mesh: Istio for service-to-service communication
- Load Balancing: Kubernetes load balancing and service discovery
CI/CD PipelineΒΆ
- Source Control: Git with feature branch workflow
- Build Automation: Automated build and testing
- Security Scanning: Vulnerability and dependency scanning
- Deployment: Automated deployment to environments
π Monitoring & ObservabilityΒΆ
Telemetry StackΒΆ
- Application Insights: .NET application monitoring
- OpenTelemetry: Distributed tracing and metrics collection
- Prometheus: Metrics collection and storage
- Grafana: Visualization and alerting dashboard
Key MetricsΒΆ
- Application Metrics: Response times, error rates, throughput
- Business Metrics: Property occupancy, maintenance requests, payments
- Infrastructure Metrics: CPU, memory, disk, network usage
- Security Metrics: Failed logins, API abuse, security events
ποΈ Clean Architecture ImplementationΒΆ
Layer StructureΒΆ
Clean Architecture Layers:
βββ Web API Layer (Controllers, Middleware)
βββ Application Layer (Use Cases, DTOs, Handlers)
βββ Domain Layer (Entities, Value Objects, Services)
βββ Infrastructure Layer (Repositories, External Services)
Service CommunicationΒΆ
- Synchronous: HTTP/REST for immediate consistency requirements
- Asynchronous: Domain events via message bus for eventual consistency
- Event-Driven: Loose coupling between services through events
- API Gateway: Centralized entry point with authentication and routing
π Architecture Decision RecordsΒΆ
ADR-001: Microservices ArchitectureΒΆ
Status: Accepted Decision: Adopt microservices architecture with domain-driven design Consequences: Independent deployment, technology diversity, fault isolation
ADR-002: .NET 8 Technology StackΒΆ
Status: Accepted Decision: Use .NET 8 with ASP.NET Core for all backend services Consequences: Strong performance, rich ecosystem, good tooling
ADR-003: Single Database with Schema SeparationΒΆ
Status: Accepted Decision: Use single PostgreSQL database with schema-per-service approach Consequences: ACID transactions, simplified infrastructure, data consistency
ADR-004: Event-Driven ArchitectureΒΆ
Status: Accepted Decision: Use domain events for asynchronous service communication Consequences: Loose coupling, scalability, resilience
ADR-005: API Gateway PatternΒΆ
Status: Accepted Decision: Implement API Gateway using YARP Consequences: Centralized configuration, security, monitoring
Next Steps
- Review Development Setup for environment configuration
- Understand Database Design for data modeling
- Explore API Reference for interface specifications