backend-systems 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- backend_systems-1.0.0/PKG-INFO +186 -0
- backend_systems-1.0.0/README.md +153 -0
- backend_systems-1.0.0/backend_systems.egg-info/PKG-INFO +186 -0
- backend_systems-1.0.0/backend_systems.egg-info/SOURCES.txt +41 -0
- backend_systems-1.0.0/backend_systems.egg-info/dependency_links.txt +1 -0
- backend_systems-1.0.0/backend_systems.egg-info/requires.txt +20 -0
- backend_systems-1.0.0/backend_systems.egg-info/top_level.txt +1 -0
- backend_systems-1.0.0/pyproject.toml +70 -0
- backend_systems-1.0.0/setup.cfg +4 -0
- backend_systems-1.0.0/src/__init__.py +10 -0
- backend_systems-1.0.0/src/application/__init__.py +1 -0
- backend_systems-1.0.0/src/application/services/__init__.py +1 -0
- backend_systems-1.0.0/src/application/services/auth_service.py +216 -0
- backend_systems-1.0.0/src/application/services/order_service.py +272 -0
- backend_systems-1.0.0/src/config.py +92 -0
- backend_systems-1.0.0/src/domain/__init__.py +1 -0
- backend_systems-1.0.0/src/domain/entities/__init__.py +17 -0
- backend_systems-1.0.0/src/domain/entities/inventory.py +246 -0
- backend_systems-1.0.0/src/domain/entities/order.py +290 -0
- backend_systems-1.0.0/src/domain/entities/organization.py +136 -0
- backend_systems-1.0.0/src/domain/entities/user.py +143 -0
- backend_systems-1.0.0/src/domain/value_objects/__init__.py +7 -0
- backend_systems-1.0.0/src/domain/value_objects/address.py +96 -0
- backend_systems-1.0.0/src/domain/value_objects/email.py +90 -0
- backend_systems-1.0.0/src/domain/value_objects/money.py +215 -0
- backend_systems-1.0.0/src/infrastructure/__init__.py +1 -0
- backend_systems-1.0.0/src/infrastructure/database/__init__.py +1 -0
- backend_systems-1.0.0/src/infrastructure/database/models.py +281 -0
- backend_systems-1.0.0/src/infrastructure/database/session.py +96 -0
- backend_systems-1.0.0/src/infrastructure/repositories/__init__.py +1 -0
- backend_systems-1.0.0/src/infrastructure/repositories/base.py +158 -0
- backend_systems-1.0.0/src/infrastructure/repositories/inventory_repository.py +228 -0
- backend_systems-1.0.0/src/infrastructure/repositories/order_repository.py +211 -0
- backend_systems-1.0.0/src/infrastructure/repositories/user_repository.py +120 -0
- backend_systems-1.0.0/src/main.py +120 -0
- backend_systems-1.0.0/src/presentation/__init__.py +1 -0
- backend_systems-1.0.0/src/presentation/routes/__init__.py +1 -0
- backend_systems-1.0.0/src/presentation/routes/auth.py +217 -0
- backend_systems-1.0.0/src/presentation/routes/health.py +103 -0
- backend_systems-1.0.0/src/presentation/routes/inventory.py +346 -0
- backend_systems-1.0.0/src/presentation/routes/orders.py +340 -0
- backend_systems-1.0.0/src/presentation/routes/users.py +286 -0
- backend_systems-1.0.0/src/presentation/schemas/__init__.py +1 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: backend-systems
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: ERP-style backend with DDD and Clean Architecture
|
|
5
|
+
Author-email: Engineering Team <team@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: fastapi>=0.109.0
|
|
15
|
+
Requires-Dist: uvicorn[standard]>=0.27.0
|
|
16
|
+
Requires-Dist: sqlalchemy>=2.0.25
|
|
17
|
+
Requires-Dist: alembic>=1.13.1
|
|
18
|
+
Requires-Dist: psycopg2-binary>=2.9.9
|
|
19
|
+
Requires-Dist: pydantic>=2.5.3
|
|
20
|
+
Requires-Dist: pydantic-settings>=2.1.0
|
|
21
|
+
Requires-Dist: python-jose[cryptography]>=3.3.0
|
|
22
|
+
Requires-Dist: passlib[bcrypt]>=1.7.4
|
|
23
|
+
Requires-Dist: python-multipart>=0.0.6
|
|
24
|
+
Requires-Dist: httpx>=0.26.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.4.4; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.23.3; extra == "dev"
|
|
29
|
+
Requires-Dist: httpx>=0.26.0; extra == "dev"
|
|
30
|
+
Requires-Dist: black>=24.1.0; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.1.14; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.8.0; extra == "dev"
|
|
33
|
+
|
|
34
|
+
# 01_backend_systems - ERP-Style Backend
|
|
35
|
+
|
|
36
|
+
> Production-grade ERP backend demonstrating Domain-Driven Design, Clean Architecture, and enterprise patterns.
|
|
37
|
+
|
|
38
|
+
## 🎯 Overview
|
|
39
|
+
|
|
40
|
+
This module implements a comprehensive ERP-style backend with:
|
|
41
|
+
|
|
42
|
+
- **Domain-Driven Design (DDD)** - Entities, Value Objects, Aggregates
|
|
43
|
+
- **Clean Architecture** - Layered separation of concerns
|
|
44
|
+
- **RBAC** - Role-based access control
|
|
45
|
+
- **RESTful APIs** - OpenAPI 3.0 documented
|
|
46
|
+
- **PostgreSQL** - With Alembic migrations
|
|
47
|
+
|
|
48
|
+
## 📁 Structure
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
01_backend_systems/
|
|
52
|
+
├── src/
|
|
53
|
+
│ ├── domain/ # Business logic & entities
|
|
54
|
+
│ │ ├── entities/ # Core domain models
|
|
55
|
+
│ │ └── value_objects/# Immutable value types
|
|
56
|
+
│ ├── application/ # Use cases & services
|
|
57
|
+
│ │ └── services/ # Application services
|
|
58
|
+
│ ├── infrastructure/ # External concerns
|
|
59
|
+
│ │ ├── database/ # DB connection & session
|
|
60
|
+
│ │ └── repositories/ # Data access layer
|
|
61
|
+
│ └── presentation/ # API layer
|
|
62
|
+
│ ├── routes/ # API endpoints
|
|
63
|
+
│ └── schemas/ # Pydantic models
|
|
64
|
+
├── alembic/ # Database migrations
|
|
65
|
+
├── tests/ # Unit & integration tests
|
|
66
|
+
└── example_data/ # Sample data for testing
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 🚀 Quick Start
|
|
70
|
+
|
|
71
|
+
### Prerequisites
|
|
72
|
+
|
|
73
|
+
- Python 3.11+
|
|
74
|
+
- PostgreSQL 14+ (or use SQLite for development)
|
|
75
|
+
|
|
76
|
+
### Installation
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Create virtual environment
|
|
80
|
+
python -m venv venv
|
|
81
|
+
source venv/bin/activate # or `venv\Scripts\activate` on Windows
|
|
82
|
+
|
|
83
|
+
# Install dependencies
|
|
84
|
+
pip install -e .
|
|
85
|
+
|
|
86
|
+
# Set environment variables
|
|
87
|
+
cp .env.example .env
|
|
88
|
+
# Edit .env with your database credentials
|
|
89
|
+
|
|
90
|
+
# Run migrations
|
|
91
|
+
alembic upgrade head
|
|
92
|
+
|
|
93
|
+
# Start the server
|
|
94
|
+
uvicorn src.main:app --reload --port 8000
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### API Documentation
|
|
98
|
+
|
|
99
|
+
Once running, visit:
|
|
100
|
+
|
|
101
|
+
- Swagger UI: <http://localhost:8000/docs>
|
|
102
|
+
- ReDoc: <http://localhost:8000/redoc>
|
|
103
|
+
|
|
104
|
+
## 🏗️ Architecture
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
108
|
+
│ PRESENTATION LAYER │
|
|
109
|
+
│ (FastAPI Routes, Pydantic Schemas, Request/Response DTOs) │
|
|
110
|
+
└─────────────────────────────────────────────────────────────┘
|
|
111
|
+
│
|
|
112
|
+
▼
|
|
113
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
114
|
+
│ APPLICATION LAYER │
|
|
115
|
+
│ (Use Cases, Application Services, Business Logic) │
|
|
116
|
+
└─────────────────────────────────────────────────────────────┘
|
|
117
|
+
│
|
|
118
|
+
▼
|
|
119
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
120
|
+
│ DOMAIN LAYER │
|
|
121
|
+
│ (Entities, Value Objects, Domain Services, Aggregates) │
|
|
122
|
+
└─────────────────────────────────────────────────────────────┘
|
|
123
|
+
│
|
|
124
|
+
▼
|
|
125
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
126
|
+
│ INFRASTRUCTURE LAYER │
|
|
127
|
+
│ (Repositories, Database, External APIs, Messaging) │
|
|
128
|
+
└─────────────────────────────────────────────────────────────┘
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 📋 Domain Model
|
|
132
|
+
|
|
133
|
+
The ERP system manages:
|
|
134
|
+
|
|
135
|
+
- **Organizations** - Multi-tenant company management
|
|
136
|
+
- **Users** - Authentication and authorization
|
|
137
|
+
- **Inventory** - Product and stock management
|
|
138
|
+
- **Orders** - Sales order processing
|
|
139
|
+
- **Invoices** - Billing and payment tracking
|
|
140
|
+
|
|
141
|
+
## 🔒 RBAC Roles
|
|
142
|
+
|
|
143
|
+
| Role | Permissions |
|
|
144
|
+
|------|-------------|
|
|
145
|
+
| `admin` | Full system access |
|
|
146
|
+
| `manager` | Read/write on assigned resources |
|
|
147
|
+
| `operator` | Limited write access |
|
|
148
|
+
| `viewer` | Read-only access |
|
|
149
|
+
|
|
150
|
+
## 🧪 Testing
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Run all tests
|
|
154
|
+
pytest tests/
|
|
155
|
+
|
|
156
|
+
# Run with coverage
|
|
157
|
+
pytest tests/ --cov=src --cov-report=html
|
|
158
|
+
|
|
159
|
+
# Run specific test file
|
|
160
|
+
pytest tests/unit/test_entities.py -v
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## 📊 API Endpoints
|
|
164
|
+
|
|
165
|
+
| Method | Endpoint | Description |
|
|
166
|
+
|--------|----------|-------------|
|
|
167
|
+
| POST | `/api/v1/auth/login` | Authenticate user |
|
|
168
|
+
| GET | `/api/v1/users` | List users |
|
|
169
|
+
| POST | `/api/v1/orders` | Create order |
|
|
170
|
+
| GET | `/api/v1/inventory` | List inventory |
|
|
171
|
+
| GET | `/health` | Health check |
|
|
172
|
+
|
|
173
|
+
## 🔧 Configuration
|
|
174
|
+
|
|
175
|
+
Environment variables (`.env`):
|
|
176
|
+
|
|
177
|
+
```env
|
|
178
|
+
DATABASE_URL=postgresql://user:pass@localhost:5432/erp_db
|
|
179
|
+
SECRET_KEY=your-secret-key-here
|
|
180
|
+
DEBUG=true
|
|
181
|
+
ALLOWED_HOSTS=localhost,127.0.0.1
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 📄 License
|
|
185
|
+
|
|
186
|
+
MIT
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# 01_backend_systems - ERP-Style Backend
|
|
2
|
+
|
|
3
|
+
> Production-grade ERP backend demonstrating Domain-Driven Design, Clean Architecture, and enterprise patterns.
|
|
4
|
+
|
|
5
|
+
## 🎯 Overview
|
|
6
|
+
|
|
7
|
+
This module implements a comprehensive ERP-style backend with:
|
|
8
|
+
|
|
9
|
+
- **Domain-Driven Design (DDD)** - Entities, Value Objects, Aggregates
|
|
10
|
+
- **Clean Architecture** - Layered separation of concerns
|
|
11
|
+
- **RBAC** - Role-based access control
|
|
12
|
+
- **RESTful APIs** - OpenAPI 3.0 documented
|
|
13
|
+
- **PostgreSQL** - With Alembic migrations
|
|
14
|
+
|
|
15
|
+
## 📁 Structure
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
01_backend_systems/
|
|
19
|
+
├── src/
|
|
20
|
+
│ ├── domain/ # Business logic & entities
|
|
21
|
+
│ │ ├── entities/ # Core domain models
|
|
22
|
+
│ │ └── value_objects/# Immutable value types
|
|
23
|
+
│ ├── application/ # Use cases & services
|
|
24
|
+
│ │ └── services/ # Application services
|
|
25
|
+
│ ├── infrastructure/ # External concerns
|
|
26
|
+
│ │ ├── database/ # DB connection & session
|
|
27
|
+
│ │ └── repositories/ # Data access layer
|
|
28
|
+
│ └── presentation/ # API layer
|
|
29
|
+
│ ├── routes/ # API endpoints
|
|
30
|
+
│ └── schemas/ # Pydantic models
|
|
31
|
+
├── alembic/ # Database migrations
|
|
32
|
+
├── tests/ # Unit & integration tests
|
|
33
|
+
└── example_data/ # Sample data for testing
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 🚀 Quick Start
|
|
37
|
+
|
|
38
|
+
### Prerequisites
|
|
39
|
+
|
|
40
|
+
- Python 3.11+
|
|
41
|
+
- PostgreSQL 14+ (or use SQLite for development)
|
|
42
|
+
|
|
43
|
+
### Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Create virtual environment
|
|
47
|
+
python -m venv venv
|
|
48
|
+
source venv/bin/activate # or `venv\Scripts\activate` on Windows
|
|
49
|
+
|
|
50
|
+
# Install dependencies
|
|
51
|
+
pip install -e .
|
|
52
|
+
|
|
53
|
+
# Set environment variables
|
|
54
|
+
cp .env.example .env
|
|
55
|
+
# Edit .env with your database credentials
|
|
56
|
+
|
|
57
|
+
# Run migrations
|
|
58
|
+
alembic upgrade head
|
|
59
|
+
|
|
60
|
+
# Start the server
|
|
61
|
+
uvicorn src.main:app --reload --port 8000
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### API Documentation
|
|
65
|
+
|
|
66
|
+
Once running, visit:
|
|
67
|
+
|
|
68
|
+
- Swagger UI: <http://localhost:8000/docs>
|
|
69
|
+
- ReDoc: <http://localhost:8000/redoc>
|
|
70
|
+
|
|
71
|
+
## 🏗️ Architecture
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
75
|
+
│ PRESENTATION LAYER │
|
|
76
|
+
│ (FastAPI Routes, Pydantic Schemas, Request/Response DTOs) │
|
|
77
|
+
└─────────────────────────────────────────────────────────────┘
|
|
78
|
+
│
|
|
79
|
+
▼
|
|
80
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
81
|
+
│ APPLICATION LAYER │
|
|
82
|
+
│ (Use Cases, Application Services, Business Logic) │
|
|
83
|
+
└─────────────────────────────────────────────────────────────┘
|
|
84
|
+
│
|
|
85
|
+
▼
|
|
86
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
87
|
+
│ DOMAIN LAYER │
|
|
88
|
+
│ (Entities, Value Objects, Domain Services, Aggregates) │
|
|
89
|
+
└─────────────────────────────────────────────────────────────┘
|
|
90
|
+
│
|
|
91
|
+
▼
|
|
92
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
93
|
+
│ INFRASTRUCTURE LAYER │
|
|
94
|
+
│ (Repositories, Database, External APIs, Messaging) │
|
|
95
|
+
└─────────────────────────────────────────────────────────────┘
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 📋 Domain Model
|
|
99
|
+
|
|
100
|
+
The ERP system manages:
|
|
101
|
+
|
|
102
|
+
- **Organizations** - Multi-tenant company management
|
|
103
|
+
- **Users** - Authentication and authorization
|
|
104
|
+
- **Inventory** - Product and stock management
|
|
105
|
+
- **Orders** - Sales order processing
|
|
106
|
+
- **Invoices** - Billing and payment tracking
|
|
107
|
+
|
|
108
|
+
## 🔒 RBAC Roles
|
|
109
|
+
|
|
110
|
+
| Role | Permissions |
|
|
111
|
+
|------|-------------|
|
|
112
|
+
| `admin` | Full system access |
|
|
113
|
+
| `manager` | Read/write on assigned resources |
|
|
114
|
+
| `operator` | Limited write access |
|
|
115
|
+
| `viewer` | Read-only access |
|
|
116
|
+
|
|
117
|
+
## 🧪 Testing
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Run all tests
|
|
121
|
+
pytest tests/
|
|
122
|
+
|
|
123
|
+
# Run with coverage
|
|
124
|
+
pytest tests/ --cov=src --cov-report=html
|
|
125
|
+
|
|
126
|
+
# Run specific test file
|
|
127
|
+
pytest tests/unit/test_entities.py -v
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 📊 API Endpoints
|
|
131
|
+
|
|
132
|
+
| Method | Endpoint | Description |
|
|
133
|
+
|--------|----------|-------------|
|
|
134
|
+
| POST | `/api/v1/auth/login` | Authenticate user |
|
|
135
|
+
| GET | `/api/v1/users` | List users |
|
|
136
|
+
| POST | `/api/v1/orders` | Create order |
|
|
137
|
+
| GET | `/api/v1/inventory` | List inventory |
|
|
138
|
+
| GET | `/health` | Health check |
|
|
139
|
+
|
|
140
|
+
## 🔧 Configuration
|
|
141
|
+
|
|
142
|
+
Environment variables (`.env`):
|
|
143
|
+
|
|
144
|
+
```env
|
|
145
|
+
DATABASE_URL=postgresql://user:pass@localhost:5432/erp_db
|
|
146
|
+
SECRET_KEY=your-secret-key-here
|
|
147
|
+
DEBUG=true
|
|
148
|
+
ALLOWED_HOSTS=localhost,127.0.0.1
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## 📄 License
|
|
152
|
+
|
|
153
|
+
MIT
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: backend-systems
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: ERP-style backend with DDD and Clean Architecture
|
|
5
|
+
Author-email: Engineering Team <team@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: fastapi>=0.109.0
|
|
15
|
+
Requires-Dist: uvicorn[standard]>=0.27.0
|
|
16
|
+
Requires-Dist: sqlalchemy>=2.0.25
|
|
17
|
+
Requires-Dist: alembic>=1.13.1
|
|
18
|
+
Requires-Dist: psycopg2-binary>=2.9.9
|
|
19
|
+
Requires-Dist: pydantic>=2.5.3
|
|
20
|
+
Requires-Dist: pydantic-settings>=2.1.0
|
|
21
|
+
Requires-Dist: python-jose[cryptography]>=3.3.0
|
|
22
|
+
Requires-Dist: passlib[bcrypt]>=1.7.4
|
|
23
|
+
Requires-Dist: python-multipart>=0.0.6
|
|
24
|
+
Requires-Dist: httpx>=0.26.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.4.4; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.23.3; extra == "dev"
|
|
29
|
+
Requires-Dist: httpx>=0.26.0; extra == "dev"
|
|
30
|
+
Requires-Dist: black>=24.1.0; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.1.14; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.8.0; extra == "dev"
|
|
33
|
+
|
|
34
|
+
# 01_backend_systems - ERP-Style Backend
|
|
35
|
+
|
|
36
|
+
> Production-grade ERP backend demonstrating Domain-Driven Design, Clean Architecture, and enterprise patterns.
|
|
37
|
+
|
|
38
|
+
## 🎯 Overview
|
|
39
|
+
|
|
40
|
+
This module implements a comprehensive ERP-style backend with:
|
|
41
|
+
|
|
42
|
+
- **Domain-Driven Design (DDD)** - Entities, Value Objects, Aggregates
|
|
43
|
+
- **Clean Architecture** - Layered separation of concerns
|
|
44
|
+
- **RBAC** - Role-based access control
|
|
45
|
+
- **RESTful APIs** - OpenAPI 3.0 documented
|
|
46
|
+
- **PostgreSQL** - With Alembic migrations
|
|
47
|
+
|
|
48
|
+
## 📁 Structure
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
01_backend_systems/
|
|
52
|
+
├── src/
|
|
53
|
+
│ ├── domain/ # Business logic & entities
|
|
54
|
+
│ │ ├── entities/ # Core domain models
|
|
55
|
+
│ │ └── value_objects/# Immutable value types
|
|
56
|
+
│ ├── application/ # Use cases & services
|
|
57
|
+
│ │ └── services/ # Application services
|
|
58
|
+
│ ├── infrastructure/ # External concerns
|
|
59
|
+
│ │ ├── database/ # DB connection & session
|
|
60
|
+
│ │ └── repositories/ # Data access layer
|
|
61
|
+
│ └── presentation/ # API layer
|
|
62
|
+
│ ├── routes/ # API endpoints
|
|
63
|
+
│ └── schemas/ # Pydantic models
|
|
64
|
+
├── alembic/ # Database migrations
|
|
65
|
+
├── tests/ # Unit & integration tests
|
|
66
|
+
└── example_data/ # Sample data for testing
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 🚀 Quick Start
|
|
70
|
+
|
|
71
|
+
### Prerequisites
|
|
72
|
+
|
|
73
|
+
- Python 3.11+
|
|
74
|
+
- PostgreSQL 14+ (or use SQLite for development)
|
|
75
|
+
|
|
76
|
+
### Installation
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Create virtual environment
|
|
80
|
+
python -m venv venv
|
|
81
|
+
source venv/bin/activate # or `venv\Scripts\activate` on Windows
|
|
82
|
+
|
|
83
|
+
# Install dependencies
|
|
84
|
+
pip install -e .
|
|
85
|
+
|
|
86
|
+
# Set environment variables
|
|
87
|
+
cp .env.example .env
|
|
88
|
+
# Edit .env with your database credentials
|
|
89
|
+
|
|
90
|
+
# Run migrations
|
|
91
|
+
alembic upgrade head
|
|
92
|
+
|
|
93
|
+
# Start the server
|
|
94
|
+
uvicorn src.main:app --reload --port 8000
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### API Documentation
|
|
98
|
+
|
|
99
|
+
Once running, visit:
|
|
100
|
+
|
|
101
|
+
- Swagger UI: <http://localhost:8000/docs>
|
|
102
|
+
- ReDoc: <http://localhost:8000/redoc>
|
|
103
|
+
|
|
104
|
+
## 🏗️ Architecture
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
108
|
+
│ PRESENTATION LAYER │
|
|
109
|
+
│ (FastAPI Routes, Pydantic Schemas, Request/Response DTOs) │
|
|
110
|
+
└─────────────────────────────────────────────────────────────┘
|
|
111
|
+
│
|
|
112
|
+
▼
|
|
113
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
114
|
+
│ APPLICATION LAYER │
|
|
115
|
+
│ (Use Cases, Application Services, Business Logic) │
|
|
116
|
+
└─────────────────────────────────────────────────────────────┘
|
|
117
|
+
│
|
|
118
|
+
▼
|
|
119
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
120
|
+
│ DOMAIN LAYER │
|
|
121
|
+
│ (Entities, Value Objects, Domain Services, Aggregates) │
|
|
122
|
+
└─────────────────────────────────────────────────────────────┘
|
|
123
|
+
│
|
|
124
|
+
▼
|
|
125
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
126
|
+
│ INFRASTRUCTURE LAYER │
|
|
127
|
+
│ (Repositories, Database, External APIs, Messaging) │
|
|
128
|
+
└─────────────────────────────────────────────────────────────┘
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 📋 Domain Model
|
|
132
|
+
|
|
133
|
+
The ERP system manages:
|
|
134
|
+
|
|
135
|
+
- **Organizations** - Multi-tenant company management
|
|
136
|
+
- **Users** - Authentication and authorization
|
|
137
|
+
- **Inventory** - Product and stock management
|
|
138
|
+
- **Orders** - Sales order processing
|
|
139
|
+
- **Invoices** - Billing and payment tracking
|
|
140
|
+
|
|
141
|
+
## 🔒 RBAC Roles
|
|
142
|
+
|
|
143
|
+
| Role | Permissions |
|
|
144
|
+
|------|-------------|
|
|
145
|
+
| `admin` | Full system access |
|
|
146
|
+
| `manager` | Read/write on assigned resources |
|
|
147
|
+
| `operator` | Limited write access |
|
|
148
|
+
| `viewer` | Read-only access |
|
|
149
|
+
|
|
150
|
+
## 🧪 Testing
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Run all tests
|
|
154
|
+
pytest tests/
|
|
155
|
+
|
|
156
|
+
# Run with coverage
|
|
157
|
+
pytest tests/ --cov=src --cov-report=html
|
|
158
|
+
|
|
159
|
+
# Run specific test file
|
|
160
|
+
pytest tests/unit/test_entities.py -v
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## 📊 API Endpoints
|
|
164
|
+
|
|
165
|
+
| Method | Endpoint | Description |
|
|
166
|
+
|--------|----------|-------------|
|
|
167
|
+
| POST | `/api/v1/auth/login` | Authenticate user |
|
|
168
|
+
| GET | `/api/v1/users` | List users |
|
|
169
|
+
| POST | `/api/v1/orders` | Create order |
|
|
170
|
+
| GET | `/api/v1/inventory` | List inventory |
|
|
171
|
+
| GET | `/health` | Health check |
|
|
172
|
+
|
|
173
|
+
## 🔧 Configuration
|
|
174
|
+
|
|
175
|
+
Environment variables (`.env`):
|
|
176
|
+
|
|
177
|
+
```env
|
|
178
|
+
DATABASE_URL=postgresql://user:pass@localhost:5432/erp_db
|
|
179
|
+
SECRET_KEY=your-secret-key-here
|
|
180
|
+
DEBUG=true
|
|
181
|
+
ALLOWED_HOSTS=localhost,127.0.0.1
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 📄 License
|
|
185
|
+
|
|
186
|
+
MIT
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
backend_systems.egg-info/PKG-INFO
|
|
4
|
+
backend_systems.egg-info/SOURCES.txt
|
|
5
|
+
backend_systems.egg-info/dependency_links.txt
|
|
6
|
+
backend_systems.egg-info/requires.txt
|
|
7
|
+
backend_systems.egg-info/top_level.txt
|
|
8
|
+
src/__init__.py
|
|
9
|
+
src/config.py
|
|
10
|
+
src/main.py
|
|
11
|
+
src/application/__init__.py
|
|
12
|
+
src/application/services/__init__.py
|
|
13
|
+
src/application/services/auth_service.py
|
|
14
|
+
src/application/services/order_service.py
|
|
15
|
+
src/domain/__init__.py
|
|
16
|
+
src/domain/entities/__init__.py
|
|
17
|
+
src/domain/entities/inventory.py
|
|
18
|
+
src/domain/entities/order.py
|
|
19
|
+
src/domain/entities/organization.py
|
|
20
|
+
src/domain/entities/user.py
|
|
21
|
+
src/domain/value_objects/__init__.py
|
|
22
|
+
src/domain/value_objects/address.py
|
|
23
|
+
src/domain/value_objects/email.py
|
|
24
|
+
src/domain/value_objects/money.py
|
|
25
|
+
src/infrastructure/__init__.py
|
|
26
|
+
src/infrastructure/database/__init__.py
|
|
27
|
+
src/infrastructure/database/models.py
|
|
28
|
+
src/infrastructure/database/session.py
|
|
29
|
+
src/infrastructure/repositories/__init__.py
|
|
30
|
+
src/infrastructure/repositories/base.py
|
|
31
|
+
src/infrastructure/repositories/inventory_repository.py
|
|
32
|
+
src/infrastructure/repositories/order_repository.py
|
|
33
|
+
src/infrastructure/repositories/user_repository.py
|
|
34
|
+
src/presentation/__init__.py
|
|
35
|
+
src/presentation/routes/__init__.py
|
|
36
|
+
src/presentation/routes/auth.py
|
|
37
|
+
src/presentation/routes/health.py
|
|
38
|
+
src/presentation/routes/inventory.py
|
|
39
|
+
src/presentation/routes/orders.py
|
|
40
|
+
src/presentation/routes/users.py
|
|
41
|
+
src/presentation/schemas/__init__.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
fastapi>=0.109.0
|
|
2
|
+
uvicorn[standard]>=0.27.0
|
|
3
|
+
sqlalchemy>=2.0.25
|
|
4
|
+
alembic>=1.13.1
|
|
5
|
+
psycopg2-binary>=2.9.9
|
|
6
|
+
pydantic>=2.5.3
|
|
7
|
+
pydantic-settings>=2.1.0
|
|
8
|
+
python-jose[cryptography]>=3.3.0
|
|
9
|
+
passlib[bcrypt]>=1.7.4
|
|
10
|
+
python-multipart>=0.0.6
|
|
11
|
+
httpx>=0.26.0
|
|
12
|
+
|
|
13
|
+
[dev]
|
|
14
|
+
pytest>=7.4.4
|
|
15
|
+
pytest-cov>=4.1.0
|
|
16
|
+
pytest-asyncio>=0.23.3
|
|
17
|
+
httpx>=0.26.0
|
|
18
|
+
black>=24.1.0
|
|
19
|
+
ruff>=0.1.14
|
|
20
|
+
mypy>=1.8.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "backend-systems"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "ERP-style backend with DDD and Clean Architecture"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Engineering Team", email = "team@example.com"}
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
dependencies = [
|
|
24
|
+
"fastapi>=0.109.0",
|
|
25
|
+
"uvicorn[standard]>=0.27.0",
|
|
26
|
+
"sqlalchemy>=2.0.25",
|
|
27
|
+
"alembic>=1.13.1",
|
|
28
|
+
"psycopg2-binary>=2.9.9",
|
|
29
|
+
"pydantic>=2.5.3",
|
|
30
|
+
"pydantic-settings>=2.1.0",
|
|
31
|
+
"python-jose[cryptography]>=3.3.0",
|
|
32
|
+
"passlib[bcrypt]>=1.7.4",
|
|
33
|
+
"python-multipart>=0.0.6",
|
|
34
|
+
"httpx>=0.26.0",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
dev = [
|
|
39
|
+
"pytest>=7.4.4",
|
|
40
|
+
"pytest-cov>=4.1.0",
|
|
41
|
+
"pytest-asyncio>=0.23.3",
|
|
42
|
+
"httpx>=0.26.0",
|
|
43
|
+
"black>=24.1.0",
|
|
44
|
+
"ruff>=0.1.14",
|
|
45
|
+
"mypy>=1.8.0",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[tool.setuptools.packages.find]
|
|
49
|
+
where = ["."]
|
|
50
|
+
include = ["src*"]
|
|
51
|
+
|
|
52
|
+
[tool.pytest.ini_options]
|
|
53
|
+
testpaths = ["tests"]
|
|
54
|
+
python_files = ["test_*.py"]
|
|
55
|
+
asyncio_mode = "auto"
|
|
56
|
+
|
|
57
|
+
[tool.black]
|
|
58
|
+
line-length = 88
|
|
59
|
+
target-version = ["py311"]
|
|
60
|
+
|
|
61
|
+
[tool.ruff]
|
|
62
|
+
line-length = 88
|
|
63
|
+
select = ["E", "F", "I", "N", "W"]
|
|
64
|
+
ignore = ["E501"]
|
|
65
|
+
|
|
66
|
+
[tool.mypy]
|
|
67
|
+
python_version = "3.11"
|
|
68
|
+
warn_return_any = true
|
|
69
|
+
warn_unused_ignores = true
|
|
70
|
+
disallow_untyped_defs = true
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Backend Systems - ERP-Style Backend with DDD and Clean Architecture.
|
|
3
|
+
|
|
4
|
+
This package provides a production-grade backend implementation demonstrating
|
|
5
|
+
enterprise patterns including Domain-Driven Design, CQRS-ready architecture,
|
|
6
|
+
and comprehensive RBAC.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__version__ = "1.0.0"
|
|
10
|
+
__author__ = "Engineering Team"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Application layer - Use cases and services."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Application services - Business use case implementations."""
|