# lukemathwalker/zero-to-production

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/lukemathwalker-zero-to-production).**

6,486 stars · 588 forks · Rust · Apache-2.0

## Links

- GitHub: https://github.com/LukeMathWalker/zero-to-production
- Homepage: https://www.zero2prod.com
- awesome-repositories: https://awesome-repositories.com/repository/lukemathwalker-zero-to-production.md

## Topics

`book` `rust`

## Description

This project is a reference implementation of a production-ready backend API built with Rust and the Actix-Web framework. It serves as a codebase demonstrating the development of a newsletter subscription service, encompassing the management of subscriber sign-ups, email confirmations, and campaign delivery.

The project highlights a layered architecture that separates concerns into handler, service, and repository layers. It utilizes an actor-based concurrency model for handling HTTP requests and employs trait-based abstractions to decouple business logic from external dependencies, such as email service providers.

The implementation features a PostgreSQL backend using an asynchronous database driver with compile-time SQL query validation and connection pooling. It includes a comprehensive integration test suite that uses isolated database instances for each test and implements environment-based configuration for deployment across different stages.

## Tags

### Content Management & Publishing

- [Newsletter Platforms](https://awesome-repositories.com/f/content-management-publishing/blog-newsletter-publishing/newsletter-platforms.md) — Provides a full backend system for managing email subscriber lists, sign-ups, and campaign delivery.
- [Newsletter Management APIs](https://awesome-repositories.com/f/content-management-publishing/headless-api-driven-services/content-management-apis/newsletter-management-apis.md) — Provides a backend API for managing newsletter subscriber sign-ups, confirmations, and campaign delivery.

### Web Development

- [Actix-Web Applications](https://awesome-repositories.com/f/web-development/actix-web-applications.md) — Implements a production-ready backend API using the Actix-Web framework.
- [Rust Web Frameworks](https://awesome-repositories.com/f/web-development/rust-web-frameworks.md) — Builds a production-ready backend API using the Rust programming language.
- [Backend Service Architectures](https://awesome-repositories.com/f/web-development/web-application-frameworks/backend-service-architectures.md) — Structures the web service using Actix-Web with a layered approach to handlers and services.

### Business & Productivity Software

- [Email Campaign Managers](https://awesome-repositories.com/f/business-productivity-software/email-campaign-managers.md) — Delivers newsletter content to subscriber lists through integrated email service providers. ([source](https://www.zero2prod.com))
- [Subscriber Verification Workflows](https://awesome-repositories.com/f/business-productivity-software/subscriber-verification-workflows.md) — Handles the complete subscriber workflow, including sign-up and email confirmation processes. ([source](https://www.zero2prod.com))

### Data & Databases

- [Asynchronous Database Drivers](https://awesome-repositories.com/f/data-databases/asynchronous-database-drivers.md) — Utilizes an asynchronous Rust driver for non-blocking communication with the PostgreSQL backend.
- [Relational Database Backends](https://awesome-repositories.com/f/data-databases/external-storage-connectors/relational-database-backends.md) — Uses PostgreSQL as the primary relational database for persisting subscriber and application state.
- [PostgreSQL Integrations](https://awesome-repositories.com/f/data-databases/postgresql-integrations.md) — Integrates Rust with PostgreSQL using SQLx for asynchronous data persistence.
- [PostgreSQL Pool Managers](https://awesome-repositories.com/f/data-databases/connection-pools/postgresql-pool-managers.md) — Provides specialized connection pooling for asynchronous PostgreSQL database connections.
- [Compile-Time Validated Backends](https://awesome-repositories.com/f/data-databases/connection-pools/postgresql-pool-managers/compile-time-validated-backends.md) — Integrates a PostgreSQL backend with SQLx for asynchronous connection pooling and compile-time SQL query validation.
- [Database Integration Testing](https://awesome-repositories.com/f/data-databases/database-orchestration/test-database-provisioners/database-integration-testing.md) — Utilizes dedicated, isolated database instances to validate end-to-end API behavior during integration testing.
- [Connection Pooling](https://awesome-repositories.com/f/data-databases/high-concurrency-database-access/connection-pooling.md) — Maintains a cache of open database connections to optimize concurrent request handling.

### Software Engineering & Architecture

- [Service Layers](https://awesome-repositories.com/f/software-engineering-architecture/service-layers.md) — Implements a service layer to decouple business logic from HTTP handlers and database repositories.
- [Layered Architectures](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/layering-presentation/layered-architectures.md) — Organizes the application into distinct handler, service, and repository layers to separate concerns.
- [Actor-Based Concurrency](https://awesome-repositories.com/f/software-engineering-architecture/actor-based-concurrency.md) — Implements a concurrency model using isolated actors for processing asynchronous HTTP requests.
- [Environment Variable-Based Configuration](https://awesome-repositories.com/f/software-engineering-architecture/application-lifecycle-management/configuration-management/environment-variable-management/environment-variables/environment-variable-based-configuration.md) — Injects application settings via environment variables and files for multi-stage deployment.
- [Trait-Based Service Abstractions](https://awesome-repositories.com/f/software-engineering-architecture/trait-based-service-abstractions.md) — Uses Rust traits to define generic interfaces for external services, allowing easy implementation swapping.

### DevOps & Infrastructure

- [Production Environment Configurations](https://awesome-repositories.com/f/devops-infrastructure/infrastructure/configuration-policy-enforcement/production-environment-configurations.md) — Manages application settings specifically tuned for stability and performance in production environments.

### Testing & Quality Assurance

- [API Testing](https://awesome-repositories.com/f/testing-quality-assurance/api-network-testing/api-testing.md) — Includes automated tests to verify the correctness and error handling of HTTP API endpoints. ([source](https://www.zero2prod.com))
- [Integration Test Suites](https://awesome-repositories.com/f/testing-quality-assurance/automated-test-suites/integration-test-suites.md) — Ships a comprehensive integration test suite using HTTP client assertions and database state verification.
- [Compile-Time Query Validation](https://awesome-repositories.com/f/testing-quality-assurance/compile-time-query-validation.md) — Implements compile-time validation of SQL queries against the actual database schema.
- [End-to-End Testing](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/e2e-integration-testing/end-to-end-testing.md) — Implements automated test suites that validate API behavior using isolated database instances.
- [Isolated Database Tests](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/e2e-integration-testing/end-to-end-testing/isolated-database-tests.md) — Runs end-to-end API tests against dedicated per-test database instances to prevent state leakage.
- [SQL Query Validators](https://awesome-repositories.com/f/testing-quality-assurance/validation-verification/input-validation/compile-time-validators/sql-query-validators.md) — Verifies SQL queries against the live database schema during compilation to catch errors early.

### Part of an Awesome List

- [Books](https://awesome-repositories.com/f/awesome-lists/more/books.md) — Listed in the “Books” section of the Rust Learning awesome list.
