A hybrid Next.js 14 application combining frontend and backend for enterprise customer lifecycle orchestration, optimized for AWS Amplify deployment.
- Authentication: JWT-based authentication with secure httpOnly cookies
- Customer Management: CRUD operations for customer records
- Deal Tracking: Manage sales deals and opportunities
- Escalation Management: Track and prioritize support escalations with intelligent scoring
- Responsive UI: Built with TailwindCSS and shadcn/ui components
- Serverless API: Next.js API routes optimized for serverless deployment
- Type-Safe: Full TypeScript coverage across frontend and backend
- Frontend: Next.js 14, React 18, TailwindCSS, React Query, Zustand
- Backend: Next.js API Routes, PostgreSQL, JWT Authentication
- Database: PostgreSQL with pg driver
- Deployment: AWS Amplify (or any Node.js platform)
npm installCopy .env.example to .env.local and configure:
cp .env.example .env.localEdit .env.local with your database credentials and JWT secrets.
Run migrations from the backend project to create database tables, or manually create the schema in your PostgreSQL database.
npm run devOpen http://localhost:3000 in your browser.
hybrid-amplify-version/
├── app/ # Next.js App Router
│ ├── api/ # API Routes (serverless functions)
│ │ ├── auth/ # Authentication endpoints
│ │ ├── customers/ # Customer CRUD endpoints
│ │ ├── deals/ # Deal CRUD endpoints
│ │ └── escalations/ # Escalation CRUD endpoints
│ ├── (auth)/ # Auth pages (login, register)
│ ├── (dashboard)/ # Dashboard pages (protected)
│ ├── layout.tsx # Root layout
│ ├── providers.tsx # React Query & Theme providers
│ └── globals.css # Global styles
├── lib/ # Shared utilities
│ ├── db.ts # Database connection & queries
│ ├── auth.ts # Authentication utilities
│ ├── types.ts # TypeScript type definitions
│ ├── utils.ts # Utility functions
│ ├── error.ts # Error handling
│ └── escalation-scoring.ts # Escalation scoring logic
├── components/ # React components (to be added)
├── stores/ # Zustand stores (to be added)
├── middleware.ts # Next.js middleware (route protection)
├── next.config.js # Next.js configuration
├── tailwind.config.ts # TailwindCSS configuration
├── amplify.yml # AWS Amplify build configuration
└── HYBRID-DEPLOYMENT-GUIDE.md # Detailed deployment guide
POST /api/auth/login- User loginPOST /api/auth/register- User registrationPOST /api/auth/refresh- Refresh access tokenGET /api/auth/me- Get current user
GET /api/customers- List customers (paginated)POST /api/customers- Create customerGET /api/customers/[id]- Get customer by IDPATCH /api/customers/[id]- Update customerDELETE /api/customers/[id]- Soft delete customer
GET /api/deals- List deals (paginated, filterable)POST /api/deals- Create dealGET /api/deals/[id]- Get deal by ID with feature gapsPATCH /api/deals/[id]- Update dealDELETE /api/deals/[id]- Delete deal
GET /api/escalations- List escalations (paginated, filterable)POST /api/escalations- Create escalationGET /api/escalations/[id]- Get escalation by IDPATCH /api/escalations/[id]- Update escalationPOST /api/escalations/[id]/recalculate-score- Recalculate priority scoreDELETE /api/escalations/[id]- Delete escalation
The application uses JWT-based authentication with the following flow:
- User logs in via
/api/auth/login - Server generates JWT token and sets httpOnly cookie
- Middleware protects routes requiring authentication
- Frontend automatically includes cookie in requests
npm run type-checknpm run lintnpm run formatSee HYBRID-DEPLOYMENT-GUIDE.md for detailed deployment instructions.
- Push code to Git repository
- Connect repository to AWS Amplify Console
- Configure environment variables
- Deploy
To complete the full application:
- Copy UI Components: Copy components from
../frontend/components/to./components/ - Copy Pages: Copy page components from
../frontend/app/(dashboard)/to./app/(dashboard)/ - Copy Stores: Copy Zustand stores from
../frontend/stores/to./stores/ - Add Features: Implement WebSocket, AI agents, background jobs as needed
- Testing: Add unit tests and e2e tests
- Monitoring: Set up logging, monitoring, and alerting
The application expects the following tables in PostgreSQL:
users- User accountscustomers- Customer recordsdeals- Sales dealssupport_escalations- Support escalationsfeature_gaps- Feature gap requestsproduct_tickets- Product backlog itemsscoping_specs- Implementation specificationshandoff_packages- Cross-team handoffsnotifications- User notificationsaudit_logs- Audit trail
Run migrations from the backend project to create these tables.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT
For questions and support, refer to: