Adds has_active_invitees flag to the events GET response. The Users icon now appears on the owner's calendar view when an event has accepted or tentative invitees, giving visual feedback that the event is actively shared. Single batch query with set lookup — no N+1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
UMBRA Backend
A complete FastAPI backend for the UMBRA application with async SQLAlchemy, PostgreSQL, authentication, and comprehensive CRUD operations.
Features
- FastAPI with async/await support
- SQLAlchemy 2.0 with async engine
- PostgreSQL with asyncpg driver
- Alembic for database migrations
- bcrypt for password hashing
- itsdangerous for session management
- PIN-based authentication with secure session cookies
- Full CRUD operations for all entities
- Dashboard with aggregated data
- CORS enabled for frontend integration
Project Structure
backend/
├── alembic/ # Database migrations
│ ├── versions/ # Migration files
│ ├── env.py # Alembic environment
│ └── script.py.mako # Migration template
├── app/
│ ├── models/ # SQLAlchemy models
│ ├── schemas/ # Pydantic schemas
│ ├── routers/ # API route handlers
│ ├── config.py # Configuration
│ ├── database.py # Database setup
│ └── main.py # FastAPI application
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── alembic.ini # Alembic configuration
└── start.sh # Startup script
Setup
1. Install Dependencies
cd backend
pip install -r requirements.txt
2. Configure Environment
Create a .env file:
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/umbra
SECRET_KEY=your-secret-key-change-in-production
3. Create Database
createdb umbra
4. Run Migrations
alembic upgrade head
5. Start Server
# Using the start script
chmod +x start.sh
./start.sh
# Or directly with uvicorn
uvicorn app.main:app --reload
The API will be available at http://localhost:8000
API Documentation
Interactive API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Authentication
POST /api/auth/setup- Initial PIN setupPOST /api/auth/login- Login with PINPOST /api/auth/logout- LogoutGET /api/auth/status- Check auth status
Todos
GET /api/todos- List todos (with filters)POST /api/todos- Create todoGET /api/todos/{id}- Get todoPUT /api/todos/{id}- Update todoDELETE /api/todos/{id}- Delete todoPATCH /api/todos/{id}/toggle- Toggle completion
Calendar Events
GET /api/events- List events (with date range)POST /api/events- Create eventGET /api/events/{id}- Get eventPUT /api/events/{id}- Update eventDELETE /api/events/{id}- Delete event
Reminders
GET /api/reminders- List reminders (with filters)POST /api/reminders- Create reminderGET /api/reminders/{id}- Get reminderPUT /api/reminders/{id}- Update reminderDELETE /api/reminders/{id}- Delete reminderPATCH /api/reminders/{id}/dismiss- Dismiss reminder
Projects
GET /api/projects- List projectsPOST /api/projects- Create projectGET /api/projects/{id}- Get projectPUT /api/projects/{id}- Update projectDELETE /api/projects/{id}- Delete projectGET /api/projects/{id}/tasks- List project tasksPOST /api/projects/{id}/tasks- Create project taskPUT /api/projects/{id}/tasks/{task_id}- Update taskDELETE /api/projects/{id}/tasks/{task_id}- Delete task
People
GET /api/people- List people (with search)POST /api/people- Create personGET /api/people/{id}- Get personPUT /api/people/{id}- Update personDELETE /api/people/{id}- Delete person
Locations
GET /api/locations- List locations (with category filter)POST /api/locations- Create locationGET /api/locations/{id}- Get locationPUT /api/locations/{id}- Update locationDELETE /api/locations/{id}- Delete location
Settings
GET /api/settings- Get settingsPUT /api/settings- Update settingsPUT /api/settings/pin- Change PIN
Dashboard
GET /api/dashboard- Get dashboard dataGET /api/upcoming?days=7- Get upcoming items
Database Schema
The application uses the following tables:
settings- Application settings and PINtodos- Task itemscalendar_events- Calendar eventsreminders- Remindersprojects- Projectsproject_tasks- Tasks within projectspeople- Contacts/peoplelocations- Physical locations
Docker
Build and run with Docker:
docker build -t umbra-backend .
docker run -p 8000:8000 -e DATABASE_URL=... -e SECRET_KEY=... umbra-backend
Development
Create New Migration
alembic revision --autogenerate -m "Description of changes"
Apply Migrations
alembic upgrade head
Rollback Migration
alembic downgrade -1
Security Notes
- Change
SECRET_KEYin production - Use strong PINs (minimum 4 digits recommended)
- Session cookies are httpOnly and last 30 days
- All API endpoints (except auth) require authentication
- PINs are hashed with bcrypt before storage