How aws-samples/aws-appconfig-feature-flags works
Project type and purpose
• This is a full-stack, serverless web application demonstrating AWS AppConfig Feature Flags.
• The README describes a sample storefront: a React SPA ("frontend" folder) that fetches product data and feature-flag settings from an AWS SAM–backed API ("backend" folder). It uses AWS AppConfig to roll out feature flags, DynamoDB to store sample data, and AWS Lambda + API Gateway to serve endpoints.
File structure
• Top level:
• backend/ – AWS SAM service with Lambda functions, a shared Lambda layer, DynamoDB template, and SAM template.yaml
• frontend/ – React application with components, pages, services, context, static assets, and a config template
• repo-wide docs & config: README.md, LICENSE, CONTRIBUTING, .gitignore
• backend/ details:
• template.yaml – defines AWS::Serverless::Function resources, DynamoDB table, API endpoint
• backend/src/ – code for three Lambda functions:
– getAllProducts – returns product list
– getFeatureFlags – returns feature flags
– FeatureFlagLayer – shared layer code that calls AWS AppConfig (getConfig.js, getFeature.js)
• backend/dynamodb.json.template – DynamoDB items template for sample data
• frontend/ details:
• public/ – static HTML entry point and images
• src/ – React entry (index.js), App.js, components (e.g., ProductItem, Feature), pages (Product, Checkout), AppContext (state & API client), services (currency formatter), config.json.template
README for additional insights
• Describes deployment steps:
• SAM build & deploy – yields HttpApiUrl and DynamoDBTableName
• Populate DynamoDB via aws cli
• Configure frontend config.json with HttpApiUrl, run npm start
• Emphasizes AWS AppConfig Feature Flags usage and DynamoDB-backed sample data
Diagramming the architecture
a. Main components:
• Frontend: React SPA (runs in user's browser)
• API Gateway (HTTP API) – exposes REST endpoints
• AWS Lambda functions – getAllProducts, getFeatureFlags, plus shared FeatureFlagLayer
• DynamoDB table – stores products & flags
• AWS AppConfig – external feature-flag service (Application / Environment / Configuration Profile)
b. Relationships & interactions:
1. User’s browser loads React SPA from localhost:3000 (or hosted static site)
2. SPA reads config.json → HttpApiUrl
3. SPA calls API Gateway endpoints (/products, /feature-flags)
4. API Gateway routes to respective Lambda functions
5. Lambdas use:
– DynamoDB SDK to fetch products & raw flag data
– FeatureFlagLayer to call AWS AppConfig GetConfiguration API and evaluate flags
6. Lambdas return JSON to frontend
7. SPA uses AppContext to store & render based on feature flags
c. Architectural patterns & design principles:
• Serverless microservices: each function has its own package.json and granular permissions
• Shared Lambda Layer (FeatureFlagLayer) centralizes AppConfig logic
• React context for state management and API abstraction
• Infrastructure-as-code via AWS SAM (template.yaml)
d. Key technologies, frameworks & libraries:
• AWS SAM, CloudFormation
• AWS Lambda, API Gateway (HTTP API)
• AWS AppConfig
• DynamoDB
• Node.js & npm (backend & layer)
• React, Create React App, Context API (frontend)