Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .claude/skills/backend-patterns/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,29 @@ async def fetch_user(user_id: int):
response.raise_for_status()
return response.json()
```

### Timezone Handling
**Principle**: Store in UTC, query in UTC, convert to local time at presentation time.

```python
# Storage (models)
from datetime import UTC, datetime
from src.mixins import TimestampMixin

class Order(SQLModel, TimestampMixin, table=True):
# created_at, updated_at stored in UTC
pass

# Presentation (serializers)
from datetime import timedelta, timezone
from src.config import get_settings

class OrderResponse(BaseModel):
created_at: datetime

@field_serializer('created_at')
def serialize_dt(self, dt: datetime, _info):
tz_offset = get_settings().app.timezone
local_tz = timezone(timedelta(hours=tz_offset))
return dt.astimezone(local_tz)
```
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This repo also provides a full-featured, best-practiced backend template for bui
- **Standardized Responses**: Middleware for consistent, unified JSON response formatting across all endpoints.
- **Custom Error Codes**: Flexible handling of business-specific error codes and messages.
- **Pagination**: Built-in support for paginating query results using `fastapi-pagination`.
- **Timezone Handling**: UTC storage with presentation-layer conversion - store in UTC, query in UTC, convert to local time at presentation time.

### DDD guidelines

Expand Down
2 changes: 0 additions & 2 deletions migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from alembic import context
from src.config import get_settings

from src.audit.schemas import AuditLog # noqa: F401

config = context.config

# Get settings before setting URL
Expand Down

This file was deleted.

This file was deleted.

Loading