A comprehensive data access layer for Vortex apps
Project description
LDC Vortex Data Layer
A comprehensive data access layer for Vortex Django applications, providing database operations, Redis caching, entity mappers, and business flow operations.
Features
| Module | Description |
|---|---|
| Base Layer | Database connection management, query execution, transaction handling |
| Entity Mappers | Data mappers for loans, investments, wallets, accounts, lenders, etc. |
| Flow Operations | Business logic flows (redemption, repayment, portfolio, dashboard) |
| Redis Integration | Unified caching layer with type-safe get/set operations |
| Cache Manager | High-level caching patterns with fallback to database |
| Constants | Centralized constants for transaction types, statuses, filters |
| Helpers | Date utilities, generic utilities, master account caching |
Installation
pip install LDC_Vortex-Datalayer
Requirements
- Python 3.10+
- Django 5.2+
- PostgreSQL (with psycopg 3.x)
- Redis 5.0+
Quick Start
Django Settings Configuration
# Database Configuration
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'vortex_db',
'USER': 'your_user',
'PASSWORD': 'your_password',
'HOST': 'localhost',
'PORT': '5432',
}
}
# Redis Configuration
IOS_REDIS_CACHE = "redis://localhost:6379/0"
Using Base Data Layer
from repository.base_layer import BaseDataLayer
class UserRepository(BaseDataLayer):
def __init__(self):
super().__init__(db_alias="default")
def get_user_by_id(self, user_id: int) -> dict:
sql = "SELECT * FROM users WHERE id = %s"
return self.execute_fetch_one(sql, params=[user_id])
def get_active_users(self) -> list:
sql = "SELECT * FROM users WHERE status = 'ACTIVE'"
return self.execute_fetch_all(sql)
Using Redis Utilities
from repository import redis_utils
# Get with automatic type conversion
user = redis_utils.get("user:123", dict) # Returns dict or None
count = redis_utils.get("counter", int) # Returns int or None
name = redis_utils.get("name", str) # Returns str or None
data = redis_utils.get("key") # Returns raw bytes (backward compatible)
# Set with automatic serialization
redis_utils.set("user:123", {"name": "John", "age": 30}, ttl=3600)
redis_utils.set("counter", 42, ttl=1800)
# Other operations
redis_utils.delete("user:123")
redis_utils.exists("user:123")
redis_utils.keys("user:*")
Using Cache Manager
from repository.cache_manager import CacheManager
# Get or set pattern with database fallback
result = CacheManager.get_or_set(
cache_identifier="user_123",
db_callback=lambda: fetch_user_from_db(123),
cache_key_prefix="USER_DATA",
ttl=1800,
return_type=dict
)
# Invalidate cache
CacheManager.invalidate("user_123", cache_key_prefix="USER_DATA")
Using Constants
from repository.constants import TransactionStatus, LoanStatus, WalletTransactionType
if transaction.status == TransactionStatus.SUCCESS:
print("Transaction completed")
if loan.status == LoanStatus.FUNDED:
process_funded_loan(loan)
Using Entity Mappers
from repository.entity.loan import Loan
from repository.entity.wallet_transaction import WalletTransaction
# Loan operations
loan_repo = Loan()
loan_details = loan_repo.get_loan_by_id(loan_id)
# Wallet transactions
wallet_repo = WalletTransaction()
transactions = wallet_repo.get_transaction_list(lender_id, filters)
Package Structure
repository/
├── base_layer.py # Base database operations
├── redis_utils.py # Redis connection and operations
├── cache_manager.py # High-level caching patterns
├── constants.py # Centralized constants
├── entity/ # Data mappers
│ ├── loan.py
│ ├── wallet_transaction.py
│ ├── lender.py
│ └── ...
├── flow/ # Business logic flows
│ ├── redemption_processing.py
│ ├── repayment_consumption.py
│ ├── cp_dashboard_summary.py
│ └── ...
├── helper/ # Utility helpers
│ ├── date_utils.py
│ ├── generic_utils.py
│ └── master_account_helper.py
├── ddl/ # Database DDL scripts
├── job_mappers/ # Job-specific mappers
└── stored_procedures/ # PostgreSQL stored procedures
Deploying to PyPI
Build and Upload
# Install build tools
pip install build twine
# Clean and build
rm -rf build/ dist/ *.egg-info/
python -m build
# Upload to PyPI
twine upload dist/*
Version Management
Update version in setup.py:
version = "0.0.2"
License
Proprietary - LenDenClub Internal Use Only
Author
Sonu Sharma - sonu.sharma@lendenclub.com
Support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ldc_vortex_datalayer-0.0.1.tar.gz.
File metadata
- Download URL: ldc_vortex_datalayer-0.0.1.tar.gz
- Upload date:
- Size: 114.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a52ae4e25f1576bd184b4917c6abf2bf24b74d5362c74400fb1056d7657b753
|
|
| MD5 |
949ae6123c969f0cb9fc93aef32d64d5
|
|
| BLAKE2b-256 |
f1b96d24b3b45ea964bd246833d2e309f2d0c16b180fbe2b550581dbc7a9175b
|
File details
Details for the file ldc_vortex_datalayer-0.0.1-py3-none-any.whl.
File metadata
- Download URL: ldc_vortex_datalayer-0.0.1-py3-none-any.whl
- Upload date:
- Size: 158.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
926ccb6243789b903da305e0ff3d2c9f8f80f0c930f1284cf4bc6b0044f1440f
|
|
| MD5 |
dd03318be7db78c18f6bb7b144cee486
|
|
| BLAKE2b-256 |
74e8eda56e766b46e3c8f502be70d7ba368962691174eff95e59314741eddab4
|