dorm_example 2.0.0-dev.3
dorm_example: ^2.0.0-dev.3 copied to clipboard
A CLI that generates dORM example projects.
dorm_example #
dorm_example is a command-line generator for complete dORM showcase projects. It creates the annotated source, generated-code commands, application flow, and backend configuration for one selected engine.
Install the generator #
Install the executable globally:
dart pub global activate dorm_example
Check the available options:
dorm_example --help
Generate a project #
Choose one engine and, optionally, an output directory:
dorm_example --engine memory
dorm_example --engine postgres --output store_example
The output directory must be empty or must not exist. The generator does not overwrite existing files, run pub get, run build_runner, start Docker, or start the generated application.
Generated profiles #
| Profile | Application | Infrastructure |
|---|---|---|
| in-memory | Flutter Web | None |
| bloc | Flutter Web | None |
| firebase | Flutter Web | Firebase Emulator Suite |
| firestore | Flutter Web | Firebase Emulator Suite |
| http | Flutter Web | Local Dart HTTP server |
| postgres | Pure Dart | PostgreSQL in Docker Compose |
| mysql | Pure Dart | MySQL in Docker Compose |
| mongo | Pure Dart | MongoDB in Docker Compose |
| sqlite | Pure Dart | Local SQLite file |
All profiles use the same store domain with users, products, categories, carts, cart items, wishlists, and reviews. SQL profiles keep the model surface portable and avoid JSON-specific annotations such as ModelField, PolymorphicField, and DerivedField.
Run a generated project #
After generation, enter the output directory and follow the generated README. A typical pure Dart profile uses:
cd store_example
docker compose up -d
dart pub get
dart run build_runner build
dart analyze
dart run
A Flutter profile uses:
cd store_example
flutter pub get
dart run build_runner build
flutter analyze
flutter run -d chrome
Docker Compose starts infrastructure only. The Dart or Flutter application runs on the host so that local environment variables, browser access, and Flutter development tools remain available.
Backend configuration #
- PostgreSQL, MySQL, and MongoDB generate Docker Compose files, environment templates, and backend-specific startup instructions.
- SQLite generates sql/schema.sql and reads that rendered file when the application starts.
- Firebase and Firestore generate local Firebase Emulator configuration.
- HTTP generates a local in-memory Dart server and a configured HttpMapping.
- The in-memory and BLoC profiles run without an external service.
The generated .env.example file documents required variables. It is a reference file; the generated application does not load it automatically.
Modify the showcase #
Edit the generated lib/models.dart file when changing models. Then regenerate the model API:
dart run build_runner build --delete-conflicting-outputs
The generated *.dorm.dart and *.g.dart files are derived output. Keep the annotated source as the file you edit.
Troubleshooting #
- A non-empty output directory fails by design; choose another path or remove only the generated directory.
- A missing generated API means build_runner has not been run in the project root.
- A database profile cannot connect until its Compose service is running and its environment values match the generated configuration.
- A Flutter profile needs Flutter and a browser target installed.
- The HTTP profile requires its generated http-api service to be running.