Files
Alexander Abakumov 15e744da49 Initial commit: Complete Software Architecture course with 11 modules
- 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
2025-09-09 22:08:07 +03:00

202 lines
4.9 KiB
Markdown

# PlantUML
## Навигация
- [🏠 Главная страница курса](../../../README.md)
- [📚 Модуль 7](../README.md)
---
## Что такое PlantUML
**PlantUML** — инструмент для создания диаграмм из текстового описания.
## Типы диаграмм
### 1. Sequence Diagrams (Диаграммы последовательности)
```plantuml
@startuml
title Order Processing Sequence
actor Customer
participant "Web App" as Web
participant "API Gateway" as Gateway
participant "Order Service" as Order
participant "Payment Service" as Payment
participant "Inventory Service" as Inventory
database "Database" as DB
Customer -> Web: Create Order
Web -> Gateway: POST /api/orders
Gateway -> Order: Create Order Request
Order -> Inventory: Check Availability
Inventory --> Order: Availability Status
Order -> Payment: Process Payment
Payment --> Order: Payment Result
Order -> DB: Save Order
DB --> Order: Order Saved
Order --> Gateway: Order Created
Gateway --> Web: Order Response
Web --> Customer: Order Confirmation
@enduml
```
### 2. Class Diagrams (Диаграммы классов)
```plantuml
@startuml
title Order Domain Model
class Order {
- id: OrderId
- customerId: CustomerId
- items: List<OrderItem>
- status: OrderStatus
- totalAmount: Money
- createdAt: LocalDateTime
+ addItem(item: OrderItem): void
+ removeItem(itemId: ItemId): void
+ confirm(): void
+ cancel(): void
}
class OrderItem {
- id: ItemId
- productId: ProductId
- quantity: int
- unitPrice: Money
+ getTotalPrice(): Money
}
class Money {
- amount: BigDecimal
- currency: Currency
+ add(other: Money): Money
+ multiply(factor: BigDecimal): Money
}
Order ||--o{ OrderItem : contains
OrderItem ||--|| Money : unitPrice
Order ||--|| Money : totalAmount
@enduml
```
### 3. Activity Diagrams (Диаграммы активности)
```plantuml
@startuml
title Order Processing Flow
start
:Receive Order Request;
:Validate Order Data;
if (Data Valid?) then (yes)
:Check Inventory;
if (Items Available?) then (yes)
:Reserve Items;
:Process Payment;
if (Payment Successful?) then (yes)
:Create Order;
:Send Confirmation;
stop
else (no)
:Release Reserved Items;
:Return Payment Error;
stop
endif
else (no)
:Return Inventory Error;
stop
endif
else (no)
:Return Validation Error;
stop
endif
@enduml
```
### 4. Deployment Diagrams (Диаграммы развертывания)
```plantuml
@startuml
title System Deployment
node "Load Balancer" {
component "NGINX" as nginx
}
node "Application Servers" {
component "API Gateway" as gateway
component "Order Service" as order
component "Payment Service" as payment
component "User Service" as user
}
node "Database Servers" {
database "PostgreSQL" as db
database "Redis" as cache
}
node "External Services" {
component "Payment Gateway" as ext_payment
component "Email Service" as ext_email
}
nginx --> gateway
gateway --> order
gateway --> payment
gateway --> user
order --> db
payment --> db
user --> db
order --> cache
payment --> cache
user --> cache
payment --> ext_payment
user --> ext_email
@enduml
```
## Лучшие практики PlantUML
### 1. Используйте семантические имена
```plantuml
# Хорошо
participant "Order Service" as OrderService
participant "Payment Service" as PaymentService
# Плохо
participant "Service1" as S1
participant "Service2" as S2
```
### 2. Группируйте связанные элементы
```plantuml
box "Order Processing" #LightBlue
participant "Order Service" as Order
participant "Inventory Service" as Inventory
end box
box "Payment Processing" #LightGreen
participant "Payment Service" as Payment
participant "Payment Gateway" as Gateway
end box
```
### 3. Используйте цвета для выделения
```plantuml
actor Customer #LightBlue
participant "Web App" as Web #LightGreen
participant "API Gateway" as Gateway #LightYellow
database "Database" as DB #LightCoral
```
## Заключение
PlantUML предоставляет мощный инструмент для создания диаграмм:
1. **Текстовое описание** — легко версионировать и изменять
2. **Множество типов диаграмм** — от последовательностей до развертывания
3. **Автоматизация** — интеграция с CI/CD
4. **Читаемость** — семантические имена и группировка
Правильное использование PlantUML значительно улучшает качество архитектурной документации.