This codebase was created to demonstrate a fully fledged backend application built with Dart including CRUD operations, authentication, routing, pagination, and more.
We've gone to great lengths to adhere to the Dart community styleguides & best practices.
For more information on how to this works with other frontends/backends, head over to the RealWorld repo.
This is a monolithic application structured by components. It uses:
- PostgreSQL as the database, and uses some of it's specific features such as Arrays.
- SQL instead of an ORM. See for example.
- Docker Compose to run tests and the application locally. For the testing strategy, I opted to not use mocks and the such to unit test individual functions: instead, I applied a honeycomb testing strategy to run the tests against the actual app connected with an actual database. I felt that this:
- Gave me more confidence that the application is working correctly.
- Allowed me to refactor more easily as I test only the public interface and not the implementation details. This talk by Dan Abramov, for example, illustrates very well the importance of this.
- Github Actions to run tests on Pull Requests and Merges to the
master
branch.
Install the Dart SDK.
Create a .env
file according to the template.
$ ./dev.sh
$ ./test.sh
Deploy to Google Cloud Platform (GCP)
- Install terraform.
- Install the gcloud CLI.
- Login with gcloud.
- Go to the dev bootstrap directory, change the
locals.tf
values to your own and runterraform apply
. - Go the scripts directory and run
build-and-push-container-image.sh <YOUR_PROJECT_ID> <YOUR_ARTIFACT_REPOSITORY>
. - Go to the dev directory, change the
locals.tf
values to your own and runterraform apply
.