Skip to content

Feature/crud item store#3

Merged
maltonoloco merged 51 commits intoOpenTaberna:mainfrom
PhilippTheServer:feature/crud-item-store
Dec 7, 2025
Merged

Feature/crud item store#3
maltonoloco merged 51 commits intoOpenTaberna:mainfrom
PhilippTheServer:feature/crud-item-store

Conversation

@PhilippTheServer
Copy link
Contributor

Core Change

Description

Introducing core utils as standalone moduls. Logging, Exceptions, Responses, config.

Scope

  • Authentication/Authorization
  • Database layer
  • Configuration management
  • Error handling
  • Logging infrastructure
  • Dependency management
  • Other:

Motivation

New core functionallity, unifyed login, exception, responses and config. Set as standalone moduls as available shared inports. Consult the repos docs/ files for details.

Testing Strategy

  • Unit tests updated/added
  • Integration tests updated/added
  • All existing tests pass

Documentation

  • Architecture documentation updated
  • API documentation updated
  • Migration guide created if needed

Checklist

  • Backward compatibility considered
  • All services tested
  • Security implications reviewed
  • Performance impact assessed

- Add LogLevel and Environment enums
- Define ILogFormatter, ILogFilter, ILogHandler protocols
- Export public API in __init__.py
- JSONFormatter for structured logging
- ConsoleFormatter with color support
- Both implement ILogFormatter interface
- SensitiveDataFilter for password/token redaction
- LevelFilter for log level filtering
- Both implement ILogFilter interface
- ConsoleHandler for stdout/stderr logging
- FileHandler for file logging
- DailyRotatingFileHandler with log rotation
- All implement ILogHandler interface
- LoggerConfig with environment presets
- Presets for development, testing, staging, production
- Configurable formatters, handlers, and filters
- LogContext for request-scoped metadata
- Context manager for automatic cleanup
- Thread-safe using contextvars
- Main logger orchestration class
- Integrates formatters, handlers, and filters
- Filters reserved LogRecord attributes
- Performance measurement with measure_time()
- get_logger() function with caching
- clear_loggers() for cache management
- Singleton pattern per logger name
- Add conftest.py to configure Python path
- Enable clean imports in tests
- 12 tests covering all logger functionality
- Test basic logging, context, filtering, performance
- Test environment configs and multiple loggers
- Practical examples for logger usage
- Demonstrate all major features
- Comprehensive logger documentation with examples
- Generic testing guide for pytest setup
- Best practices and troubleshooting
- Architecture documentation with design principles
- Development guide with workflows and patterns
- Code quality guidelines and best practices
- Remove old test_api.py
- Remove generic services subdirectories
- Preparing for new modular service architecture
- Add service structure with routers, models, functions
- Follows new modular architecture pattern
- Update main.py for new service structure
- Update Keycloak authorization module
- Integrate logger system
- Database, Redis, Keycloak settings
- CORS, logging, cache configuration
- Rate limiting and feature flags
- Auto-loads from .env, Docker secrets, K8s secrets
- Validates SECRET_KEY in production
- Remove duplicate Environment enum from logger
- Import Environment from app.shared.config.enums
- Single source of truth for environment detection
- Add BaseResponse base class for all API responses
- Include success, message, timestamp, request_id, metadata fields
- Use Pydantic v2 ConfigDict
- Auto-generate UTC timestamps with datetime.now(UTC)
- Optional success field for flexibility
- Add SuccessResponse[T] with optional typed data
- Add DataResponse[T] with required typed data
- Add MessageResponse for simple message-only responses
- Use TypeVar for type-safe generic responses
- Pydantic v2 ConfigDict with examples
- Add ErrorResponse with HTTP status code mapping
- Add ValidationErrorResponse for field-level validation errors
- Implement from_exception() for AppException integration
- Map error categories to HTTP status codes (404, 422, 401, etc.)
- Optional debug logging in development mode
- Status code validation (400-599)
…gation

- Add PageInfo with page, size, total, pages fields
- Add PaginatedResponse[T] for page-based pagination
- Add CursorInfo for cursor-based pagination metadata
- Add CursorPaginatedResponse[T] for infinite scrolling
- Validation for page numbers and sizes
- Generic type support with TypeVar
- Optimized for webshop product listings
…tion

- Add success(), data_response(), message_response() helpers
- Add error(), error_from_exception(), validation_error() helpers
- Add paginated() and cursor_paginated() helpers
- Auto-calculate total pages in paginated()
- Convenience aliases: ok, created, accepted, not_found, etc.
- Optional config/logger integration for debug logging
- Environment-aware logging (dev/debug mode only)
- Export all response models and factory functions
- Export convenience aliases
- Clean public interface
- Comprehensive __all__ list
Tests cover:
- Success/error/paginated responses
- Exception integration and status mapping
- Type safety with generics
- Factory functions and pagination logic
Includes architecture, usage examples, FastAPI integration,
best practices, and troubleshooting guide
@maltonoloco maltonoloco merged commit cd34fce into OpenTaberna:main Dec 7, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants