DEV Community

Cover image for AWS re:Invent 2024 - Zero to production serverless in 8 weeks

AWS re:Invent 2024 - Zero to production serverless in 8 weeks

๐Ÿš€ Building an ADHD Prescription Integration Under Tight Deadlines Using Serverless Architecture ๐ŸŒ๐Ÿ’Š

In early 2024, we embarked on an exciting but challenging project at Chemist4U, the UK's third-largest online pharmacy dispensing an impressive 175,000โ€“200,000 items monthly. Our mission? To build a secure, scalable integration for a clinic specializing in ADHD diagnostics and treatment. This new system would replace the clinicโ€™s existing pharmacy partner, which struggled to scale alongside their growing demand.

With tight deadlines and high stakes, this project was a race against time to ensure patients could continue receiving critical medications without any interruption. Here's how we made it happen! ๐Ÿ’ช


๐ŸŽฏ The Challenge: What Did We Need to Solve?

We were tasked with building a comprehensive solution that tackled:

  • Secure Data Integration: A safe, reliable way to transfer sensitive patient and prescription data.
  • Regulatory Compliance: ADHD medications are highly controlled, requiring checks on patient history and strict adherence to UK regulations.
  • Seamless Payment Handling: Private prescriptions needed secure payment processing, while NHS prescriptions required accurate invoicing for reimbursements.
  • Customer Service Enablement: Equipping the support team with tools to answer patient inquiries effectively.
  • Warehouse Integration: Ensuring prescriptions were processed smoothly by our ERP and warehouse systems.

Deadline: Eight weeks โณ


๐Ÿ”ง Why Serverless?

Given the complexity and urgency, serverless architecture was the perfect choice. Here's why:

  1. โš™๏ธ Built-in High Availability: No need to manage uptimeโ€”itโ€™s baked in.
  2. ๐Ÿ“‰ Low Administration Overhead: Skip the headache of managing EC2 instances or Kubernetes.
  3. ๐Ÿš€ Rapid Development: Tools like AWS CDK allowed us to prototype and deploy features faster.
  4. ๐Ÿ“ˆ Auto Scaling: Effortlessly handle peaks and troughs in prescription volume.

Curious about serverless? Check out AWSโ€™s guide to serverless architecture. ๐ŸŒŸ


๐Ÿ’ก The Approach: Prototyping First

We skipped the proof of concept stage and dove straight into building a working prototype. Prototyping allowed us to test our ideas in real-world conditions while leaving room for rapid iterations.

๐Ÿ›  Tools and Technologies

  • AWS CDK: For Infrastructure as Code (IaC).
  • Vitest: Unit testing from Day 1 ensured reliability.
  • Biome: Automated linting and formatting saved valuable time.
  • Hexagonal Architecture: Enabled modular developmentโ€”essential for teamwork!
  • Serverless Framework: Combined with AWS Lambda, API Gateway, and DynamoDB for backend functionality.
  • React with Vite: For the front-end interface.

๐ŸŽ‰ Day 1 Wins!

By leveraging pre-built boilerplate code and automation tools, we launched:

  • A basic authenticated website using AWS Cognito.
  • A stubbed API with validation powered by API Gateway.
  • CI/CD pipelines for automated deployments.
  • Fully isolated developer environments for efficient parallel work.

๐Ÿ—๏ธ Building the Core Integration

The centerpiece of the system was the integration with the clinicโ€™s existing platform. Here's how we approached it:

1๏ธโƒฃ Defining Interfaces Early

To avoid delays, we deployed a stubbed API with validation using Swagger. This allowed the clinicโ€™s team to proceed with development in parallel.

2๏ธโƒฃ Validation Handling

Initially, we used API Gatewayโ€™s built-in validation. However, the generic error messages were a bottleneck during testing. Switching to Zod gave us:

  • Customizable validation messages.
  • Consistent logic reuse in TypeScript.
  • Cleaner, more actionable error handling.

โšก Infrastructure Setup with AWS CDK

Our serverless architecture consisted of:

  • API Gateway: Managed RESTful API endpoints.
  • Lambda Functions: Executed core business logic.
  • DynamoDB: Stored prescription and patient data securely.
  • S3 Buckets: Hosted the React front end and stored documents.

Want to learn CDK? Check out this CDK documentation. ๐Ÿ“š


๐ŸŒˆ Rapid Iterations with Serverless

Serverless enabled us to:

  • Quickly deploy isolated development environments.
  • Make reproducible changes using IaC.
  • Maintain stability with automated tests.

๐Ÿ›  Lessons Learned

๐Ÿ’ก Prototyping is Key: Starting with a working prototype minimized rework.

๐Ÿ’ก Better Error Handling Matters: Switching to Zod drastically improved testing efficiency.

๐Ÿ’ก Serverless Speeds Things Up: By offloading infrastructure management, we could focus on delivering business value.


๐ŸŽฏ The Result

In just 8 weeks, we delivered a fully functional system that:

  • Secured sensitive patient data ๐Ÿ”’.
  • Automated workflows adhering to strict regulations โœ….
  • Integrated seamlessly with the clinic and warehouse systems โšก.
  • Scaled to meet the growing demand for ADHD prescriptions ๐Ÿ“ˆ.

๐Ÿ“บ Original Video

Want to dive deeper into our process? Watch the original video on YouTube:

What do you think of our approach? Have you worked on similar tight-deadline projects? Let us know in the comments! ๐Ÿ‘‡

Top comments (0)