This project contains practical examples demonstrating the power and flexibility of the Adjacency List pattern for modeling relational data in DynamoDB using an e-commerce platform example.
This comprehensive example covers:
Basic E-commerce Relationships
- Users: Customers and sellers with different profiles
- Products: Items with categories and seller relationships
- Orders: Customer orders with multiple order items
- Reviews: Product reviews with user and product relationships
- Categories: Product categorisation with flexible assignment
Query Patterns Demonstrated
- Single item retrieval by exact key
- One-to-many relationships (user's orders, product reviews)
- Many-to-many relationships (products in categories)
- Complex entity relationships in single queries
- Hierarchical traversal (parent/child navigation)
- Cross-entity analytics (orders for specific products)
Advanced Pattern Implementations
- Write Sharding: Distribute high-traffic entity writes across multiple partitions
- Hierarchical Data: Nested category structures with efficient navigation
- Bidirectional Relationships: Query relationships from either direction using GSI
- Time-Series Patterns: Time-based sorting and filtering
deploy/- AWS CLI deployment scriptsdata/- Sample data filessrc/- TypeScript application demonstrating queriesscripts/- Utility scripts for setup and data loading
- AWS CLI configured with appropriate permissions
- Node.js 18+ and npm
- DynamoDB permissions (CreateTable, PutItem, Query, etc.)
npm run setupThis single command will:
- Check all prerequisites (AWS CLI, Node.js, credentials)
- Install dependencies
- Deploy the DynamoDB table
- Build the TypeScript code
- Load sample data
- Confirm everything is ready
-
Deploy the DynamoDB table:
chmod +x scripts/deploy.sh ./scripts/deploy.sh
-
Install dependencies and build:
npm install npm run build
-
Load sample data:
npm run load-data
-
Run the demo application:
npm start
npm run build- Compile TypeScriptnpm run dev- Run in development mode with auto-reloadnpm run load-data- Load sample data into DynamoDBnpm run clean-table- Remove all data from the tablenpm start- Run the demo application
Make sure your AWS CLI is configured with a region and credentials:
aws configureThe scripts will use your default AWS profile and region.