This codebase was created to demonstrate a fully fledged backend application built with Dart-Shelf including CRUD operations, authentication, routing, pagination, and more. I've gone to great lengths to adhere to the Dart community style guides & best practices.
This is a monolithic application structures by components. It uses:
- Dart a client-optimized language for fast apps on any platform.
- Shelf a server app using package:shelf.
- PostgreSQL as the database, and uses some of it's specific features such as Arrays.
- SQL instead of an ORM.
- 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
main
branch.
For more detailed information in pubspec.yml
- Install Dart SDK.
- Clone this project.
- On terminal project run
dart pub get
. - Create a
.env
file according to the example.
## RUN THE APP
$ ./dev.sh
## RUN THE TEST
$ ./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 run terraform apply.