mad-lawsuit/cline_docs/activeContext.md

402 lines
18 KiB
Markdown

# Active Context - Current Work Status
## Current Task: v2.0 PRODUCTION DEPLOYMENT - COMPLETE ✅
**MAD Lawsuit Website v2.0 - Fully Operational at https://v2.mad-lawsuit.org**:
- **v1.0 Status**: Fully operational at https://mad-lawsuit.org (Next.js + Express + React)
- **v2.0 Status**: **FULLY OPERATIONAL** at https://v2.mad-lawsuit.org (Laravel + Inertia + Vue)
- **Current Phase**: Phase 4 - Production Deployment **COMPLETE**
- **Status**: All systems operational, ready for DNS switchover 🎉
### Phase 4 Deployment - COMPLETE ✅
**All Steps Successfully Completed:**
1. **Docker Container Deployment**
- Fixed PHP-FPM issue: Changed `php-fpm8.3``php-fpm` in supervisord.conf
- Rebuilt container on production server (10.4.0.205)
- Both nginx and PHP-FPM running successfully
- Container: `mad-lawsuit-v2` on port 8080
2. **Caddy Reverse Proxy Configuration**
- Added v2.mad-lawsuit.org to centralized Caddyfile
- Configuration: `v2.mad-lawsuit.org``localhost:8080`
- Added www redirect: `www.v2.mad-lawsuit.org``v2.mad-lawsuit.org`
- Caddy reloaded successfully
- SSL certificate auto-provisioned by Let's Encrypt
3. **Environment Configuration**
- Created .env file with PostgreSQL settings
- Generated APP_KEY successfully
- Vite build assets present (manifest.json exists)
- Added ASSET_URL for HTTPS asset loading
4. **Critical Fixes Applied**
- **AdminUser Password Issue**: Removed password mutator that was double-hashing
- **AdminSeeder Fix**: Updated to use correct bcrypt hash format (`$2y$`)
- **Mixed Content Fix**: Added TrustProxies middleware to detect HTTPS from Caddy
- **Background Colors**: Matched v1 exactly (#6E6362 and rgba(57,64,83,0.95))
5. **Database Setup**
- Ran migrations successfully on production PostgreSQL
- Seeded database with all v1 data (63 entries, 63 documents, 28 subscribers)
- All relationships intact and verified
6. **Admin Authentication**
- **URL**: https://v2.mad-lawsuit.org/admin/login
- **Username**: eliza
- **Password**: AXEoZWk2AMAD0naw
- **Status**: Login working perfectly, password persists across rebuilds
- **Dashboard**: Showing 63 entries, 63 documents, 27 subscribers
7. **Visual Design Match**
- Extracted exact colors from v1 React container
- Updated v2 to match v1 precisely
- Background colors: #6E6362 (main), rgba(57,64,83,0.95) (header/footer)
- Eliza won't notice any visual differences
### Production URLs
- **v1.0 (Current)**: https://mad-lawsuit.org
- **v2.0 (Ready)**: https://v2.mad-lawsuit.org
- **v2.0 Admin**: https://v2.mad-lawsuit.org/admin/login
### Admin Credentials
- **Username**: eliza
- **Password**: AXEoZWk2AMAD0naw
- **Access**: Full CRUD operations on docket entries, documents, and subscribers
### v2.0 Phase 2 COMPLETED ✅
**Admin Dashboard - Fully Functional**:
**Controllers Implemented**:
-**AuthController** - Login/logout with session management
-**DashboardController** - Statistics and recent entries
-**DocketEntryController** - Full CRUD (7 resource methods)
-**DocumentController** - PDF upload/delete with UUID naming
-**SubscriberController** - List and deactivate subscribers
**Vue Pages Created**:
-**Admin/Login.vue** - Professional authentication page
-**Admin/Dashboard.vue** - Statistics cards, quick actions, recent entries
-**Admin/DocketEntries/Index.vue** - Paginated table (20 per page)
-**Admin/DocketEntries/Create.vue** - Form for new entries
-**Admin/DocketEntries/Edit.vue** - Update existing entries
-**Admin/DocketEntries/Show.vue** - View details + upload documents
-**Admin/Subscribers/Index.vue** - Manage email subscribers (50 per page)
**Features Implemented**:
- ✅ Session-based authentication (separate from Breeze)
- ✅ Full CRUD operations for docket entries
- ✅ PDF document upload with validation (10MB max, PDF only)
- ✅ UUID-based file naming for security
- ✅ File storage in `storage/app/public/documents`
- ✅ Storage symlink configured (`php artisan storage:link`)
- ✅ Pagination for entries and subscribers
- ✅ Soft delete for subscribers (deactivate)
- ✅ Cascade delete for entries (removes documents)
- ✅ Professional UI with Tailwind CSS
- ✅ Form validation with error display
- ✅ Success/error flash messages
- ✅ Responsive design
### v2.0 Technology Stack
**Backend**:
- **Framework**: Laravel 12.43.1 (latest stable)
- **PHP**: 8.3.28
- **Database**: PostgreSQL 16-alpine (production)
- **ORM**: Eloquent (replacing Prisma)
- **Auth**: Laravel Sanctum + Session
- **API**: Inertia.js server-side
**Frontend**:
- **Framework**: Vue 3 + TypeScript
- **Routing**: Inertia.js (SSR-like experience)
- **Styling**: Tailwind CSS 3.x
- **Build Tool**: Vite 7.x
- **Components**: Vue SFC (Single File Components)
**Production Environment**:
- **Server**: 10.4.0.205 (dedicated server behind NAT)
- **Docker**: Alpine Linux containers
- **Web Server**: nginx 1.28.0
- **PHP**: PHP-FPM 8.3.28
- **Database**: PostgreSQL 16-alpine
- **Reverse Proxy**: Caddy (with auto-SSL)
### v2.0 Progress Checklist
**Phase 1 - Public Website** ✅ COMPLETE:
- [x] Install PHP 8.3 and Composer locally
- [x] Create Laravel 12 project
- [x] Install Laravel Breeze with Vue + Inertia + TypeScript
- [x] Resolve NPM dependency conflicts (Vite 7 compatibility)
- [x] Install all NPM packages successfully
- [x] Create database migrations (docket_entries, documents, subscriptions, admin_users)
- [x] Create Eloquent models with relationships
- [x] Run migrations successfully (SQLite)
- [x] Create HomeController with Inertia
- [x] Build Vue home page component matching v1.0 design
- [x] Test locally with development servers (php artisan serve + npm run dev)
- [x] Verify website rendering correctly
- [x] Implement email subscription API
- [x] Add document download functionality
**Phase 2 - Admin Dashboard** ✅ COMPLETE:
- [x] Build admin authentication (session-based)
- [x] Create AdminUser model and migration
- [x] Implement AuthController (login/logout)
- [x] Create AdminAuth middleware
- [x] Build Admin/Login.vue page
- [x] Implement DashboardController with statistics
- [x] Create Admin/Dashboard.vue page
- [x] Implement DocketEntryController (all 7 CRUD methods)
- [x] Create all DocketEntry Vue pages (Index, Create, Edit, Show)
- [x] Implement DocumentController (store, destroy)
- [x] Implement SubscriberController (index, destroy)
- [x] Create Admin/Subscribers/Index.vue page
- [x] Set up file storage for PDFs
- [x] Configure storage symlink
**Phase 3 - Data Migration** ✅ COMPLETE (100%):
- [x] Export v1.0 production data (PostgreSQL dump)
- [x] Copy PDF files from production (69 files, 158MB)
- [x] Create V1DataMigrationSeeder (tested with sample data)
- [x] Create Python parser script (parse_sql_to_seeder.py)
- [x] Identify parser limitation (only captured 32/63 entries)
- [x] Create improved parser v2 (parse_sql_to_seeder_v2.py) with multi-line support
- [x] Generate complete PHP arrays (63 entries, 63 docs, 28 subs)
- [x] Update seeder with all production data
- [x] Run seeder to import ALL data
- [x] Verify 100% data integrity in database (63/63/28)
**Phase 4 - Production Deployment** ✅ COMPLETE (100%):
- [x] Create Dockerfile and docker-compose.yml
- [x] Build Docker image with PHP-FPM + nginx
- [x] Fix PHP-FPM command issue (php-fpm8.3 → php-fpm)
- [x] Deploy container to production server
- [x] Configure Caddy reverse proxy
- [x] Create production .env file
- [x] Generate APP_KEY
- [x] Fix AdminUser password double-hashing issue
- [x] Update AdminSeeder with correct bcrypt hash
- [x] Add TrustProxies middleware for HTTPS detection
- [x] Match v1 background colors exactly
- [x] Run migrations on production database
- [x] Seed production database with v1 data
- [x] Verify SSL certificate provisioning
- [x] Test admin login (working perfectly)
- [x] Test all functionality (all working)
- [x] Visual design matches v1 exactly
**Phase 5 - DNS Switchover** (PENDING USER DECISION):
- [ ] Update DNS: mad-lawsuit.org → v2.mad-lawsuit.org
- [ ] Monitor for 24-48 hours
- [ ] Decommission v1 containers
- [ ] Implement email notifications (future enhancement)
### v2.0 Design Specifications
**Complete v1.0 documentation captured**:
- ✅ Visual design (colors, typography, layout)
- ✅ Component specifications (forms, cards, buttons)
- ✅ Functional requirements (interactions, animations)
- ✅ Data structures (63 entries, 63 PDFs, 28 subscribers)
- ✅ Admin dashboard specs (complete CRUD operations)
- ✅ Production data verified from live database
- ✅ Exact color matching from v1 container
**Reference Document**: `cline_docs/v1_design_specifications.md` (400+ lines)
### Next Steps (Optional Enhancements)
**Future Improvements**:
1. **Email Notifications** - Configure SMTP for subscriber notifications
2. **Monitoring** - Set up application monitoring and alerts
3. **Backups** - Automated database and file backups
4. **Performance** - Redis caching for improved speed
5. **Analytics** - Track visitor statistics
### Data Migration Details
**v1.0 Production Data**:
- **Docket Entries**: 63 entries with dates, titles, summaries
- **Documents**: 63 PDF files (UUID filenames)
- **Subscriptions**: 28 email subscribers (27 active)
- **Total Size**: 158MB of PDF files
**Schema Mapping** (v1.0 → v2.0):
- `docket_entries.id``docket_entries.id`
- `docket_entries.date``docket_entries.date`
- `docket_entries.title``docket_entries.title`
- `docket_entries.summary``docket_entries.summary`
- `docket_entries.notes``docket_entries.notes`
- `docket_entries.createdAt``docket_entries.created_at`
- `docket_entries.updatedAt``docket_entries.updated_at`
- `documents.docketEntryId``documents.docket_entry_id`
- `documents.storedFilename``documents.stored_filename`
- `documents.originalFilename``documents.original_filename`
- `documents.fileSize``documents.file_size`
- `documents.mimeType``documents.mime_type`
- `documents.displayOrder``documents.display_order`
- `subscriptions.isActive``subscriptions.is_active`
- `subscriptions.unsubscribeToken``subscriptions.unsubscribe_token`
- `subscriptions.createdAt``subscriptions.created_at`
## Previous Task: v1.0 PRODUCTION SERVER MIGRATION COMPLETED ✅
**MAD Lawsuit Website Successfully Migrated to New Infrastructure**:
- **Old Server**: chrishaulmark.com (DigitalOcean VPS - being decommissioned)
- **New Server**: 10.4.0.205 (Dedicated server behind NAT)
- **Status**: FULLY OPERATIONAL WITH ALL DATA MIGRATED ✅
- **v1.0 Tagged**: Git tag `v1.0` created and pushed to Gitea
### Migration Implementation Details
**Infrastructure Changes**:
1. **Package Upgrades** ✅ COMPLETED
- **Frontend**: React 18→19, Next.js 15→16, Tailwind 3→4
- **Backend**: Prisma 5→7, Express 4→5
- **All Dependencies**: Updated to latest stable versions
- **Docker Images**: Rebuilt with new package versions
2. **Caddy Reverse Proxy Fix** ✅ COMPLETED
- **Problem**: Docker DNS resolving container hostnames to wrong network IPs
- **Impact**: Caddy timing out trying to reach containers
- **Solution**: Updated Caddyfile to use direct IP addresses on caddy_network
- **Frontend IP**: 172.18.0.6:806 (instead of hostname)
- **Backend IP**: 172.18.0.5:901 (instead of hostname)
- **File**: `/home/chaulmark/docker/caddy/config/Caddyfile` on server
3. **Data Migration** ✅ COMPLETED
- **Database**: PostgreSQL data (47MB) migrated from old server
- **PDF Files**: 158MB of court documents (69 files) migrated
- **Redis Cache**: Cache data migrated
- **Method**: Created tar archive, transferred via rsync, extracted on new server
- **Location**: `/docker/websites/mad-lawsuit/` on 10.4.0.205
4. **SSL Certificates** ✅ COMPLETED
- **Provider**: Let's Encrypt via Caddy
- **Domains**: mad-lawsuit.org, files.mad-lawsuit.org, v2.mad-lawsuit.org
- **Status**: Active and auto-renewing
### Final Production Architecture
```
┌─────────────────────────────────────────────────────────┐
│ Caddy Reverse Proxy (10.4.0.205) │
│ │
│ mad-lawsuit.org → 172.18.0.6:806 (Frontend v1) │
│ files.mad-lawsuit.org → 172.18.0.5:901 (Backend v1) │
│ v2.mad-lawsuit.org → localhost:8080 (v2 LIVE) │
└─────────────────────────────────────────────────────────┘
├─────────────────────────────┐
│ │
┌──────▼──────┐ ┌──────▼──────┐
│ Frontend │ │ Backend │
│ Port 806 │──────────────│ Port 901 │
│ Next.js 16 │ API Calls │ Express 5 │
│ React 19 │ │ Prisma 7 │
└─────────────┘ └─────────────┘
┌──────▼──────┐
│ PostgreSQL │
│ + Redis │
└─────────────┘
```
### Deployment Server Information
**IMPORTANT**: All deployments now go to **10.4.0.205** (NOT chrishaulmark.com)
**Server Details**:
- **Hostname**: public-websites (internal: 10.4.0.205)
- **External Access**: Via NAT through dedicated server
- **SSH Access**: `ssh chaulmark@10.4.0.205`
- **v1 Project**: `~/websites/mad-lawsuit.org/`
- **v2 Project**: `~/websites/v2.mad-lawsuit.org/`
- **Docker Volumes**: `/docker/websites/mad-lawsuit/`
**v2 Deployment Commands**:
```bash
# SSH to production server
ssh chaulmark@10.4.0.205
# Navigate to v2 project
cd ~/websites/v2.mad-lawsuit.org
# Pull latest code
git pull origin main
# Rebuild and restart containers
docker compose down
docker compose up -d --build
# Check container status
docker compose ps
docker compose logs -f app
# Run migrations
docker exec mad-lawsuit-v2 php artisan migrate --force
# Seed database
docker exec mad-lawsuit-v2 php artisan db:seed --class=V1DataMigrationSeeder --force
# Clear caches
docker exec mad-lawsuit-v2 php artisan config:clear
docker exec mad-lawsuit-v2 php artisan cache:clear
docker exec mad-lawsuit-v2 php artisan route:clear
```
### Verification ✅
- **v1 Website**: https://mad-lawsuit.org (HTTP/2 200 ✓)
- **v1 Backend API**: https://files.mad-lawsuit.org (HTTP/2 200 ✓)
- **v1 Database**: 63 docket entries with all historical data ✓
- **v1 PDF Files**: 69 court documents accessible ✓
- **v1 All Containers**: Running and healthy ✓
- **v2 Website**: https://v2.mad-lawsuit.org (HTTP/2 200 ✓)
- **v2 Admin**: https://v2.mad-lawsuit.org/admin/login (Working ✓)
- **v2 Database**: 63 entries, 63 documents, 27 subscribers ✓
- **v2 All Features**: Fully operational ✓
## Current Status
### What's Working ✅
- **v1.0 Production**: Fully operational at https://mad-lawsuit.org
- **v2.0 Production**: **FULLY OPERATIONAL** at https://v2.mad-lawsuit.org
- **v2.0 Admin**: Login working, all CRUD operations functional
- **v2.0 Database**: All data migrated and verified
- **v2.0 Design**: Matches v1 exactly (colors, layout, functionality)
- **SSL Certificates**: Active on all domains
- **File Storage**: PDFs uploading and downloading correctly
- **Authentication**: Admin login persists across rebuilds
### Ready for DNS Switchover 🎉
The v2.0 website is **production-ready** and can replace v1.0 at any time:
- All features working
- All data migrated
- Visual design matches exactly
- Admin dashboard fully functional
- SSL certificates active
- Performance tested
### Next Steps for User
**Optional - DNS Switchover**:
1. Update DNS: Point mad-lawsuit.org to v2.mad-lawsuit.org
2. Monitor for 24-48 hours
3. Decommission v1 containers once stable
4. Consider future enhancements (email notifications, monitoring, etc.)
### Files Modified (Final Phase)
**Critical Fixes**:
- `app/Models/AdminUser.php` - Removed password mutator
- `database/seeders/AdminSeeder.php` - Fixed bcrypt hash
- `app/Http/Middleware/TrustProxies.php` - Created for HTTPS detection
- `bootstrap/app.php` - Registered TrustProxies middleware
- `resources/js/Pages/Home.vue` - Matched v1 background colors exactly
### Deployment Notes
- **Phase 4 Complete**: All systems operational
- **DNS Ready**: v2.mad-lawsuit.org fully functional
- **SSL Active**: Let's Encrypt certificates auto-renewed
- **Data Verified**: 100% migration success
- **Design Verified**: Exact match to v1
- All code committed to Git repository (latest commit: 7b409eba)
## Investigation Process
1. **Phase 1**: Built public website matching v1.0 design ✅
2. **Phase 2**: Implemented complete admin dashboard with CRUD ✅
3. **Phase 3**: Exported production data and transferred PDF files, created seeders, imported all data ✅
4. **Phase 4**: Deployed to production, fixed all issues, verified functionality ✅
The MAD lawsuit website v2.0 rebuild is **100% COMPLETE** and ready for production use! 🎉