DeployFrame Docs

Infrastructure Overview

Understanding the AI SaaS Boilerplate architecture and CDK structure

Infrastructure Overview

The AI SaaS Boilerplate is built on a modern, fully serverless AWS architecture designed for scalability, cost efficiency, and rapid deployment. This section helps you understand what you're deploying and how the infrastructure components work together.

Why Serverless Architecture?

The platform uses a 100% serverless approach for several key advantages:

  • Automatic Scaling: Resources scale up and down based on actual usage
  • Cost Efficiency: Pay only for what you use, with no idle server costs
  • Zero Maintenance: No servers to manage, patch, or monitor
  • High Availability: Built-in redundancy across multiple AWS regions

With serverless architecture, costs scale directly with usage. Development and testing often run within AWS free tier limits, while production automatically handles any traffic volume.

Architecture Overview

AI SaaS Architecture

The platform is organized into four main layers, each handling specific responsibilities:

  1. Frontend Layer: Next.js web application hosted on AWS Amplify
  2. API Layer: API Gateway routing requests to Lambda functions
  3. Service Layer: AI services and core business logic
  4. Storage Layer: DynamoDB and S3 for data persistence

CDK Code Structure

The infrastructure is deployed using AWS CDK with Python. Here's how the code is organized:

cdk/lib/
├── core/                          # Foundation infrastructure
│   ├── auth/                      # Authentication (Cognito)
│   ├── storage/                   # File storage (S3)
│   ├── scheduler/                 # Event scheduling
│   └── config.py                  # Environment configuration
├── business/                      # Business logic systems
│   ├── credits/                   # Credit management (AppSync)
│   └── payments/                  # Payment processing (Stripe)
├── services/                      # AI service implementations
│   ├── document/                  # PDF chat, OCR, markdown
│   ├── image/                     # Generation, style transfer
│   ├── video/                     # YouTube chat, summarization
│   └── service_factory.py         # Service creation and management
├── frontend/                      # Frontend deployment
│   ├── amplify_config_stack.py    # Configuration management
│   ├── nextjs_stack.py           # Next.js deployment
│   └── api/                       # Frontend-specific APIs
└── app.py                         # Main deployment orchestration

The CDK structure follows a layered dependency pattern: Core → Business → Services → Frontend. Each layer builds upon the previous one, ensuring proper resource dependencies and deployment order.

Technology Stack Summary

Frontend:

  • Next.js 14+ with React and JavaScript
  • Tailwind CSS for styling
  • AWS Amplify for hosting and deployment

Backend:

  • AWS Lambda functions (Python)
  • API Gateway for HTTP routing
  • AWS AppSync for GraphQL APIs

Data & Storage:

  • Amazon DynamoDB for structured data
  • Amazon S3 for file storage
  • AWS Parameter Store for secure configuration

AI & External Services:

  • AWS Bedrock (Titan Image Generator)
  • AWS Textract for document processing
  • OpenAI API integration
  • Stripe for payments

Infrastructure Guides

Next Steps

Now that you understand the overall structure, you can:

  • Explore the Architecture Layers for detailed component explanations
  • Review the Backend section for service implementations
  • Check the Frontend section for user interface details

On this page