Some checks failed
CI/CD Pipeline / Backend Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Tests (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
Complete rewrite from Express to NestJS with enterprise-grade features: ## Backend Improvements - Migrated from Express to NestJS 11.0.1 with TypeScript - Implemented Prisma ORM 7.3.0 for type-safe database access - Added CASL authorization system replacing role-based guards - Created global exception filters with structured logging - Implemented Auth0 JWT authentication with Passport.js - Added vehicle management with conflict detection - Enhanced event scheduling with driver/vehicle assignment - Comprehensive error handling and logging ## Frontend Improvements - Upgraded to React 19.2.0 with Vite 7.2.4 - Implemented CASL-based permission system - Added AbilityContext for declarative permissions - Created ErrorHandler utility for consistent error messages - Enhanced API client with request/response logging - Added War Room (Command Center) dashboard - Created VIP Schedule view with complete itineraries - Implemented Vehicle Management UI - Added mock data generators for testing (288 events across 20 VIPs) ## New Features - Vehicle fleet management (types, capacity, status tracking) - Complete 3-day Jamboree schedule generation - Individual VIP schedule pages with PDF export (planned) - Real-time War Room dashboard with auto-refresh - Permission-based navigation filtering - First user auto-approval as administrator ## Documentation - Created CASL_AUTHORIZATION.md (comprehensive guide) - Created ERROR_HANDLING.md (error handling patterns) - Updated CLAUDE.md with new architecture - Added migration guides and best practices ## Technical Debt Resolved - Removed custom authentication in favor of Auth0 - Replaced role checks with CASL abilities - Standardized error responses across API - Implemented proper TypeScript typing - Added comprehensive logging Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
135 lines
3.7 KiB
Markdown
135 lines
3.7 KiB
Markdown
# VIP Coordinator Backend
|
|
|
|
NestJS 10.x backend with Prisma ORM, Auth0 authentication, and PostgreSQL.
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
# Install dependencies
|
|
npm install
|
|
|
|
# Set up environment variables
|
|
cp .env.example .env
|
|
# Edit .env with your Auth0 credentials
|
|
|
|
# Start PostgreSQL (via Docker)
|
|
cd ..
|
|
docker-compose up -d postgres
|
|
|
|
# Generate Prisma Client
|
|
npx prisma generate
|
|
|
|
# Run database migrations
|
|
npx prisma migrate dev
|
|
|
|
# Seed sample data (optional)
|
|
npm run prisma:seed
|
|
|
|
# Start development server
|
|
npm run start:dev
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
All endpoints are prefixed with `/api/v1`
|
|
|
|
### Public Endpoints
|
|
- `GET /health` - Health check
|
|
|
|
### Authentication
|
|
- `GET /auth/profile` - Get current user profile
|
|
|
|
### Users (Admin only)
|
|
- `GET /users` - List all users
|
|
- `GET /users/pending` - List pending approval users
|
|
- `GET /users/:id` - Get user by ID
|
|
- `PATCH /users/:id` - Update user
|
|
- `PATCH /users/:id/approve` - Approve/deny user
|
|
- `DELETE /users/:id` - Delete user (soft)
|
|
|
|
### VIPs (Admin, Coordinator)
|
|
- `GET /vips` - List all VIPs
|
|
- `POST /vips` - Create VIP
|
|
- `GET /vips/:id` - Get VIP by ID
|
|
- `PATCH /vips/:id` - Update VIP
|
|
- `DELETE /vips/:id` - Delete VIP (soft)
|
|
|
|
### Drivers (Admin, Coordinator)
|
|
- `GET /drivers` - List all drivers
|
|
- `POST /drivers` - Create driver
|
|
- `GET /drivers/:id` - Get driver by ID
|
|
- `GET /drivers/:id/schedule` - Get driver schedule
|
|
- `PATCH /drivers/:id` - Update driver
|
|
- `DELETE /drivers/:id` - Delete driver (soft)
|
|
|
|
### Events (Admin, Coordinator; Drivers can view and update status)
|
|
- `GET /events` - List all events
|
|
- `POST /events` - Create event (with conflict detection)
|
|
- `GET /events/:id` - Get event by ID
|
|
- `PATCH /events/:id` - Update event
|
|
- `PATCH /events/:id/status` - Update event status
|
|
- `DELETE /events/:id` - Delete event (soft)
|
|
|
|
### Flights (Admin, Coordinator)
|
|
- `GET /flights` - List all flights
|
|
- `POST /flights` - Create flight
|
|
- `GET /flights/status/:flightNumber` - Get real-time flight status
|
|
- `GET /flights/vip/:vipId` - Get flights for VIP
|
|
- `GET /flights/:id` - Get flight by ID
|
|
- `PATCH /flights/:id` - Update flight
|
|
- `DELETE /flights/:id` - Delete flight
|
|
|
|
## Development Commands
|
|
|
|
```bash
|
|
npm run start:dev # Start dev server with hot reload
|
|
npm run build # Build for production
|
|
npm run start:prod # Start production server
|
|
npm run lint # Run ESLint
|
|
npm run test # Run tests
|
|
npm run test:watch # Run tests in watch mode
|
|
npm run test:cov # Run tests with coverage
|
|
```
|
|
|
|
## Database Commands
|
|
|
|
```bash
|
|
npx prisma studio # Open Prisma Studio (database GUI)
|
|
npx prisma migrate dev # Create and apply migration
|
|
npx prisma migrate deploy # Apply migrations (production)
|
|
npx prisma migrate reset # Reset database (DEV ONLY)
|
|
npx prisma generate # Regenerate Prisma Client
|
|
npm run prisma:seed # Seed database with sample data
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
See `.env.example` for all required variables:
|
|
|
|
- `DATABASE_URL` - PostgreSQL connection string
|
|
- `AUTH0_DOMAIN` - Your Auth0 tenant domain
|
|
- `AUTH0_AUDIENCE` - Your Auth0 API identifier
|
|
- `AUTH0_ISSUER` - Your Auth0 issuer URL
|
|
- `AVIATIONSTACK_API_KEY` - Flight tracking API key (optional)
|
|
|
|
## Features
|
|
|
|
- ✅ Auth0 JWT authentication
|
|
- ✅ Role-based access control (Administrator, Coordinator, Driver)
|
|
- ✅ User approval workflow
|
|
- ✅ VIP management
|
|
- ✅ Driver management
|
|
- ✅ Event scheduling with conflict detection
|
|
- ✅ Flight tracking integration
|
|
- ✅ Soft deletes for all entities
|
|
- ✅ Comprehensive validation
|
|
- ✅ Type-safe database queries with Prisma
|
|
|
|
## Tech Stack
|
|
|
|
- **Framework:** NestJS 10.x
|
|
- **Database:** PostgreSQL 15+ with Prisma 5.x ORM
|
|
- **Authentication:** Auth0 + Passport JWT
|
|
- **Validation:** class-validator + class-transformer
|
|
- **HTTP Client:** @nestjs/axios (for flight tracking)
|