Common utilities and configurations for MySingle Platform microservices
Project description
MySingle
Common utilities and configurations for MySingle Platform microservices.
๐ฆ Installation
Basic Installation
pip install mysingle
Installs only core dependencies (pydantic, pydantic-settings).
Feature-specific Installation
# Authentication features
pip install mysingle[auth]
# Web framework features
pip install mysingle[web]
# Database features
pip install mysingle[database]
# Email features
pip install mysingle[email]
# Monitoring features
pip install mysingle[monitoring]
# All features
pip install mysingle[full]
# Development tools
pip install mysingle[dev]
Combined Installation
# Web + Auth + Database
pip install mysingle[web,auth,database]
# Full features + development tools
pip install mysingle[full,dev]
๐ Quick Start
Basic Usage
from mysingle.core import create_fastapi_app
from mysingle.core.config import settings
# Create FastAPI app with common configurations
app = create_fastapi_app()
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
๐งญ Imports: ๊ถ์ฅ ๊ฒฝ๋ก
๋ฃจํธ ์ฌ๋ ธ์ถ์ ์ ์ง๋์ง๋ง, ์๋ธํจํค์ง ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํ๋ฉด ์ํ์ฐธ์กฐ๋ฅผ ํผํ๊ณ ์ด๊ธฐํ ๋น์ฉ์ ์ค์ผ ์ ์์ต๋๋ค.
-
Core (๋ฃจํธ์์๋ ๋ ธ์ถ ์ ์ง)
- ๊ถ์ฅ:
from mysingle.core import create_fastapi_app, CommonSettings, settings, get_settings, init_mongo, get_mongodb_url, get_database_name - ๋ฃจํธ๋ ๊ฐ๋ฅ:
from mysingle import create_fastapi_app, CommonSettings, settings, get_settings, init_mongo, get_mongodb_url, get_database_name
- ๊ถ์ฅ:
-
Logging
- ๊ถ์ฅ:
from mysingle.logging import get_logger, setup_logging, configure_structured_logging - ๋ฃจํธ๋ ๊ฐ๋ฅ:
from mysingle import get_logger
- ๊ถ์ฅ:
-
Database
- ๊ถ์ฅ:
from mysingle.database import BaseDuckDBManager - ๋ฃจํธ๋ ๊ฐ๋ฅ:
from mysingle import BaseDuckDBManager
- ๊ถ์ฅ:
-
Clients
- ๊ถ์ฅ:
from mysingle.clients import BaseServiceClient - ๋ฃจํธ๋ ๊ฐ๋ฅ:
from mysingle import BaseServiceClient
- ๊ถ์ฅ:
๋ฃจํธ ํจํค์ง(mysingle)๋ ์ง์ฐ ๋ก๋ฉ(lazy export)์ผ๋ก ๊ตฌ์ฑ๋์ด ์์ด, ์ฌ๋ณผ ์ ๊ทผ ์์ ์๋ง ์๋ธํจํค์ง๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
With Authentication
from mysingle.core import create_fastapi_app
from mysingle.auth import get_user_manager
from mysingle.auth.router import auth_router
app = create_fastapi_app()
app.include_router(auth_router, prefix="/auth")
With Database
from mysingle.core import create_fastapi_app
from mysingle.core.db import init_db
app = create_fastapi_app()
@app.on_event("startup")
async def startup():
await init_db()
๐ Features
- ๐ Authentication: JWT-based auth with OAuth support
- ๐ Web Framework: FastAPI with common configurations
- ๐๏ธ Database: MongoDB with Beanie ODM
- ๐ง Email: Template-based email system
- ๐ Monitoring: Prometheus metrics and structured logging
- โ๏ธ Configuration: Pydantic-based settings management
๐ Available Dependencies by Feature
Core (always installed)
pydantic>=2.5.0pydantic-settings>=2.1.0
Auth
httpx-oauth>=0.16.1pyjwt>=2.10.1pwdlib>=0.2.1
Web
fastapi>=0.104.1uvicorn[standard]>=0.24.0python-multipart>=0.0.6
Database
motor>=3.3.2beanie>=1.23.6redis>=6.4.0
emails>=0.6jinja2>=3.1.6
Monitoring
prometheus-client>=0.19.0structlog>=23.2.0
๐ ๏ธ Development
# Clone repository
git clone <repo-url>
cd quant-pack
# Install with development dependencies
pip install -e .[full,dev]
# Run tests
pytest
# Format code
black src/
ruff check src/ --fix
# Type checking
mypy src/mysingle/
๐ Release & Versioning
CI๋ ๊ธฐ๋ณธ์ ์ผ๋ก Conventional Commits๋ฅผ ํ์ฑํด ์๋์ผ๋ก ๋ค์ ๋ฒ์ ์ ๊ฒฐ์ (major/minor/patch)ํฉ๋๋ค. ํ์ง๋ง ๋ฆด๋ฆฌ์ค ์ ์ ์๋์ผ๋ก ๋ฒ์ ์ ์ง์ ํ๊ณ ์ถ๋ค๋ฉด, ์ ๊ณต๋ ๋ํํ ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํ์ธ์. ์ด ์คํฌ๋ฆฝํธ๋ก ์ง์ ๋ฒ์ ์ ์ฌ๋ฆฌ๋ฉด CI์ ์๋ ๋ฒ์ ๊ฒฐ์ ์ ์คํต๋ฉ๋๋ค(์๋ ๋ณ๊ฒฝ ์ฐ์ ).
๋ํํ ๋ฒ์ ์ ์คํฌ๋ฆฝํธ ์ฌ์ฉ๋ฒ
python scripts/bump_version.py
- ํ์ฌ ๋ฒ์ ์ ์ฝ์ด์ bump ์ข ๋ฅ(major/minor/patch/custom)๋ฅผ ์ ํํ ์ ์์ต๋๋ค.
- ์ต์ ์ผ๋ก main ๋ธ๋์น ์ ํ/์ต์ ๋ฐ์, ์ปค๋ฐ/ํ๊ทธ ์์ฑ, ์๊ฒฉ ํธ์๊น์ง ์ง์ํฉ๋๋ค.
- ์ปค๋ฐ ๋ฉ์์ง๋
chore(release): vX.Y.Z (bump <type>)ํํ๋ก ์์ฑ๋ฉ๋๋ค. - pyproject.toml์
project.version์ด ๋ณ๊ฒฝ๋๋ฏ๋ก, ๊ฐ์ ์ปค๋ฐ์์ ๋ค์ ์๋ ๋ฒ์ ์ฌ๋ฆฌ๊ธฐ๋ฅผ ํ์ง ์์ต๋๋ค.
๊ถ์ฅ ํ๋ก์ฐ(์๋ ๋ฆด๋ฆฌ์ค):
- ํ
์คํธ/๊ฒํ ์๋ฃ โ 2)
python scripts/bump_version.py์คํ โ 3) ์ปค๋ฐ/ํ๊ทธ/ํธ์ โ 4) CI๊ฐ ๋น๋/ํผ๋ธ๋ฆฌ์ ์ํ(์๋ ๋ฒ์ ์ ์ง)
๏ฟฝ๏ธ Roadmap
Phase 1: Enhanced Developer Experience (Current)
- DI Functions Compatibility: Add
Depends()wrapper functions for backward compatibility - ServiceConfig Extensions: Add ServiceCategory enum and internal routes flag
- Configuration Documentation: Create inheritance pattern templates for services
Phase 2: Advanced Architecture (Q4 2024)
- Service Templates: Generate service-specific configuration templates
- Service Type Expansion: Add ORCHESTRATOR, EXECUTION, DATA, ANALYTICS, UTILITY types
- Enhanced Routing: Support for internal vs external API separation
Phase 3: Developer Tools (Q1 2025)
- CLI Tools: Service generator and validator commands
- Testing Utilities: Enhanced auth helpers and service testing framework
- Auto Documentation: Generate service documentation from configuration
Completed Features โ
- App Factory Standardization: Unified FastAPI app creation with automatic middleware setup
- HTTP Client Pooling: Standardized service-to-service communication with connection pooling
- Structured Logging: JSON logging with correlation ID support and context management
- Kong Gateway Integration: Complete header standardization and authentication flow
- Metrics Collection: Prometheus-compatible metrics with performance monitoring
- Audit Logging: Comprehensive request/response logging system
Migration Status
- All services using App Factory pattern
- HTTP client standardization implemented
- Kong Gateway headers standardized
- Structured logging system deployed
- CommonSettings inheritance pattern adoption
- Request-based DI pattern migration
- Test code updates
- Environment configuration migration
๏ฟฝ๐ License
This project is licensed under the MIT License.
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 Distributions
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 mysingle-1.2.4-py3-none-any.whl.
File metadata
- Download URL: mysingle-1.2.4-py3-none-any.whl
- Upload date:
- Size: 133.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8538b2578d3a33ca1ce420769dd79bba2fa32c1201cecbead8160b4f037a364
|
|
| MD5 |
67fa9b60f4d823b4dcb7da0e82aa11d9
|
|
| BLAKE2b-256 |
f74cdd3740d7ad26d2bd2ab96ef8f7e22d70abfb00543ff5b23a222f3c475100
|