I created a simple app by very fast Rust web framework Actix web. Please use this as a sample code.

Background

Here’s a natural English translation of your text:

I believe it was last year when I had an interview at a company. As part of the technical assessment, I created a simple web application using Rust, React, and Next.js. Since I built it in just a few days specifically for the interview, it may not be highly polished, but I aimed to make it as robust as possible for production use. Therefore, I think it could be a good reference for those looking to create something with Actix web. The application uses Next.js for SSG, so it should load quickly.

Every time I start a new development project, I find it tedious to repeatedly implement the same things, like the Docker Compose YAML file, API handlers, and Next.js configurations. I also often find myself wondering, “How did I do that again?” Because of this, I think developing based on this working project could save time.

Although I didn’t end up joining the company, I wanted to share this repository with everyone instead of letting it go unused. I’ve removed any parts related to that company and erased them from the Git history as well.

However, one of the interview conditions was not to use any ORM libraries (such as Diesel), so there are no ORMs included. If you plan to use this as a reference, please keep this in mind, and you’ll likely need to incorporate Diesel or another ORM if you build upon it.

Lastly, please don’t use the test code as a reference—it’s something I put together quickly under time constraints. I’m sharing this purely as a reference.

By the way, it seems that Actix web, the Rust web framework, is incredibly fast. A few years ago, it topped the charts in the benchmark below.
https://www.techempower.com/benchmarks/#hw=ph&test=fortune&section=data-r22

Although its ranking has dropped quite a bit, as of August 15, 2024, Actix ecosystem’s actix-http is still in 12th place. It’s probably still one of the faster frameworks, especially among the more mature ones.

How to use

This is witten in the Readme.md too:

$ git clone https://github.com/lechatthecat/assignment
$ cd assignment
$ docker compose up --build -d
Enter fullscreen mode Exit fullscreen mode

This will start release build of the Rust code. When it is done, you can access the app from this URL.
http://localhost/login

Please use the following information to login.
name: test_user1
password: password

For development

If you want to use the docker compose file for development:

$ docker compose -f docker-compose-dev.yml up -d --build
Enter fullscreen mode Exit fullscreen mode

What does the app do?

Structure

The app is divided into an API server built with Actix web and a React + Next.js application that calls it. To see which APIs are available, please refer to the API handlers.
https://github.com/lechatthecat/assignment/blob/main/simple_restaurant_api/src/api/api_handler/handlers.rs

The API server, Nginx, and PostgreSQL are each set up as separate containers using Docker Compose. Ideally, the API server container and the client container should be separated, but for the sake of simplifying development, I’ve combined them. If you use this as a reference for your own development, I recommend separating the API server container and the client container.

Overview

This is a simple SPA (though technically it’s SSG with Next.js, so I’m not sure if SPA is the right term) designed for use in a restaurant with 10 tables. The idea is that each waiter has a tablet, and when taking orders, they first select the table from which the order is being placed.

Image description

After selecting the table, you’ll be taken to a screen showing the list of currently received orders for that table.

Image description

When you press “Menu,” you’ll be taken to a page displaying the full menu, where you can click on the items that have been ordered. Each menu item includes the price and the estimated time until it’s ready. By pressing “Add this to order,” you can add the selected menu item to the list of received orders.

Image description

Once you add an order, a real-time countdown begins until the preparation is complete. When it reaches zero, the waiter is expected to go to the kitchen to pick up the dish and serve it to the customer at that table. You can also see the estimated time when the dish will be ready.

Image description

To be honest, the functionality itself isn’t anything special. As I mentioned before, I built this in just a few days for an interview, so I only implemented the bare minimum.

Things that could be added:

As mentioned in the README, here are some things that should be added as a to-do:

  • There’s no API documentation, so I think it would be good to integrate Swagger to document that part.
  • Introducing API-side caching with Redis or using a CDN like Cloudflare could reduce server load. Since this is intended for internal use, the load shouldn’t be too heavy, so I skipped it for now, but for an app that is publicly available, caching would likely be necessary.
  • The implementation on the Next.js side doesn’t really consider other people using it, but the focus of the interview was mainly on the API implementation.
  • Ideally, before actually sending the order to the kitchen, there should be a confirmation step where the customer is asked, “Is this your order?” So, a feature to temporarily hold the order (without sending it to the kitchen) would be good. However, since this would require additional front-end development and the interview was primarily focused on the API, I decided to skip it.

Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Download ladies market (2021) full movie mp4 – livelihoods intersect in a “ladies market” in hong kong.