added postgres support

This commit is contained in:
Brian Bjarke Jensen
2025-11-11 15:16:24 +01:00
parent 7c602c8da7
commit 65655db034
10 changed files with 83 additions and 40 deletions
+21 -12
View File
@@ -81,13 +81,14 @@ uv run uvicorn src.baby_monitor.main:app --reload --host 0.0.0.0 --port 8000
### Environment Variables
| Variable | Default | Description |
| ---------------- | ------------ | ------------------------------------------- |
| `ENVIRONMENT` | `production` | Set to `development` to enable API docs |
| `ADMIN_PASSWORD` | _(required)_ | Admin user password |
| `ADMIN_USERNAME` | `admin` | Admin username |
| `DATA_DIR` | `/data` | Directory for SQLite database |
| `REDIS_URI` | _(optional)_ | Redis connection URI for distributed tokens |
| Variable | Default | Description |
| ---------------- | ------------ | --------------------------------------------- |
| `ENVIRONMENT` | `production` | Set to `development` to enable API docs |
| `ADMIN_PASSWORD` | _(required)_ | Admin user password |
| `ADMIN_USERNAME` | `admin` | Admin username |
| `DATA_DIR` | `/data` | Directory for SQLite database (SQLite only) |
| `REDIS_URI` | _(optional)_ | Redis connection URI for distributed tokens |
| `POSTGRES_URI` | _(optional)_ | PostgreSQL connection URI for database storage|
### Storage Options
@@ -96,18 +97,26 @@ uv run uvicorn src.baby_monitor.main:app --reload --host 0.0.0.0 --port 8000
- Automatic setup, no configuration needed
- Data stored in `/data/baby_monitor.db`
- Perfect for single-server deployments
- Timezone-aware datetimes stored as naive UTC
**Redis (Optional)**
**Redis (Optional - Token Storage)**
```bash
# Enable Redis token storage
# Enable Redis token storage for distributed deployments
export REDIS_URI=redis://localhost:6379
```
**PostgreSQL (Future)**
**PostgreSQL (Optional - Database)**
- Repository interface ready
- Swap implementation in `dependencies.py`
```bash
# Enable PostgreSQL for production database
export POSTGRES_URI=postgresql://user:password@localhost:5432/baby_monitor
```
- Supports timezone-aware datetimes natively
- Recommended for production deployments
- Better performance for concurrent access
- Supports database migrations and backups
## 📁 Project Structure