01_backend_systems - ERP-Style Backend
Production-grade ERP backend demonstrating Domain-Driven Design, Clean Architecture, and enterprise patterns.
🎯 Overview
This module implements a comprehensive ERP-style backend with:
- Domain-Driven Design (DDD) - Entities, Value Objects, Aggregates
- Clean Architecture - Layered separation of concerns
- RBAC - Role-based access control
- RESTful APIs - OpenAPI 3.0 documented
- PostgreSQL - With Alembic migrations
📁 Structure
01_backend_systems/
├── src/
│ ├── domain/ # Business logic & entities
│ │ ├── entities/ # Core domain models
│ │ └── value_objects/# Immutable value types
│ ├── application/ # Use cases & services
│ │ └── services/ # Application services
│ ├── infrastructure/ # External concerns
│ │ ├── database/ # DB connection & session
│ │ └── repositories/ # Data access layer
│ └── presentation/ # API layer
│ ├── routes/ # API endpoints
│ └── schemas/ # Pydantic models
├── alembic/ # Database migrations
├── tests/ # Unit & integration tests
└── example_data/ # Sample data for testing
🚀 Quick Start
Prerequisites
- Python 3.11+
- PostgreSQL 14+ (or use SQLite for development)
Installation
# Create virtual environment
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install dependencies
pip install -e .
# Set environment variables
cp .env.example .env
# Edit .env with your database credentials
# Run migrations
alembic upgrade head
# Start the server
uvicorn src.main:app --reload --port 8000
API Documentation
Once running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
🏗️ Architecture
┌─────────────────────────────────────────────────────────────┐
│ PRESENTATION LAYER │
│ (FastAPI Routes, Pydantic Schemas, Request/Response DTOs) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ APPLICATION LAYER │
│ (Use Cases, Application Services, Business Logic) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ DOMAIN LAYER │
│ (Entities, Value Objects, Domain Services, Aggregates) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ INFRASTRUCTURE LAYER │
│ (Repositories, Database, External APIs, Messaging) │
└─────────────────────────────────────────────────────────────┘
📋 Domain Model
The ERP system manages:
- Organizations - Multi-tenant company management
- Users - Authentication and authorization
- Inventory - Product and stock management
- Orders - Sales order processing
- Invoices - Billing and payment tracking
🔒 RBAC Roles
| Role | Permissions |
|---|---|
admin |
Full system access |
manager |
Read/write on assigned resources |
operator |
Limited write access |
viewer |
Read-only access |
🧪 Testing
# Run all tests
pytest tests/
# Run with coverage
pytest tests/ --cov=src --cov-report=html
# Run specific test file
pytest tests/unit/test_entities.py -v
📊 API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/login |
Authenticate user |
| GET | /api/v1/users |
List users |
| POST | /api/v1/orders |
Create order |
| GET | /api/v1/inventory |
List inventory |
| GET | /health |
Health check |
🔧 Configuration
Environment variables (.env):
DATABASE_URL=postgresql://user:pass@localhost:5432/erp_db
SECRET_KEY=your-secret-key-here
DEBUG=true
ALLOWED_HOSTS=localhost,127.0.0.1
📄 License
MIT
Metadata
Release files for backend-systems 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| backend_systems-1.0.0.tar.gz | 30.6 kB | Without provenance | Details for backend_systems-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| backend_systems-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for backend_systems-1.0.0-py3-none-any.whl |
Total release size: 73.4 kB
Release files / backend_systems-1.0.0.tar.gz
| Download URL | backend_systems-1.0.0.tar.gz |
|---|---|
| Size | 30.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4878cab558416c82dbe55e87871a00b697d89f91874744e2c757abd80e795558
|
|
BLAKE2b-256 checksum How to use checksums |
4fa0f67f09b223210b8a41d6da73b5ff2f8ff6032c12ed91e0d6e757094619b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / backend_systems-1.0.0-py3-none-any.whl
| Download URL | backend_systems-1.0.0-py3-none-any.whl |
|---|---|
| Size | 42.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
05704aef1392e72872563883dbde0e395f25b237c7cec4c213bdaf4e98b8fa8a
|
|
BLAKE2b-256 checksum How to use checksums |
e13dec55293533b6736e11cc2e9a6a9f24f857480ff036830e8c30c34d3091de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for backend-systems 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.