Skip to content

Quart codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

Notifications You must be signed in to change notification settings

marcusmonteirodesouza/realworld-python-quart-sql

Repository files navigation

RealWorld Example App

Quart codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a fully fledged backend application built with Quart including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the Quart community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

How it works

Getting started

Pre-Requisites

  1. Install Docker.
  2. Install GNU Make. It is used to run scripts.
  3. Install Poetry.
  4. Run poetry install.

Running

To start the server, you can run:

make run

It will stand up a PostgreSQL container using Docker Compose and run the Quart application using Poetry.

Testing

The approach I followed is this:

  1. I only test the external API.
  2. I don't mock things that are under my control, such as databases.

I believe that doing so allow for:

  1. More opportunities for refactoring. Testing only the external API and not any of the internals allowed me more freedom to move things around, provided the tests keep green.
  2. More confidence that the application actually works.

To run the tests, you can run:

make test

It uses pytest with pytest-asyncio as the test runner.

You can also run the API tests from the realworld repository by running:

make api-test

It requires that you install Node.js.

Deployment

System Architecture

System Architecture Diagram

Components

  1. HTTPS Load Balancer.
  2. A Cloud Run service running the application as a Docker container.
  3. A Cloud SQL instance running PostgreSQL.

Deployment

  1. Install terraform.
  2. Install openssl. The deployment generates and uses certificates to connect with the Cloud SQL using SSL/TLS and run migrations using flyway.
  3. Have registered domain. You will need to connect your domain to set up HTTPS.
  4. cd into deployment/google-cloud/terraform.
  5. Run terraform init.
  6. Run terraform apply.

About

Quart codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages