A complete multi-tenant AI-powered data processing platform with AWS CDK infrastructure and Next.js frontend.Learn more
CortexAI/
βββ π infra/ # AWS CDK Infrastructure
β βββ π bin/ # CDK App Entry Points
β βββ π lib/ # CDK Constructs & Stacks
β βββ π lambda/ # Lambda Functions
β βββ π scripts/ # Deployment Scripts
βββ π frontend/ # Next.js Frontend
β βββ π src/ # Source Code
β βββ π public/ # Static Assets
β βββ π .env.local # Environment Variables (auto-generated)
βββ π package.json # Monorepo Configuration
- Node.js 18+
- AWS CLI configured
- AWS CDK CLI installed
npm installnpm run buildnpm run deploy:infranpm run dev- AWS Cognito User Pool with custom attributes
- Identity Pool for AWS service access
- Tenant isolation through custom attributes
- DynamoDB with tenant-based partitioning
- S3 bucket with tenant-prefixed paths
- Automatic data lifecycle management
- Event-driven data processing
- Amazon Bedrock integration for AI insights
- Configurable processing workflows
- Next.js 14 with TypeScript
- AWS Amplify UI for authentication
- Real-time file upload and processing status
- AI insights visualization
cd infra
# Build Lambda functions
cd lambda/upload && npm install && npm run build && cd ../..
cd lambda/process && npm install && npm run build && cd ../..
cd lambda/insights && npm install && npm run build && cd ../..
# Deploy to development
npm run deploy
# View changes
npm run diffcd frontend
# Start development server
npm run dev
# Build for production
npm run buildAfter deployment, the infrastructure automatically generates:
frontend/.env.local- Frontend environment variablesfrontend/src/config/aws-config.ts- AWS Amplify configuration
// infra/bin/cortex-ai.ts
new CortexAIStack(app, 'CustomCortexAI', {
environment: 'prod',
applicationName: 'my-enterprise-ai',
enableAIInsights: true,
cognitoConfig: {
userPoolName: 'enterprise-users',
},
});- User Authentication β Cognito β Identity Pool
- File Upload β Next.js β API Gateway β Lambda β S3 + DynamoDB
- Data Processing β EventBridge β Lambda β Analysis
- AI Insights β EventBridge β Lambda β Bedrock β Storage
- Frontend Display β API Gateway β Next.js
- DynamoDB partition keys based on tenantId
- S3 object prefixes for tenant separation
- IAM policies with tenant-specific conditions
- Cognito User Pool for user management
- JWT tokens for API access
- Identity Pool for AWS service access
# Deploy to different environments
npm run deploy:infra -- --context environment=dev
npm run deploy:infra -- --context environment=staging
npm run deploy:infra -- --context environment=prod# Build and deploy frontend
npm run deploy:frontend# Deploy everything
npm run deploy:all- Deploy infrastructure
- Create test user in Cognito
- Upload JSON files through frontend
- Monitor processing pipeline
- View AI insights
# Test health endpoint
curl https://your-api-url/health
# Test upload (with auth token)
curl -X POST https://your-api-url/upload \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "X-Tenant-ID: tenant-123" \
-H "Content-Type: application/json" \
-d '{"dataType": "customer", "data": {...}}'- Lambda function execution logs
- API Gateway access logs
- Application performance metrics
- Data upload events
- Processing pipeline events
- AI insights generation events
name: Deploy CortexAI
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm install
- run: npm run build
- run: npm run deploy:all-
CDK Bootstrap Required
cdk bootstrap
-
Lambda Build Errors
cd infra/lambda/upload && npm install && npm run build
-
Frontend Configuration Missing
npm run deploy:infra # This generates frontend config
export CDK_DEBUG=1
npm run deploy:infra- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License.
Built with β€οΈ using AWS CDK and Next.js