Discovering Zero to Production in Rust
Zero to Production in Rust is an in-depth guide designed to provide individuals with comprehensive knowledge of backend development using the Rust programming language. The project documents the developmental journey of creating an email newsletter application, showcasing the application’s evolution through each chapter of the accompanying book, "Zero To Production In Rust".
Exploring the Project
At its core, this project acts as a practical complement to the book, offering a real-world snapshot of a dynamic codebase. Each chapter in the book corresponds to a specific branch in the repository, enabling readers to follow the code's progression from basic to more advanced stages. For instance, users can observe snapshots for various chapters such as:
Each dedicated branch allows users to explore the developments implemented by the end of the respective chapters.
Prerequisites for Getting Started
To get started with this Rust project, certain software installations are necessary. Key requirements include:
- Rust: The primary programming language used.
- Docker: A tool to help streamline deploying applications by isolating them into containers.
Beyond installing these tools, additional requirements depend on the operating system:
- Windows Users: Need to install
cargo-binutils
,llvm-tools-preview
, and thesqlx-cli
. - Linux Users (Ubuntu and Arch): Required packages include
lld
,clang
,libssl-dev
, andpostgresql-client
. - MacOS Users: Installation of
zld
is necessary.
These tools and packages ensure a smoother development experience within the Rust environment.
Building the Project
Once all environmental requirements are met, building the project involves several steps:
- Initialize a Postgres Database: Use a Docker script (
./scripts/init_db.sh
) for setting up a PostgreSQL database. - Start Redis: Another Docker script (
./scripts/init_redis.sh
) sets up a Redis instance. - Compile the Code: Utilize Rust’s package manager, Cargo, to build the project (
cargo build
).
After starting the web server using cargo run
, you can view the application by visiting http://127.0.0.1:8000/login on your browser. An admin account is pre-set with the username "admin" and password "everythinghastostartsomewhere" for quick initial access.
Testing the Application
Testing forms a critical part of robust application development. The testing process mirrors the build setup:
- Initialize the Database and Redis: Repeat the steps for setting up Postgres and Redis using Docker.
- Execute Tests: Engage Cargo to run tests with the command (
cargo test
).
These steps ensure your application functions as intended, providing insights into possible bugs or areas to refine.
Conclusion
Zero to Production in Rust serves as an innovative gateway to mastering backend development with Rust. By walking through a complete journey of developing an email application, this project offers learners a practical, hands-on experience, supporting them as they transform theoretical knowledge into practical skills. The additional resources found in the book, alongside the detailed code snapshots in the repository, create a synergistic learning platform for aspiring backend developers.