• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 2 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fullstack RealWorld implementation using rust, axum, sqlx, and yew!

License: MIT CI Coverage Codecov

realworld_logo

A fullstack implementation of the RealWorld project using Rust, axum, sqlx, and yew.

To get started, install Docker and cargo-make on your local machine (Windows users may want to use WSL for ease of development), then clone/fork the repository. Once you have the project local to your machine, create an .env file local to workspace with valid values (you can use the defaults as well).

cp .env.example .env

Next, create and start our Docker containers:

cargo make docker

Once the application containers have started, verify all integration tests pass:

cargo make integration

The above target will run the included Postman suite of tests designed by the authors of the RealWorld project. Once the tests have completed, verify all unit tests are passing as well:

cargo make test

Again, the target above will run all included unit tests found in the project. To run the frontend project using trunk:

cargo make web

Project Structure

This project is more or less a Rust playground for myself and others to learn Rust, axum, and sqlx. We utilize cargo workspaces to help encapsulate project-specific logic/domains, with a rough organization strategy as follows:

  • crates/conduit-bin - API entry point, consisting of a single main.rs file to drive startup and wire library dependencies together
  • crates/conduit-web - (in progress) web frontend project utilizing yew
  • crates/conduit-api - web API project housing axum specific setup, endpoints, routing, request/response marshalling, etc.
  • crates/conduit-core - core logic and contract definitions between domains, services, and repository
  • crates/conduit-domain - a simple project to house PORS (plain old rust structs) used for API request and responses, services, etc.
  • crates/conduit-infrastructure - a project adapter containing implementations of the core business logics definitions from higher up
  • integrations - contains the RealWorld Postman test scripts and collection
  • cypress - contains the e2e tests used to test the frontend project (crates/conduit-web)
  • deploy - contains all Docker Compose files used for building the project containers
  • .husky - contains husky git hooks

Why is there package.json file?

I use husky for pre-commit hooks and lint-staged to format staged files to keep committed code well formatted. While there are a few other options for including pre-commit hooks into a Rust project, and certainly those that are more appropriate for Rust projects, I wanted to leave open the opportunity of bringing on a TS-based frontend sometime in the future to have the true RealWorld fullstack experience. The pre-commit hooks will format, lint, and test all code so that each commit ensure that tests are passing and code does not contain any obvious errors.

To bypass the included hooks, simply pass a --no-verify flag while committing code

git commit -m "feat(core): add some amazing unit tests" --no-verify

Using Docker

The project utilizes Docker containers for Postgres and Prometheus metrics, as well as containers for the API and frontend. For example, when starting the application with cargo make docker, navigating to localhost:9090 will bring you to the Prometheus metrics page. From there, running integration tests with cargo make integration to simulate traffic to the API allows one to observe the various metrics that are recorded in the service layer: request count, request latency, and histograms of service request intervals.

To start the API outside the Docker context, run:

cargo make dev # or cargo run

The dev tasks takes on the postgres task as a dependency, so your database container will start automatically.

If you're starting the application for the first time, it will attempt to seed a bit of data that is also used for testing.

TODO

There's a lot more unit tests to write...

More Repositories

1

BlazorConduit

A Medium clone written using .NET Core and Blazor!
C#
62
star
2

realworld-go-kit

Realworld implementation written with Go using Go kit!
Go
48
star
3

sveltekit-typescript-tailwind-template

A Sveltekit template project including TypeScript, Tailwind, and all your favorite dev tooling!
Svelte
21
star
4

StateManagementWithFluxor

Repository for my blog post on state management using Fluxor.
C#
20
star
5

nextjs-typescript-tailwind-template

A default Next.js project with boilerplate packages and configurations. Includes Tailwind, TypeScript (strict), ESLint, Prettier, and Husky.
TypeScript
17
star
6

Dappery

A Dapper-based .NET Core project for our favorite fictional brewery, Dappery.
C#
7
star
7

newswrap

Hacker News API bindings for Rust.
Rust
4
star
8

full-stack-rust

A demo project featuring Rust across the stack!
Dockerfile
2
star
9

nx-fullstack-realworld

A fullstack Nx-based project using Nest, Angular, and Postgres.
TypeScript
1
star
10

BlazorPortfolio

Portfolio built with Blazor WebAssembly
HTML
1
star
11

brewdude-go

An application to help users manage their trials and tribulations exploring the vast world of beer, written in Go!
Go
1
star
12

yew-tailwind-sandbox

A Yew project with Tailwind!
Rust
1
star
13

DecoupledControllersWithApiEndpoints

An example repository demoing the capability of ApiEndpoints.
C#
1
star
14

nrwl-react-take-home-assignment

Nrwl take home assignment for the React implementation.
TypeScript
1
star
15

axum-htmx-templates

HTML
1
star
16

joey-mckenzie-tech

Personal portfolio and blog.
Astro
1
star
17

nextjs-tailwind-typescript-template

TypeScript
1
star
18

realworld-fullstack-go-angular-scully

Realworld implementation of Conduit written with Go and Angular!
TypeScript
1
star
19

realworld-remix

A RealWorld implementation with Remix!
TypeScript
1
star
20

ExternalApisWithBlazor

Repository for my blog post on calling external APIs with client-side Blazor
C#
1
star
21

rusterview

LeetCode questions solved with Rust!
Rust
1
star