- Added comprehensive course structure with 11 modules - Included theoretical content, practical examples, and tasks - Multi-language code examples (Java, Rust, Node.js, Python) - Detailed analysis of architectural approaches and trade-offs - Complete caching strategies documentation - Architecture examples from real-world systems (Twitter, Netflix, Uber) - Structured navigation and learning path - Ready for educational use
244 lines
8.8 KiB
Markdown
244 lines
8.8 KiB
Markdown
# Архитектурное проектирование
|
|
|
|
## Навигация
|
|
- [🏠 Главная страница курса](../../../README.md)
|
|
- [📚 Модуль 11](../README.md)
|
|
|
|
---
|
|
|
|
## Анализ домена
|
|
|
|
### 1. Domain Identification
|
|
```markdown
|
|
# Domain Analysis для E-commerce Platform
|
|
|
|
## Core Domains
|
|
- **User Management**: управление пользователями, аутентификация, авторизация
|
|
- **Product Catalog**: каталог товаров, категории, поиск
|
|
- **Order Management**: обработка заказов, управление состоянием
|
|
- **Payment Processing**: обработка платежей, интеграция с платежными системами
|
|
- **Inventory Management**: управление запасами, резервирование товаров
|
|
|
|
## Supporting Domains
|
|
- **Notification Service**: отправка уведомлений
|
|
- **Analytics Service**: сбор и анализ данных
|
|
- **Recommendation Service**: рекомендации товаров
|
|
- **Review Service**: система отзывов
|
|
|
|
## Generic Domains
|
|
- **Logging Service**: централизованное логирование
|
|
- **Monitoring Service**: мониторинг системы
|
|
- **Configuration Service**: управление конфигурацией
|
|
```
|
|
|
|
### 2. Bounded Context Mapping
|
|
```plantuml
|
|
@startuml
|
|
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
|
|
|
|
title E-commerce Platform - Context Map
|
|
|
|
Person(customer, "Customer", "A customer who shops online")
|
|
Person(admin, "Admin", "Platform administrator")
|
|
|
|
System_Boundary(core, "Core Business") {
|
|
System(userMgmt, "User Management", "Manages user accounts and authentication")
|
|
System(productCatalog, "Product Catalog", "Manages product information and search")
|
|
System(orderMgmt, "Order Management", "Processes and manages orders")
|
|
System(payment, "Payment Processing", "Handles payment transactions")
|
|
System(inventory, "Inventory Management", "Manages product stock")
|
|
}
|
|
|
|
System_Boundary(supporting, "Supporting Services") {
|
|
System(notification, "Notification Service", "Sends notifications to users")
|
|
System(analytics, "Analytics Service", "Collects and analyzes data")
|
|
System(recommendation, "Recommendation Service", "Provides product recommendations")
|
|
}
|
|
|
|
System_Boundary(generic, "Generic Services") {
|
|
System(logging, "Logging Service", "Centralized logging")
|
|
System(monitoring, "Monitoring Service", "System monitoring")
|
|
}
|
|
|
|
Rel(customer, userMgmt, "Uses", "HTTPS")
|
|
Rel(customer, productCatalog, "Browses", "HTTPS")
|
|
Rel(customer, orderMgmt, "Places orders", "HTTPS")
|
|
Rel(customer, payment, "Makes payments", "HTTPS")
|
|
|
|
Rel(admin, userMgmt, "Manages", "HTTPS")
|
|
Rel(admin, productCatalog, "Manages", "HTTPS")
|
|
Rel(admin, orderMgmt, "Monitors", "HTTPS")
|
|
|
|
Rel(orderMgmt, inventory, "Reserves items", "HTTP")
|
|
Rel(orderMgmt, payment, "Processes payment", "HTTP")
|
|
Rel(orderMgmt, notification, "Sends notifications", "Events")
|
|
|
|
Rel(productCatalog, recommendation, "Gets recommendations", "HTTP")
|
|
Rel(customer, analytics, "Generates events", "Events")
|
|
|
|
@enduml
|
|
```
|
|
|
|
## Проектирование архитектуры
|
|
|
|
### 1. High-Level Architecture
|
|
```plantuml
|
|
@startuml
|
|
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
|
|
|
title E-commerce Platform - Container Diagram
|
|
|
|
Person(customer, "Customer", "A customer who shops online")
|
|
Person(admin, "Admin", "Platform administrator")
|
|
|
|
System_Boundary(platform, "E-commerce Platform") {
|
|
Container(webApp, "Web Application", "React", "Single-page application for customers")
|
|
Container(adminApp, "Admin Application", "React", "Administrative interface")
|
|
Container(apiGateway, "API Gateway", "Kong", "Routes requests to microservices")
|
|
|
|
Container(userService, "User Service", "Java Spring Boot", "Manages user accounts and authentication")
|
|
Container(productService, "Product Service", "Java Spring Boot", "Manages product catalog")
|
|
Container(orderService, "Order Service", "Java Spring Boot", "Processes orders")
|
|
Container(paymentService, "Payment Service", "Java Spring Boot", "Handles payments")
|
|
Container(inventoryService, "Inventory Service", "Java Spring Boot", "Manages stock")
|
|
|
|
ContainerDb(userDb, "User Database", "PostgreSQL", "Stores user data")
|
|
ContainerDb(productDb, "Product Database", "PostgreSQL", "Stores product data")
|
|
ContainerDb(orderDb, "Order Database", "PostgreSQL", "Stores order data")
|
|
ContainerDb(paymentDb, "Payment Database", "PostgreSQL", "Stores payment data")
|
|
ContainerDb(inventoryDb, "Inventory Database", "PostgreSQL", "Stores inventory data")
|
|
|
|
Container(redis, "Redis Cache", "Redis", "Caches frequently accessed data")
|
|
Container(messageQueue, "Message Queue", "Apache Kafka", "Handles asynchronous communication")
|
|
}
|
|
|
|
System_Ext(paymentGateway, "Payment Gateway", "External payment processing service")
|
|
System_Ext(emailService, "Email Service", "External email service")
|
|
System_Ext(analyticsService, "Analytics Service", "External analytics service")
|
|
|
|
Rel(customer, webApp, "Uses", "HTTPS")
|
|
Rel(admin, adminApp, "Uses", "HTTPS")
|
|
|
|
Rel(webApp, apiGateway, "Makes API calls", "HTTPS")
|
|
Rel(adminApp, apiGateway, "Makes API calls", "HTTPS")
|
|
|
|
Rel(apiGateway, userService, "Routes requests", "HTTP")
|
|
Rel(apiGateway, productService, "Routes requests", "HTTP")
|
|
Rel(apiGateway, orderService, "Routes requests", "HTTP")
|
|
Rel(apiGateway, paymentService, "Routes requests", "HTTP")
|
|
Rel(apiGateway, inventoryService, "Routes requests", "HTTP")
|
|
|
|
Rel(userService, userDb, "Reads from and writes to", "JDBC")
|
|
Rel(productService, productDb, "Reads from and writes to", "JDBC")
|
|
Rel(orderService, orderDb, "Reads from and writes to", "JDBC")
|
|
Rel(paymentService, paymentDb, "Reads from and writes to", "JDBC")
|
|
Rel(inventoryService, inventoryDb, "Reads from and writes to", "JDBC")
|
|
|
|
Rel(userService, redis, "Caches data", "Redis Protocol")
|
|
Rel(productService, redis, "Caches data", "Redis Protocol")
|
|
Rel(orderService, redis, "Caches data", "Redis Protocol")
|
|
|
|
Rel(orderService, messageQueue, "Publishes events", "Kafka")
|
|
Rel(paymentService, messageQueue, "Consumes events", "Kafka")
|
|
Rel(inventoryService, messageQueue, "Consumes events", "Kafka")
|
|
|
|
Rel(paymentService, paymentGateway, "Processes payments", "HTTPS")
|
|
Rel(userService, emailService, "Sends emails", "SMTP")
|
|
Rel(webApp, analyticsService, "Tracks events", "HTTPS")
|
|
|
|
@enduml
|
|
```
|
|
|
|
### 2. Detailed Component Design
|
|
```plantuml
|
|
@startuml
|
|
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
|
|
|
|
title Order Service - Component Diagram
|
|
|
|
Container_Boundary(orderService, "Order Service") {
|
|
Component(controllers, "Controllers", "Spring MVC", "Handles HTTP requests")
|
|
Component(services, "Services", "Spring", "Contains business logic")
|
|
Component(repositories, "Repositories", "Spring Data", "Handles data access")
|
|
Component(events, "Event Handlers", "Spring", "Handles domain events")
|
|
Component(validators, "Validators", "Spring", "Validates input data")
|
|
}
|
|
|
|
ContainerDb(orderDb, "Order Database", "PostgreSQL", "Stores order data")
|
|
Container(redis, "Redis Cache", "Redis", "Caches order data")
|
|
Container(messageQueue, "Message Queue", "Apache Kafka", "Publishes and consumes events")
|
|
|
|
Rel(controllers, services, "Uses")
|
|
Rel(services, repositories, "Uses")
|
|
Rel(services, events, "Publishes")
|
|
Rel(services, validators, "Uses")
|
|
Rel(repositories, orderDb, "Reads from and writes to", "JDBC")
|
|
Rel(services, redis, "Caches data", "Redis Protocol")
|
|
Rel(events, messageQueue, "Publishes events", "Kafka")
|
|
|
|
@enduml
|
|
```
|
|
|
|
## Выбор технологического стека
|
|
|
|
### 1. Backend Technologies
|
|
```yaml
|
|
# Technology Stack
|
|
backend:
|
|
language: "Java 17"
|
|
framework: "Spring Boot 3.x"
|
|
build_tool: "Maven"
|
|
testing: "JUnit 5, Mockito, TestContainers"
|
|
|
|
databases:
|
|
primary: "PostgreSQL 15"
|
|
cache: "Redis 7"
|
|
search: "Elasticsearch 8"
|
|
|
|
messaging:
|
|
broker: "Apache Kafka"
|
|
protocol: "Avro"
|
|
|
|
security:
|
|
authentication: "JWT"
|
|
authorization: "Spring Security"
|
|
encryption: "AES-256"
|
|
```
|
|
|
|
### 2. Frontend Technologies
|
|
```yaml
|
|
# Frontend Stack
|
|
frontend:
|
|
framework: "React 18"
|
|
language: "TypeScript"
|
|
state_management: "Redux Toolkit"
|
|
styling: "Material-UI"
|
|
build_tool: "Vite"
|
|
testing: "Jest, React Testing Library"
|
|
```
|
|
|
|
### 3. Infrastructure Technologies
|
|
```yaml
|
|
# Infrastructure Stack
|
|
infrastructure:
|
|
containerization: "Docker"
|
|
orchestration: "Kubernetes"
|
|
service_mesh: "Istio"
|
|
api_gateway: "Kong"
|
|
|
|
monitoring:
|
|
metrics: "Prometheus"
|
|
visualization: "Grafana"
|
|
logging: "ELK Stack"
|
|
tracing: "Jaeger"
|
|
|
|
cloud:
|
|
provider: "AWS"
|
|
services:
|
|
- "EKS (Kubernetes)"
|
|
- "RDS (PostgreSQL)"
|
|
- "ElastiCache (Redis)"
|
|
- "S3 (File Storage)"
|
|
- "CloudWatch (Monitoring)"
|
|
```
|