[INIT-001] Initial project setup with Clean Architecture (feat)
Some checks failed
CD - Build & Deploy / build-and-push (push) Has been cancelled
CD - Build & Deploy / package-helm (push) Has been cancelled
CD - Build & Deploy / deploy-staging (push) Has been cancelled
CD - Build & Deploy / deploy-production (push) Has been cancelled
CD - Build & Deploy / release (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / security (push) Has been cancelled
Some checks failed
CD - Build & Deploy / build-and-push (push) Has been cancelled
CD - Build & Deploy / package-helm (push) Has been cancelled
CD - Build & Deploy / deploy-staging (push) Has been cancelled
CD - Build & Deploy / deploy-production (push) Has been cancelled
CD - Build & Deploy / release (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / security (push) Has been cancelled
- Implemented Clean Architecture with Domain, Application, Infrastructure, Presentation layers - Added comprehensive project structure following SOLID principles - Created Kubernetes deployment with Helm charts (HPA, PDB, NetworkPolicy) - Configured ArgoCD for automated deployment (production + staging) - Implemented CI/CD pipeline with GitHub Actions - Added comprehensive documentation (handbook, architecture, coding standards) - Configured PostgreSQL, Redis, Celery for backend services - Created modern landing page with Persian fonts (Vazirmatn) - Added Docker multi-stage build for production - Configured development tools (pytest, black, flake8, mypy, isort) - Added pre-commit hooks for code quality - Implemented Makefile for common operations
This commit is contained in:
174
docs/architecture/overview.md
Normal file
174
docs/architecture/overview.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# معماری کلی سیستم
|
||||
|
||||
## نمای کلی
|
||||
|
||||
پلتفرم پیکربند بر اساس **Clean Architecture** طراحی شده که قابلیت تست، نگهداری و توسعه را به حداکثر میرساند.
|
||||
|
||||
## لایههای معماری
|
||||
|
||||
### 1. Domain Layer (هسته مرکزی)
|
||||
|
||||
مستقلترین لایه که شامل منطق کسبوکار خالص است:
|
||||
|
||||
**Components:**
|
||||
- **Entities**: موجودیتهای اصلی (User, Service, Invoice, Server)
|
||||
- **Value Objects**: Email, Money, Phone, IPAddress
|
||||
- **Domain Services**: منطق پیچیدهای که به چند entity مرتبط است
|
||||
- **Domain Events**: رویدادهای کسبوکار
|
||||
- **Exceptions**: خطاهای دامین
|
||||
|
||||
**قوانین:**
|
||||
- هیچ وابستگی به لایههای دیگر ندارد
|
||||
- فقط منطق کسبوکار
|
||||
- بدون وابستگی به framework
|
||||
- Pure Python
|
||||
|
||||
### 2. Application Layer (موارد استفاده)
|
||||
|
||||
**Components:**
|
||||
- **Use Cases**: موارد استفاده سیستم (RegisterUser, CreateInvoice)
|
||||
- **DTOs**: Data Transfer Objects
|
||||
- **Interfaces**: تعریف رابطهای سرویسها
|
||||
- **Validators**: اعتبارسنجی ورودیها
|
||||
|
||||
**قوانین:**
|
||||
- وابسته به Domain Layer
|
||||
- مستقل از Infrastructure
|
||||
- تعریف رابطهای مورد نیاز
|
||||
|
||||
### 3. Infrastructure Layer (جزئیات فنی)
|
||||
|
||||
**Components:**
|
||||
- **Database**: PostgreSQL + SQLAlchemy
|
||||
- **Cache**: Redis
|
||||
- **External APIs**: DigitalOcean, Hetzner, OVH
|
||||
- **Tasks**: Celery background jobs
|
||||
- **Security**: Authentication, Authorization
|
||||
- **Logging**: Structured logging
|
||||
|
||||
**قوانین:**
|
||||
- پیادهسازی interface های Application Layer
|
||||
- وابسته به تکنولوژیهای خاص
|
||||
- قابل تعویض
|
||||
|
||||
### 4. Presentation Layer (رابط کاربری)
|
||||
|
||||
**Components:**
|
||||
- **Web**: Reflex pages و components
|
||||
- **API**: REST endpoints (optional)
|
||||
- **State Management**: Reflex states
|
||||
|
||||
**قوانین:**
|
||||
- فقط به Application Layer وابسته
|
||||
- مستقل از Infrastructure details
|
||||
|
||||
## جریان داده
|
||||
|
||||
```
|
||||
User Action
|
||||
↓
|
||||
Presentation Layer (Reflex Component)
|
||||
↓
|
||||
Application Layer (Use Case)
|
||||
↓
|
||||
Domain Layer (Business Logic)
|
||||
↓
|
||||
Application Layer (Interfaces)
|
||||
↓
|
||||
Infrastructure Layer (Implementation)
|
||||
↓
|
||||
External Systems (Database, APIs)
|
||||
```
|
||||
|
||||
## Dependency Rule
|
||||
|
||||
وابستگیها همیشه به سمت داخل (به سمت Domain) هستند:
|
||||
|
||||
```
|
||||
Presentation → Application → Domain
|
||||
Infrastructure → Application → Domain
|
||||
```
|
||||
|
||||
**قانون طلایی**: لایههای داخلی هیچ چیز از لایههای خارجی نمیدانند.
|
||||
|
||||
## مزایای این معماری
|
||||
|
||||
1. **Testability**: هر لایه مستقلا قابل تست
|
||||
2. **Maintainability**: تغییرات محلی و جداسازی شده
|
||||
3. **Flexibility**: تعویض آسان تکنولوژیها
|
||||
4. **Scalability**: قابل مقیاسپذیری در هر لایه
|
||||
5. **Business Logic First**: تمرکز روی منطق کسبوکار
|
||||
|
||||
## Domain-Driven Design (DDD)
|
||||
|
||||
پروژه از اصول DDD استفاده میکند:
|
||||
|
||||
- **Ubiquitous Language**: زبان مشترک با کسبوکار
|
||||
- **Bounded Contexts**: محدودههای مشخص
|
||||
- **Aggregates**: مجموعههای یکپارچه
|
||||
- **Repositories**: دسترسی به داده
|
||||
- **Domain Events**: رویدادهای کسبوکار
|
||||
|
||||
## Technology Stack
|
||||
|
||||
### Core
|
||||
- **Language**: Python 3.11+
|
||||
- **Framework**: Reflex 0.4.0
|
||||
- **Database**: PostgreSQL 14+
|
||||
- **Cache**: Redis 7+
|
||||
- **ORM**: SQLAlchemy 2.0+
|
||||
|
||||
### Infrastructure
|
||||
- **Task Queue**: Celery 5.3+
|
||||
- **Testing**: pytest 7.4+
|
||||
- **Logging**: structlog
|
||||
- **API Client**: httpx
|
||||
|
||||
### External Services
|
||||
- **Cloud Providers**: DigitalOcean, Hetzner, OVH
|
||||
- **Payment**: Zarinpal, IDPay
|
||||
- **Monitoring**: Sentry, Prometheus
|
||||
|
||||
## Security Architecture
|
||||
|
||||
- **Authentication**: JWT + 2FA
|
||||
- **Authorization**: RBAC (Role-Based Access Control)
|
||||
- **Encryption**: Data at rest & in transit
|
||||
- **Secrets Management**: Environment variables
|
||||
- **Audit Logging**: تمام اقدامات مهم
|
||||
|
||||
## Scalability Strategy
|
||||
|
||||
### Horizontal Scaling
|
||||
- Load balancing برای Reflex
|
||||
- Database replication
|
||||
- Redis clustering
|
||||
- Celery workers
|
||||
|
||||
### Vertical Scaling
|
||||
- Connection pooling
|
||||
- Query optimization
|
||||
- Caching strategy
|
||||
- Async operations
|
||||
|
||||
## Monitoring & Observability
|
||||
|
||||
- **Metrics**: Request rate, response time, error rate
|
||||
- **Logs**: Structured logging با contextual info
|
||||
- **Tracing**: Request tracing
|
||||
- **Alerts**: Critical issues
|
||||
- **Dashboards**: Grafana/Prometheus
|
||||
|
||||
## Future Considerations
|
||||
|
||||
- Microservices architecture (در صورت نیاز)
|
||||
- Event-driven architecture
|
||||
- CQRS pattern
|
||||
- GraphQL API
|
||||
- Multi-tenancy
|
||||
|
||||
---
|
||||
|
||||
**نسخه**: 1.0.0
|
||||
**آخرین بروزرسانی**: 2025-01-24
|
||||
|
||||
Reference in New Issue
Block a user