Building a Scalable E-commerce Platform with Flutter, NestJS, and AWS
Webskyne partnered with a mid-size retail client to transform their legacy PHP e-commerce system into a modern, scalable platform using Flutter for cross-platform mobile apps, NestJS for a modular backend architecture, and AWS managed services for cloud infrastructure. The legacy system suffered from slow page load times (averaging 4.5 seconds), limited scalability during peak seasons, and lack of native mobile support.
Over a six-month development cycle, the team delivered a production-ready platform that achieved sub-2-second page load times for 95% of requests, supported automatic horizontal scaling for up to 50,000 concurrent users, and provided native iOS and Android applications from a single Flutter codebase. The solution leveraged AWS services including Aurora Serverless v2 for database scaling, ElastiCache for caching, S3/CloudFront for static assets, and Fargate for containerized backend services.
Post-launch metrics demonstrated significant improvements: page load times reduced from 4.5 seconds to an average of 1.8 seconds for dynamic calls, conversion rates increased by 18%, gross merchandise volume grew 34% quarter-over-quarter, and operational costs decreased by 28%. The platform successfully integrated with the client's existing ERP system and provided a seamless omnichannel experience where cart, wishlist, and user preferences synced across devices.
Case Studye-commerceFlutterNestJSAWSscalabilitymobile developmentcloud infrastructure
Building a Scalable E-commerce Platform with Flutter, NestJS, and AWS
Overview
In the rapidly evolving digital marketplace, businesses require robust, scalable, and user-friendly e-commerce solutions to stay competitive. This case study examines how Webskyne, a fullâservice development agency, partnered with a midâsize retail client to build a crossâplatform eâcommerce application that seamlessly integrates a Flutterâbased mobile frontend, a NestJSâpowered backend, and Amazon Web Services (AWS) for cloud infrastructure. Over a sixâmonth development cycle, the team delivered a productionâready platform that supports over 10,000 concurrent users, processes thousands of daily transactions, and provides a cohesive shopping experience across iOS, Android, and web browsers.
Challenge
The clientâs legacy eâcommerce system was a monolithic PHP application hosted on a single virtual machine. It suffered from frequent performance bottlenecks during peak shopping seasons, limited mobile support, and a cumbersome deployment process that required manual server updates. Key pain points included:
- Slow page load times (averaging 4.5 seconds) leading to high bounce rates.
- Inability to scale horizontally; traffic spikes caused server crashes.
- Lack of a native mobile app, forcing customers to rely on a nonâresponsive mobile web site.
- Deployment risks: each release required downtime and often introduced bugs.
- Difficulty integrating thirdâparty services such as payment gateways, inventory management, and analytics due to tight coupling.
Goals
The project aimed to transform the clientâs online store into a modern, scalable, and futureâproof platform with the following objectives:
1. Achieve subâ2âsecond page load times for 95% of requests under normal load.
2. Support automatic horizontal scaling to handle traffic surges of up to 50,000 concurrent users.
3. Deliver native iOS and Android applications built from a single Flutter codebase, sharing business logic with the web version.
4. Implement a microâserviceâstyle backend using NestJS to enable independent deployment and easier maintenance.
5. Leverage AWS managed services (RDS, ElastiCache, S3, CloudFront, etc.) to reduce operational overhead.
6. Establish a CI/CD pipeline that enables zeroâdowntime deployments and automated rollback.
7. Provide a seamless omnichannel experience where cart, wishlist, and user preferences sync across devices.
8. Reduce operational costs by 30% through optimized resource utilization and managed services.
Approach
Webskyne adopted a domainâdriven design (DDD) approach, breaking the system into bounded contexts such as Catalog, Order, Payment, User, and Inventory. Each context was implemented as a separate NestJS module, communicating via lightweight DTOs and asynchronous events where appropriate. The frontend adopted a clean architecture with featureâbased Flutter modules, using Riverpod for state management and GoRouter for navigation. On the infrastructure side, the team selected AWS services that aligned with the goals of scalability, reliability, and costâefficiency:
- Amazon Aurora (PostgreSQLâcompatible) for the primary relational database, with read replicas for scaling readâheavy workloads.
- Amazon ElastiCache (Redis) for session storage, caching frequently accessed product data, and rateâlimiting.
- Amazon S3 for static assets (images, videos, CSS/JS) served via Amazon CloudFront CDN.
- AWS Fargate for running NestJS containers, allowing the team to focus on application code without managing EC2 instances.
- Application Load Balancer (ALB) to distribute traffic across multiple Fargate tasks and enable SSL termination.
- Amazon Cognito for user authentication, authorization, and social login integration.
- AWS CodePipeline, CodeBuild, and CodeDeploy to automate build, test, and deployment stages.
- Amazon CloudWatch for logging, metrics, and alarms; AWS XâRay for distributed tracing.
The development process followed Scrum with twoâweek sprints, daily standâups, and biâweekly sprint reviews with the client. Continuous feedback loops ensured that the evolving product matched business expectations.
Implementation
The implementation phase was divided into four parallel tracks: backend services, frontend applications, infrastructure as code (IaC), and DevOps automation.
Backend (NestJS)
- Created a monorepo using Nx to share libraries and enforce linting/formatting standards.
- Each microservice (Catalog, Order, Payment, etc.) was a NestJS application with its own database schema where logical separation benefited performance.
- Used TypeORM for ORM, with migrations managed via TypeORM CLI.
- Implemented JWTâbased authentication guarded by NestJS AuthModule, integrating with Amazon Cognito user pools.
- Employed NestJS microservices (TCP/Redis) for interâservice communication where eventual consistency was acceptable (e.g., updating inventory after order placement).
- Integrated thirdâparty APIs: Stripe for payments, Twilio for SMS notifications, and a custom ERP system via REST/WebSocket.
- Wrote unit tests with Jest and integration tests using SuperTest; achieved 85%+ code coverage.
- Dockerized each service with multiâstage builds to keep image sizes under 150âŻMB.
Frontend (Flutter)
- Structured the Flutter project using the featureâslice pattern: each feature (home, product catalog, cart, checkout, profile) lived in its own folder with UI, business logic, and widgets.
- Leveraged Riverpod for state management, allowing selective rebuilds and easy testing.
- Used GoRouter for declarative navigation, supporting deep links and web URL strategy.
- Created a shared Dart package for data models and API clients, consumed by both mobile and web builds.
- Implemented responsive design with LayoutBuilder and MediaQuery to adapt to various screen sizes.
- Optimized images with flutter_native_splash and cached_network_image; used WebP format where supported.
- Added accessibility features: semantic labels, sufficient contrast, and scalable fonts.
- Conducted widget tests with flutter_test and integration tests using flutter_driver.
- Built release binaries for iOS (IPA) and Android (AAB) using Flutterâs build commands; enabled appâbundles for smaller download sizes.
Infrastructure (AWS & IaC)
- Defined infrastructure as code using AWS CloudFormation (YAML) and supplemented with AWS CDK (TypeScript) for higherâlevel abstractions.
- Created separate stacks for networking (VPC, subnets, IGW, NAT), database (Aurora cluster), caching (ElastiCache), and compute (ECS/Fargate services).
- Configured Aurora Serverless v2 to automatically scale compute capacity based on workload, reducing idle costs.
- Set up ElastiCache cluster with automatic failover and readâreplica support.
- Configured S3 buckets with versioning, lifecycle policies (transition to Glacier after 90 days), and publicâread access for static assets.
- Deployed CloudFront distribution with origin access identity (OAI) to secure S3 origins, and added Lambda@Edge for header manipulation and basic A/B testing.
- Established ECS cluster with Fargate launch type; defined task definitions for each NestJS service, specifying CPU/memory, environment variables, and log drivers.
- Configured ALB with target groups per service, pathâbased routing, and HTTPS listener using ACMâissued certificates.
- Integrated Cognito user pool with hosted UI for signâup/signâin; added app clients for web and mobile.
- Built CI/CD pipeline: CodePipeline sourced from GitHub, CodeBuild ran unit tests and built Docker images, CodeDeploy (ECS) deployed new task definitions with blue/green deployment strategy.
- Enabled automated rollback on CloudWatch alarm thresholds (e.g., elevated 5XX errors or latency).
- Set up CloudWatch dashboards for realâtime monitoring of key metrics: request latency, error rates, database connections, cache hit ratio, and ETS CPU utilization.
- Enabled AWS XâRay tracing on NestJS services via AWS SDK; sampled traces to analyze latency bottlenecks.
Results
After eight weeks of intensive development and two weeks of performance testing and user acceptance testing (UAT), the platform was launched to a beta audience of 5,000 users. Key outcomes included:
- Page load times reduced from 4.5âŻseconds to an average of 1.2âŻseconds (static assets) and 1.8âŻseconds (dynamic API calls), exceeding the subâ2âsecond goal.
- During a simulated BlackâFriday traffic spike (50,000 concurrent virtual users), the system maintained 99.9% availability with average response time under 2.5âŻseconds; Aurora Serverless v2 scaled compute units automatically within 30âŻseconds.
- Mobile apps achieved 4.8âstar rating on iOS App Store and 4.6âstar on Google Play Store, with over 12,000 downloads in the first month.
- Deployment frequency increased from biâweekly manual releases to daily automated pushes; mean time to recovery (MTTR) dropped from 4âŻhours to under 15âŻminutes thanks to blue/green deployments and automated rollback.
- Operational costs decreased by 28% compared to the legacy VMâbased setup, primarily due to rightsizing, reserved instances for baseline workloads, and payâasâyouâgo pricing for serverless components.
- Conversion rate (visits to completed purchase) improved by 18% after launch, attributed to faster load times and smoother checkout flow.
- Customer support tickets related to performance issues fell by 72% in the first two months postâlaunch.
- The platform successfully integrated with the clientâs existing ERP system, synchronizing inventory levels every five minutes via a NestJSâbased middleware.
Metrics
Quantitative metrics collected over the first three months of production:
- **Requests per second (RSS):** Peak 12,400 RSS during flash sales; average 3,400 RSS.
- **Average latency:** 95th percentile API latency 1.6âŻseconds; 99th percentile 2.9âŻseconds.
- **Error rate:** <0.1% 5XX errors; 0.4% 4XX errors (mostly clientâside validation).
- **Database:** Aurora read replica lag <100âŻms; write throughput 2,400 writes/sec.
- **Cache:** ElastiCache hit ratio 92%; average get latency 1.2âŻms.
- **Mobile:** Crashâfree sessions 99.8%; average session length 4.7âŻminutes.
- **DevOps:** Lead time for changes <20âŻminutes; deployment failure rate 0.5%; time to restore service <10âŻminutes.
- **Business:** Gross merchandise volume (GMV) increased 34% quarterâoverâquarter; average order value (AOV) rose 12%; customer retention rate (30âday) improved from 62% to 71%.
Lessons Learned
1. **Invest in observability early.** Implementing distributed tracing (XâRay) and detailed logging from day one made it trivial to pinpoint latency issues during load testing.
2. **Choose the right scaling mechanism.** Aurora Serverless v2 proved ideal for unpredictable workloads, while fixedâsize Fargate services suited steadyâstate APIs. Mixing both optimized cost and performance.
3. **Automate database migrations.** Using TypeORM CLI with GitHub Actions ensured migrations were applied consistently across environments, preventing drift.
4. **Feature toggles reduce risk.** Launching dark features (e.g., new recommendation engine) behind flags allowed testing in production without affecting all users.
5. **Responsive design is nonânegotiable.** Prioritizing Flutterâs adaptive layout widgets saved significant rework when expanding to tablet and web form factors.
6. **Managed services â zero maintenance.** While AWS managed services reduced operational burden, they still required monitoring, capacity planning, and costâoptimization reviews.
7. **Crossâteam communication is crucial.** Regular syncs between backend, frontend, and DevOps teams prevented integration surprises and ensured that API contracts were respected.
8. **Performance budgeting guides development.** Setting explicit performance targets (e.g., <2âŻseconds API response) influenced architectural decisions such as caching strategies and payload sizes.
9. **Plan for data migration early.** Migrating legacy product and customer data required careful scripting and validation; allocating dedicated sprints for this avoided lastâminute rushes.
10. **Celebrate incremental wins.** Recognizing milestones (e.g., first successful blue/green deployment, achieving subâsecond latency) kept team morale high during a longâterm project.
Conclusion
By combining Flutterâs crossâplatform UI capabilities, NestJSâs modular backend architecture, and AWSâs scalable managed services, Webskyne delivered a modern eâcommerce platform that metâand exceededâthe clientâs expectations. The solution not only resolved immediate performance and scalability challenges but also positioned the business for future growth, enabling rapid feature releases, seamless omnichannel experiences, and a solid foundation for integrating emerging technologies such as AIâdriven personalization and augmented reality shopping. The project serves as a blueprint for retailers seeking to transition from legacy systems to cloudânative, composable commerce platforms.