Обновлен план MVP
This commit is contained in:
@@ -9,27 +9,21 @@ graph TB
|
||||
B[QR Scanner]
|
||||
end
|
||||
|
||||
subgraph "Backend Services"
|
||||
C[Go Core Service]
|
||||
D[Python Document Service]
|
||||
subgraph "Backend"
|
||||
C[Go Core Service (REST)]
|
||||
end
|
||||
|
||||
subgraph "Infrastructure"
|
||||
E[PostgreSQL]
|
||||
F[Redis Cache]
|
||||
end
|
||||
|
||||
A <--> C
|
||||
B --> A
|
||||
C <--> E
|
||||
C <--> D
|
||||
D <--> F
|
||||
|
||||
style A fill:#ff9999
|
||||
style C fill:#99ccff
|
||||
style D fill:#99ff99
|
||||
style E fill:#ffcc99
|
||||
style F fill:#cc99ff
|
||||
```
|
||||
|
||||
---
|
||||
@@ -37,36 +31,25 @@ graph TB
|
||||
## 🛠️ Технологический стек
|
||||
|
||||
### Backend (Go)
|
||||
- **Framework:** Gin (легкий и быстрый)
|
||||
- **Database:** PostgreSQL
|
||||
- **Authentication:** JWT
|
||||
- **Validation:** validator
|
||||
- **Inter-service Communication:** gRPC + Protocol Buffers
|
||||
- **API Documentation:** Swagger/OpenAPI
|
||||
- Framework: Gin (легкий и быстрый)
|
||||
- Database: PostgreSQL
|
||||
- Authentication: JWT
|
||||
- Validation: validator
|
||||
- API: REST + OpenAPI (Swagger)
|
||||
|
||||
### Frontend (Angular PWA)
|
||||
- **Framework:** Angular 17+
|
||||
- **Build Tool:** Angular CLI
|
||||
- **PWA:** @angular/service-worker
|
||||
- **QR Scanner:** @zxing/ngx-scanner
|
||||
- **UI:** Angular Material + Tailwind CSS
|
||||
- **State Management:** NgRx (для сложной логики)
|
||||
|
||||
### Document Service (Python)
|
||||
- **Framework:** FastAPI (быстрый, автоматическая документация)
|
||||
- **PDF Generation:** reportlab + weasyprint
|
||||
- **Office Documents:** python-docx, openpyxl
|
||||
- **Templates:** Jinja2
|
||||
- **Caching:** Redis
|
||||
- **Inter-service Communication:** gRPC
|
||||
- Framework: Angular 17+
|
||||
- PWA: @angular/service-worker (только кэш статики)
|
||||
- QR Scanner: @zxing/ngx-scanner
|
||||
- UI: Angular Material + Tailwind CSS
|
||||
- State Management: локальные сервисы (без NgRx на MVP)
|
||||
|
||||
### Infrastructure
|
||||
- **Containerization:** Docker
|
||||
- **Orchestration:** Docker Compose
|
||||
- **Inter-service Communication:** gRPC + Protocol Buffers
|
||||
- **API Gateway:** Traefik (опционально)
|
||||
- **Security:** HTTPS, CORS, JWT
|
||||
- **Monitoring:** Structured logging + Prometheus
|
||||
- Containerization: Docker
|
||||
- Orchestration: Docker Compose
|
||||
- Web server (опционально): Nginx для фронтенда
|
||||
- Security: HTTPS, CORS, JWT
|
||||
- Monitoring: структурированное логирование (метрики Post‑MVP)
|
||||
|
||||
---
|
||||
|
||||
@@ -197,7 +180,6 @@ CREATE TABLE item_placements (
|
||||
# Аутентификация
|
||||
POST /api/auth/login
|
||||
POST /api/auth/register
|
||||
POST /api/auth/refresh
|
||||
|
||||
# Организации
|
||||
GET /api/organizations/:id
|
||||
@@ -227,168 +209,12 @@ GET /api/templates
|
||||
POST /api/templates/:id/apply
|
||||
```
|
||||
|
||||
### Document Service (Python) - REST API
|
||||
```
|
||||
# Документы
|
||||
POST /api/documents/generate-pdf
|
||||
POST /api/documents/generate-excel
|
||||
GET /api/documents/:id/status
|
||||
GET /api/documents/:id/download
|
||||
|
||||
# Шаблоны документов
|
||||
GET /api/templates
|
||||
POST /api/templates
|
||||
PUT /api/templates/:id
|
||||
DELETE /api/templates/:id
|
||||
```
|
||||
|
||||
## 🔄 Межсервисная коммуникация
|
||||
|
||||
### gRPC Services
|
||||
|
||||
#### Core Service → Document Service
|
||||
```protobuf
|
||||
service DocumentService {
|
||||
rpc GenerateQRCode(QRCodeRequest) returns (QRCodeResponse);
|
||||
rpc GenerateReport(ReportRequest) returns (ReportResponse);
|
||||
rpc GetDocumentStatus(StatusRequest) returns (StatusResponse);
|
||||
}
|
||||
```
|
||||
|
||||
#### Document Service → Core Service
|
||||
```protobuf
|
||||
service CoreService {
|
||||
rpc GetLocationData(LocationRequest) returns (LocationResponse);
|
||||
rpc GetItemData(ItemRequest) returns (ItemResponse);
|
||||
rpc ValidateTemplate(TemplateRequest) returns (TemplateResponse);
|
||||
}
|
||||
```
|
||||
|
||||
### События (Event-Driven)
|
||||
```protobuf
|
||||
message DocumentEvent {
|
||||
string event_type; // "qr_generated", "report_ready"
|
||||
string document_id;
|
||||
string organization_id;
|
||||
google.protobuf.Timestamp timestamp;
|
||||
}
|
||||
```
|
||||
|
||||
## 🔄 Диаграммы последовательности
|
||||
|
||||
### Генерация QR-кода
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant F as Frontend
|
||||
participant C as Core Service
|
||||
participant D as Document Service
|
||||
participant R as Redis
|
||||
|
||||
F->>C: POST /api/locations/:id/qr-code
|
||||
C->>D: gRPC GenerateQRCode()
|
||||
D->>D: Generate QR code
|
||||
D->>R: Cache document
|
||||
D->>C: Return document URL
|
||||
C->>F: Return QR code data
|
||||
```
|
||||
|
||||
### Размещение товара
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant U as User
|
||||
participant F as Frontend
|
||||
participant C as Core Service
|
||||
participant DB as Database
|
||||
|
||||
U->>F: Scan QR code
|
||||
F->>F: Decode location ID
|
||||
F->>C: GET /api/locations/:id
|
||||
C->>DB: Query location
|
||||
DB->>C: Return location data
|
||||
C->>F: Return location info
|
||||
F->>U: Show location details
|
||||
|
||||
U->>F: Select item & quantity
|
||||
F->>C: POST /api/operations/place-item
|
||||
C->>DB: Create placement
|
||||
DB->>C: Confirm placement
|
||||
C->>F: Return success
|
||||
F->>U: Show confirmation
|
||||
```
|
||||
|
||||
### Поиск товара
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant U as User
|
||||
participant F as Frontend
|
||||
participant C as Core Service
|
||||
participant R as Redis
|
||||
participant DB as Database
|
||||
|
||||
U->>F: Search query
|
||||
F->>C: GET /api/operations/search?q=query
|
||||
C->>R: Check cache
|
||||
alt Cache hit
|
||||
R->>C: Return cached results
|
||||
else Cache miss
|
||||
C->>DB: Search items & locations
|
||||
DB->>C: Return results
|
||||
C->>R: Cache results
|
||||
end
|
||||
C->>F: Return search results
|
||||
F->>U: Display results
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Безопасность
|
||||
|
||||
### Аутентификация
|
||||
- JWT токены с refresh механизмом
|
||||
- Organization-scope на всех запросах
|
||||
- Middleware для проверки прав доступа
|
||||
|
||||
### Валидация данных
|
||||
- Входная валидация всех параметров
|
||||
- SQL injection protection через prepared statements
|
||||
- XSS protection в frontend
|
||||
|
||||
### HTTPS
|
||||
- Обязательное использование HTTPS
|
||||
- Secure cookies для JWT
|
||||
- CORS настройки для PWA
|
||||
|
||||
---
|
||||
|
||||
## 📱 PWA Особенности
|
||||
|
||||
### Service Worker
|
||||
- Кэширование статических ресурсов
|
||||
- Offline fallback для базовых функций
|
||||
- Background sync для операций
|
||||
|
||||
### QR Scanner
|
||||
- Использование WebRTC для доступа к камере
|
||||
- Real-time распознавание QR-кодов
|
||||
- Fallback на ручной ввод
|
||||
|
||||
### Установка
|
||||
- Manifest для установки как нативное приложение
|
||||
- Splash screen и иконки
|
||||
- Автоматические обновления
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Развертывание
|
||||
|
||||
### Docker Compose
|
||||
### Docker Compose (MVP)
|
||||
```yaml
|
||||
version: '3.8'
|
||||
services:
|
||||
# Core Service (Go)
|
||||
core-service:
|
||||
build: ./core-service
|
||||
ports:
|
||||
@@ -396,23 +222,9 @@ services:
|
||||
environment:
|
||||
- DB_HOST=postgres
|
||||
- JWT_SECRET=your-secret
|
||||
- DOC_SERVICE_URL=http://doc-service:8000
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
|
||||
# Document Service (Python)
|
||||
doc-service:
|
||||
build: ./doc-service
|
||||
ports:
|
||||
- "8000:8000"
|
||||
environment:
|
||||
- REDIS_URL=redis://redis:6379
|
||||
- CORE_SERVICE_URL=http://core-service:8080
|
||||
depends_on:
|
||||
- redis
|
||||
|
||||
# Frontend (Angular)
|
||||
frontend:
|
||||
build: ./frontend
|
||||
ports:
|
||||
@@ -420,7 +232,6 @@ services:
|
||||
depends_on:
|
||||
- core-service
|
||||
|
||||
# Database
|
||||
postgres:
|
||||
image: postgres:15
|
||||
environment:
|
||||
@@ -430,29 +241,8 @@ services:
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
# Cache
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
|
||||
# API Gateway (опционально)
|
||||
traefik:
|
||||
image: traefik:v2.10
|
||||
command:
|
||||
- --api.insecure=true
|
||||
- --providers.docker=true
|
||||
ports:
|
||||
- "80:80"
|
||||
- "8081:8080"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
```
|
||||
|
||||
### Структура проекта
|
||||
|
||||
Reference in New Issue
Block a user