A modern Next.js application with AWS CDK infrastructure as code, featuring a scalable, secure, and production-ready architecture.
- TypeScript for type safety and better developer experience
- Tailwind CSS for modern, responsive UI design
- App Router with the latest Next.js 15 features
- Standalone Output optimized for Docker containers
- Health Check API for infrastructure monitoring
- Modern React 19 with server actions and typed routes
- Multi-tier Architecture with proper security segmentation
- ECS Fargate for containerized application deployment
- RDS PostgreSQL with automated backups and encryption
- ElastiCache Redis for high-performance caching
- Application Load Balancer with health checks and auto-scaling
- VPC with Security Groups for network isolation
- Secrets Manager for secure credential management
┌─────────────────────────────────────────────────────────────────────────────┐
│ INTERNET │
└─────────────────────┬─────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ Application Load Balancer (ALB) │
│ Port 80/443 │
└─────────────────────┬─────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ Private Subnets (AZ1, AZ2) │
│ - ECS Fargate Tasks (Next.js App) │
│ - Auto-scaling (2-10 instances) │
└─────────────────────┬─────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ Isolated Subnets (AZ1, AZ2) │
│ - RDS PostgreSQL Database │
│ - ElastiCache Redis Cluster │
└─────────────────────────────────────────────────────────────────────────────┘
- Next.js 15.4.6 - React framework with App Router
- React 19.1.0 - Latest React with concurrent features
- TypeScript 5 - Type-safe JavaScript
- Tailwind CSS 4 - Utility-first CSS framework
- AWS CDK - Infrastructure as Code
- ECS Fargate - Serverless container orchestration
- RDS PostgreSQL 15.4 - Managed relational database
- ElastiCache Redis 7 - Managed in-memory cache
- Application Load Balancer - Traffic distribution
- VPC & Security Groups - Network security
- Docker - Containerization
- ECR - Container registry
- CloudWatch - Monitoring and logging
- Auto Scaling - Dynamic resource management
DemoProject/
├── src/ # Next.js application source
│ ├── app/ # App Router pages and components
│ │ ├── api/ # API routes
│ │ │ └── health/ # Health check endpoint
│ │ ├── globals.css # Global styles with Tailwind
│ │ ├── layout.tsx # Root layout component
│ │ └── page.tsx # Home page component
│ └── ...
├── cdk/ # AWS CDK infrastructure code
│ ├── bin/ # CDK app entry point
│ ├── lib/ # CDK constructs and stacks
│ ├── scripts/ # Deployment scripts
│ ├── test/ # CDK tests
│ └── README.md # CDK documentation
├── public/ # Static assets
├── Dockerfile # Container configuration
├── next.config.ts # Next.js configuration
├── package.json # Node.js dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # This file
- Node.js 18+ and npm
- AWS CLI configured with credentials
- Docker for containerization
- AWS CDK CLI (
npm install -g aws-cdk)
git clone <repository-url>
cd DemoProject
npm install
cd cdk && npm installaws configure
# Enter your AWS Access Key ID, Secret Access Key, and regioncd cdk
# Bootstrap CDK (first time only)
cdk bootstrap
# Deploy all infrastructure
cdk deploy --all# Build the Next.js application
npm run build
# Build Docker image
docker build -t demoproject-app .
# Push to ECR (after infrastructure deployment)
aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <account-id>.dkr.ecr.<region>.amazonaws.com
docker tag demoproject-app:latest <ecr-repository-uri>:latest
docker push <ecr-repository-uri>:latestAfter deployment, you'll get the ALB DNS name from the CDK outputs. Access your application at:
http://<alb-dns-name>
# Start development server
npm run dev
# Open http://localhost:3000cd cdk
# Watch for changes and compile
npm run watch
# Synthesize CloudFormation templates
cdk synth
# View differences
cdk diff- CDK Infrastructure - Complete infrastructure documentation
- Infrastructure Details - Detailed architecture and deployment guide
- Deployment Scripts - Automated deployment scripts for Linux/Mac and Windows
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintcd cdk
npm run build # Build CDK project
cdk synth # Generate CloudFormation templates
cdk deploy --all # Deploy all stacks
cdk destroy --all # Destroy all infrastructure
cdk list # List all stacks
cdk diff # Show changesdocker build -t demoproject-app . # Build image
docker run -p 3000:3000 demoproject-app # Run locally- VPC Isolation - All resources run in private VPC
- Security Groups - Restrictive network access controls
- Encryption - Data encrypted at rest and in transit
- IAM Roles - Least privilege access for services
- Secrets Management - Secure credential storage
- Health Checks - Application and infrastructure monitoring
- Development Environment: T3.micro instances, minimal storage
- Production Ready: Auto-scaling, multi-AZ, reserved instances
- Cost Monitoring: CloudWatch metrics and cost alerts
- Resource Optimization: Right-sizing recommendations
- Multi-AZ Deployment - Enable for high availability
- Backup Strategy - Increase RDS backup retention
- Monitoring - Set up CloudWatch alarms and notifications
- Security - Enable deletion protection and restrict IAM permissions
- Compliance - Ensure infrastructure meets compliance requirements
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Documentation: Project Wiki
- Discussions: GitHub Discussions
- Next.js Team for the amazing framework
- AWS CDK Team for infrastructure as code tools
- Tailwind CSS Team for the utility-first CSS framework
- Open Source Community for all the amazing tools and libraries
Built with ❤️ using Next.js, TypeScript, Tailwind CSS, and AWS CDK