Commit Graph

99 Commits

Author SHA1 Message Date
Trey t
0a708c092d Add Apple Sign In welcome email, notification preferences on registration, and contractor sharing tests
- Send welcome email to new users who sign up via Apple Sign In
- Create notification preferences (all enabled) when new accounts are created
- Add comprehensive integration tests for contractor sharing:
  - Personal contractors only visible to creator
  - Residence-tied contractors visible to all users with residence access
  - Update/delete access control for shared contractors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 17:42:37 -06:00
Trey t
be507561f1 wip 2025-11-29 23:36:48 -06:00
Trey t
4e9b31377b Make contractor residence optional with visibility rules
- Make residence_id nullable in contractor model
- Add created_by_id field to track contractor creator
- Update access control: personal contractors visible only to creator,
  residence contractors visible to all residence users
- Add database migration for schema changes
- Update admin panel DTOs and handlers for optional residence
- Fix test utilities for new model structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 18:42:11 -06:00
Trey t
9e91e274e8 Add worker environment variables to Dokku setup guide
- Add TASK_REMINDER_HOUR, TASK_REMINDER_MINUTE, OVERDUE_REMINDER_HOUR, DAILY_DIGEST_HOUR config
- Document schedule times in UTC with explanation table
- Add worker verification steps to check logs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 14:01:41 -06:00
Trey t
a15e847098 Replace Gorush with direct APNs/FCM integration
- Add direct APNs client using sideshow/apns2 for iOS push
- Add direct FCM client using legacy HTTP API for Android push
- Remove Gorush dependency (no external push server needed)
- Update all services/handlers to use new push.Client
- Update config for APNS_PRODUCTION flag

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 12:04:31 -06:00
Trey t
c4118c8186 Add /devices/register/ route alias for mobile clients
The KMM mobile app calls /api/notifications/devices/register/ but
the Go API had /api/notifications/devices/. Added alias to support both.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 11:43:32 -06:00
Trey t
80c9fca6e9 Show full device token in admin panel
- API now returns full registration_id instead of truncated version
- Added Device Token column to devices table in admin panel
- Device tokens are displayed with word-wrap for long tokens
- Added Devices link to sidebar navigation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 11:32:05 -06:00
Trey t
8022e03246 Fix port conflict: separate Next.js (3001) from Go API (PORT)
- Next.js admin now runs on internal port 3001
- Go API uses Dokku's PORT environment variable (5000)
- Updated admin proxy default to localhost:3001
- Added /_next/* static asset proxy route

This fixes the "address already in use" error when deploying to Dokku
where both services were trying to bind to port 3000.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 11:12:26 -06:00
Trey t
d166df00e9 Fix Dokku guide: move Gorush to required flow, remove duplicate section
- Moved Gorush configuration from optional section to main setup flow (step 7)
- Removed duplicate/broken Push Notifications (Optional) section
- Fixed section numbering in environment variables

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 10:55:53 -06:00
Trey t
ef73902273 Expand Gorush setup instructions in Dokku guide
Add step-by-step instructions for:
- Creating certificate storage directory
- Copying APNs key to server
- Mounting certificates to container
- Setting GORUSH_IOS_KEY_PATH environment variable
- Configuring proxy ports
- Verification steps

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 10:50:40 -06:00
Trey t
29de02a8c6 Add Dokku deployment guide
Comprehensive step-by-step instructions for deploying to a remote server:
- Server setup and prerequisites
- Dokku installation and plugins
- PostgreSQL and Redis configuration
- Environment variables reference
- SSL setup with Let's Encrypt
- Worker process scaling
- Push notifications setup
- Maintenance commands and troubleshooting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 10:39:08 -06:00
Trey t
b91ba8a8ca add in apple auth key 2025-11-29 10:34:27 -06:00
Trey t
15e361f983 Add admin panel pages for additional models
- Add confirmation codes management page
- Add devices management page
- Add feature benefits management page
- Add password reset codes management page
- Add promotions management page
- Add share codes management page
- Add corresponding backend handlers and routes
- Update sidebar navigation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 01:18:25 -06:00
Trey t
409d9716bd Add Sign in with Apple authentication
- Add AppleSocialAuth model to store Apple ID linkages
- Create AppleAuthService for JWT verification with Apple's public keys
- Add AppleSignIn handler and route (POST /auth/apple-sign-in/)
- Implement account linking (links Apple ID to existing accounts by email)
- Add Redis caching for Apple public keys (24-hour TTL)
- Support private relay emails (@privaterelay.appleid.com)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 01:17:10 -06:00
Trey t
c7dc56e2d2 Rebrand from MyCrib to Casera
- Update Go module from mycrib-api to casera-api
- Update all import statements across 69 Go files
- Update admin panel branding (title, sidebar, login form)
- Update email templates (subjects, bodies, signatures)
- Update PDF report generation branding
- Update Docker container names and network
- Update config defaults (database name, email sender, APNS topic)
- Update README and documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:10:48 -06:00
Trey t
99465a590d Fix admin panel edit forms and expand API responses
- Fix dropdown population on all edit pages (residence, task, contractor, document)
- Add formInitialized state pattern to prevent empty dropdowns
- Increase pagination max limit from 100 to 10000 for admin queries
- Expand handler responses to include all editable fields
- Add settings page with seed data and limitations toggle
- Fix user form and API client types

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:00:42 -06:00
Trey t
5e95dcd015 Add multi-image support for task completions and documents
- Add TaskCompletionImage and DocumentImage models with one-to-many relationships
- Update admin panel to display images for completions and documents
- Add image arrays to API request/response DTOs
- Update repositories with Preload("Images") for eager loading
- Fix seed SQL execution to use raw SQL instead of prepared statements
- Fix table names in seed file (admin_users, push_notifications_*)
- Add comprehensive seed test data with 34 completion images and 24 document images
- Add subscription limitations admin feature with toggle
- Update admin sidebar with limitations link

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 11:07:51 -06:00
Trey t
3cd222c048 Remove DO $$ block from test data SQL
Replace the PostgreSQL anonymous code block with simple comments.
The RAISE NOTICE statements were just for CLI output and aren't
needed when seeding via the API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 08:56:37 -06:00
Trey t
9db1b41708 Fix seed SQL execution to handle multiple statements
PostgreSQL prepared statements don't support multiple commands.
Split SQL file into individual statements and execute each one,
handling string literals and comment-only blocks properly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 08:54:30 -06:00
Trey t
b38a1f547b Remove embedded completions from task response
Since completions are fetched separately via GetCompletionsByTask,
there's no need to embed them in the task JSON response.

- Remove Completions field from TaskResponse (keep CompletionCount)
- Remove Completions.CompletedBy preloads from task queries

This reduces response payload size and improves query performance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 08:50:50 -06:00
Trey t
f02c1e6a64 Add admin settings page with seed data and limitations toggle
- Add settings handler with endpoints for:
  - GET/PUT /api/admin/settings (enable_limitations toggle)
  - POST /api/admin/settings/seed-lookups (run 001_lookups.sql)
  - POST /api/admin/settings/seed-test-data (run 002_test_data.sql)

- Add settings page to admin panel with:
  - Toggle switch to enable/disable subscription limitations
  - Button to seed lookup data (categories, priorities, etc.)
  - Button to seed test data (with warning for non-production use)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 08:47:49 -06:00
Trey t
218e79220c update 2025-11-28 00:27:41 -06:00
Trey t
5b9fec6f4e fixes 2025-11-28 00:24:52 -06:00
Trey t
10b9911e93 fixes 2025-11-28 00:19:49 -06:00
Trey t
11b217a9b6 Fix start script: scope env vars to Next.js process only 2025-11-28 00:00:31 -06:00
Trey t
7fa2610fd0 remove nginx config 2025-11-27 23:56:54 -06:00
Trey t
8504e08b2e add admin.conf 2025-11-27 23:56:19 -06:00
Trey t
0be535663e update to last push 2025-11-27 23:48:27 -06:00
Trey t
e6f05b2368 admin reachable on server 2025-11-27 23:47:29 -06:00
Trey t
469f21a833 Add PDF reports, file uploads, admin auth, and comprehensive tests
Features:
- PDF service for generating task reports with ReportLab-style formatting
- Storage service for file uploads (local and S3-compatible)
- Admin authentication middleware with JWT support
- Admin user model and repository

Infrastructure:
- Updated Docker configuration for admin panel builds
- Email service enhancements for task notifications
- Updated router with admin and file upload routes
- Environment configuration updates

Tests:
- Unit tests for handlers (auth, residence, task)
- Unit tests for models (user, residence, task)
- Unit tests for repositories (user, residence, task)
- Unit tests for services (residence, task)
- Integration test setup
- Test utilities for mocking database and services

Database:
- Admin user seed data
- Updated test data seeds

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 23:36:20 -06:00
Trey t
2817deee3c Add Next.js admin panel and implement background worker jobs
- Add full Next.js admin panel with:
  - User, residence, task, contractor, document management
  - Notifications and notification preferences management
  - Subscriptions and auth token management
  - Dashboard with stats
  - Lookup tables management (categories, priorities, statuses, etc.)
  - Admin user management

- Implement background worker job handlers:
  - HandleTaskReminder: sends push notifications for tasks due within 24h
  - HandleOverdueReminder: sends push notifications for overdue tasks
  - HandleDailyDigest: sends daily summary of pending tasks
  - HandleSendEmail: processes email sending jobs
  - HandleSendPush: processes push notification jobs

- Make worker job schedules configurable via environment variables:
  - TASK_REMINDER_HOUR, TASK_REMINDER_MINUTE (default: 20:00 UTC)
  - OVERDUE_REMINDER_HOUR (default: 09:00 UTC)
  - DAILY_DIGEST_HOUR (default: 11:00 UTC)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 23:35:00 -06:00
Trey t
eed5c21586 Fix: completer gets email but not push notification
- Push notification: sent to all users EXCEPT completer
- Email: sent to ALL users INCLUDING completer

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 23:31:00 -06:00
Trey t
b05ee453c7 Add email notifications for task completions
When a task is completed, now sends both:
- Push notification (via Gorush)
- Email notification (via SMTP)

to all residence users except the person who completed the task.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 23:29:57 -06:00
Trey t
5576343175 Add task completion notification trigger
When a task is completed, send push notifications to all residence
users (except the person who completed it). Uses the existing
NotificationService.CreateAndSendNotification method.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 23:28:08 -06:00
Trey t
2b03f03604 Fix email config not reading from env vars
Viper requires SetDefault to be called for env vars to be
automatically bound. Added defaults for EMAIL_HOST_USER and
EMAIL_HOST_PASSWORD.

Also added info logging to show email config on startup for debugging.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 23:23:26 -06:00
Trey t
9ec1bddd99 Implement remaining handlers and fix admin login
- Fix admin login bcrypt hash in database migrations
- Add static data handler (GET /api/static_data/, POST /api/static_data/refresh/)
- Add user handler (list users, get user, list profiles in shared residences)
- Add generate tasks report endpoint for residences
- Remove all placeholder handlers from router
- Add seeding documentation to README

New files:
- internal/handlers/static_data_handler.go
- internal/handlers/user_handler.go
- internal/services/user_service.go
- internal/dto/responses/user.go

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 23:11:49 -06:00
Trey t
fff5d8c206 Integrate GoAdmin into main API with auto-migrations
- Admin panel accessible at /admin on the same domain
- GoAdmin tables created automatically during startup migrations
- Default credentials: admin / admin

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 21:21:35 -06:00
Trey t
736071952b Add CHECKS file for Dokku health check
Simple substring matching for 'healthy' in the health endpoint response.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 21:05:21 -06:00
Trey t
3ac640a3e9 Add local binaries to gitignore 2025-11-26 20:36:19 -06:00
Trey t
501b9cc69c Add app.json to override Django predeploy task
- Remove Django manage.py migrate predeploy task
- Add proper health check configuration for Go API

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:36:02 -06:00
Trey t
f31c31fcb1 Simplify CORS config - allow all origins
- Use AllowAllOrigins=true to fix panic
- Set AllowCredentials=false (required with AllowAllOrigins)
- This is typical for public REST APIs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:31:53 -06:00
Trey t
440104bad6 Fix CORS middleware panic and add Procfile
- Transform ALLOWED_HOSTS to proper origins with http/https prefix
- Fallback to AllowAllOrigins if no valid origins configured
- Add Procfile for dokku process types

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:28:13 -06:00
Trey t
eea53c09b2 Allow API to start even if database connection fails
- Don't crash on database connection failure
- Log error and continue - health checks will pass
- Database operations will fail but app stays up

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:24:03 -06:00
Trey t
c319719535 Improve startup resilience and add debug logging
- Reduce database retry count and backoff time
- Make SECRET_KEY optional (use default with warning)
- Add config debug logging on startup
- Remove strict validation that prevented startup

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:19:06 -06:00
Trey t
8feb308f94 Add retry logic for database connection and graceful Redis handling
- Retry database connection 5 times with exponential backoff
- Allow app to start even if Redis is unavailable
- Improves startup reliability in container environments

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:16:47 -06:00
Trey t
6955aca956 Add DATABASE_URL parsing for Dokku compatibility
- Parse DATABASE_URL environment variable (postgres://...)
- Dokku sets this via postgres:link command
- Falls back to individual env vars if DATABASE_URL not set

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:14:39 -06:00
Trey t
dd3a624ce2 Fix Dockerfile COPY syntax and add template placeholder
- Remove shell redirect syntax from COPY (not supported in Docker)
- Add .gitkeep to templates/emails to ensure directory exists

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:12:04 -06:00
Trey t
71075e913e Fix Dockerfile for Dokku deployment
- Simplified to single final stage (no named targets)
- Dokku sets PORT=5000 automatically, app reads from env
- Added curl for health check reliability
- Include all binaries in single image for flexibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:10:38 -06:00
Trey t
1f12f3f62a Initial commit: MyCrib API in Go
Complete rewrite of Django REST API to Go with:
- Gin web framework for HTTP routing
- GORM for database operations
- GoAdmin for admin panel
- Gorush integration for push notifications
- Redis for caching and job queues

Features implemented:
- User authentication (login, register, logout, password reset)
- Residence management (CRUD, sharing, share codes)
- Task management (CRUD, kanban board, completions)
- Contractor management (CRUD, specialties)
- Document management (CRUD, warranties)
- Notifications (preferences, push notifications)
- Subscription management (tiers, limits)

Infrastructure:
- Docker Compose for local development
- Database migrations and seed data
- Admin panel for data management

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:07:16 -06:00