├── movieapp_flutter ├── linux │ ├── .gitignore │ ├── main.cc │ ├── flutter │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugins.cmake │ │ └── CMakeLists.txt │ └── my_application.h ├── ios │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner.xcodeproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ ├── RunnerTests │ │ └── RunnerTests.swift │ ├── .gitignore │ └── Podfile ├── android │ ├── gradle.properties │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── values │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── values-night │ │ │ │ │ │ └── styles.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ └── movieapp_flutter │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── build.gradle │ └── settings.gradle ├── macos │ ├── Runner │ │ ├── Configs │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ ├── Warnings.xcconfig │ │ │ └── AppInfo.xcconfig │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ ├── app_icon_64.png │ │ │ │ ├── app_icon_1024.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Release.entitlements │ │ ├── DebugProfile.entitlements │ │ ├── MainFlutterWindow.swift │ │ └── Info.plist │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner.xcodeproj │ │ └── project.xcworkspace │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── RunnerTests │ │ └── RunnerTests.swift │ └── Podfile ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── manifest.json │ └── index.html ├── lib │ ├── core │ │ ├── error │ │ │ ├── failure.dart │ │ │ └── exceptions.dart │ │ ├── entities │ │ │ └── user.dart │ │ ├── utils │ │ │ ├── show_snackbar.dart │ │ │ └── strings.dart │ │ ├── usecases │ │ │ └── usecase.dart │ │ ├── widgets │ │ │ └── loader.dart │ │ └── router │ │ │ └── app_router.dart │ ├── features │ │ ├── movie │ │ │ ├── presentation │ │ │ │ ├── bloc │ │ │ │ │ ├── movie_list │ │ │ │ │ │ ├── movie_list_event.dart │ │ │ │ │ │ ├── movie_list_state.dart │ │ │ │ │ │ └── movie_list_bloc.dart │ │ │ │ │ ├── movie_detail │ │ │ │ │ │ ├── movie_detail_event.dart │ │ │ │ │ │ ├── movie_detail_state.dart │ │ │ │ │ │ └── movie_detail_bloc.dart │ │ │ │ │ └── movie_manage │ │ │ │ │ │ ├── movie_manage_event.dart │ │ │ │ │ │ ├── movie_manage_state.dart │ │ │ │ │ │ └── movie_manage_bloc.dart │ │ │ │ ├── pages │ │ │ │ │ ├── movie_list_page.dart │ │ │ │ │ └── movie_detail_page.dart │ │ │ │ └── widgets │ │ │ │ │ └── movie_list_widget.dart │ │ │ ├── domain │ │ │ │ ├── repositories │ │ │ │ │ └── movie_repository.dart │ │ │ │ └── usecases │ │ │ │ │ ├── list_movies.dart │ │ │ │ │ ├── delete_movie.dart │ │ │ │ │ ├── save_movie.dart │ │ │ │ │ └── retrieve_movie.dart │ │ │ └── data │ │ │ │ ├── datasources │ │ │ │ └── movie_datasource.dart │ │ │ │ └── repositories │ │ │ │ └── movie_repository_impl.dart │ │ ├── auth │ │ │ ├── data │ │ │ │ ├── models │ │ │ │ │ └── user_model.dart │ │ │ │ └── repositories │ │ │ │ │ └── auth_repository_impl.dart │ │ │ ├── domain │ │ │ │ ├── usecases │ │ │ │ │ ├── user_logout.dart │ │ │ │ │ ├── current_user.dart │ │ │ │ │ ├── user_login.dart │ │ │ │ │ ├── user_register.dart │ │ │ │ │ └── user_confirm_registration.dart │ │ │ │ └── respositories │ │ │ │ │ └── auth_repository.dart │ │ │ └── presentation │ │ │ │ └── bloc │ │ │ │ ├── auth_state.dart │ │ │ │ └── auth_event.dart │ │ ├── asset │ │ │ ├── presentation │ │ │ │ ├── bloc │ │ │ │ │ ├── asset_event.dart │ │ │ │ │ ├── asset_state.dart │ │ │ │ │ └── asset_bloc.dart │ │ │ │ └── widgets │ │ │ │ │ └── upload_file_widget.dart │ │ │ ├── domain │ │ │ │ ├── repositories │ │ │ │ │ └── asset_repository.dart │ │ │ │ └── usecases │ │ │ │ │ └── upload_image.dart │ │ │ └── data │ │ │ │ ├── repositories │ │ │ │ └── asset_repository_impl.dart │ │ │ │ └── datasources │ │ │ │ └── asset_data_source.dart │ │ └── app_user │ │ │ └── presentation │ │ │ ├── cubits │ │ │ └── cubit │ │ │ │ ├── app_user_state.dart │ │ │ │ └── app_user_cubit.dart │ │ │ └── widgets │ │ │ └── app_user_dropdown.dart │ └── main.dart ├── windows │ ├── runner │ │ ├── resources │ │ │ └── app_icon.ico │ │ ├── resource.h │ │ ├── utils.h │ │ ├── runner.exe.manifest │ │ ├── flutter_window.h │ │ ├── main.cpp │ │ ├── CMakeLists.txt │ │ ├── utils.cpp │ │ └── flutter_window.cpp │ ├── .gitignore │ └── flutter │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugin_registrant.cc │ │ └── generated_plugins.cmake ├── README.md ├── test │ └── widget_test.dart ├── .gitignore ├── analysis_options.yaml └── .metadata ├── movieapp_server ├── deploy │ ├── aws │ │ ├── terraform │ │ │ ├── .gitignore │ │ │ ├── main.tf │ │ │ ├── vpc.tf │ │ │ ├── init-script.sh │ │ │ ├── cloudfront-web-staging.tf │ │ │ ├── staging.tf │ │ │ ├── cloudfront-web.tf │ │ │ ├── storage.tf │ │ │ ├── database.tf │ │ │ ├── redis.tf │ │ │ ├── code-deploy.tf │ │ │ └── instances.tf │ │ └── scripts │ │ │ ├── run_serverpod │ │ │ ├── install_dependencies │ │ │ ├── appspec.yml │ │ │ └── start_server │ └── gcp │ │ ├── terraform_gce │ │ ├── .gitignore │ │ ├── variables.tf │ │ ├── config.auto.tfvars │ │ └── main.tf │ │ └── console_gcr │ │ └── cloud-run-deploy.sh ├── CHANGELOG.md ├── config │ ├── generator.yaml │ ├── development.yaml │ ├── production.yaml │ └── staging.yaml ├── lib │ ├── src │ │ ├── models │ │ │ ├── movie.yaml │ │ │ └── example.spy.yaml │ │ ├── generated │ │ │ ├── protocol.yaml │ │ │ └── example.dart │ │ ├── web │ │ │ ├── widgets │ │ │ │ └── default_page_widget.dart │ │ │ └── routes │ │ │ │ └── root.dart │ │ ├── endpoints │ │ │ ├── asset_endpoint.dart │ │ │ ├── movie_endpoint.dart │ │ │ └── example_endpoint.dart │ │ └── future_calls │ │ │ └── example_future_call.dart │ └── server.dart ├── .gcloudignore ├── bin │ └── main.dart ├── .gitignore ├── migrations │ ├── 20240418142408454 │ │ └── definition_project.json │ ├── migration_registry.txt │ ├── 20240418143611250 │ │ ├── migration.sql │ │ ├── migration.json │ │ └── definition_project.json │ ├── 20240418143756623 │ │ ├── migration.sql │ │ ├── definition_project.json │ │ └── migration.json │ └── 20240422145132179 │ │ └── definition_project.json ├── pubspec.yaml ├── generated │ └── tables.pgsql ├── README.md ├── docker-compose.yaml ├── Dockerfile ├── web │ ├── templates │ │ └── default.html │ └── static │ │ ├── css │ │ └── style.css │ │ └── images │ │ └── background.svg └── analysis_options.yaml ├── movieapp_client ├── CHANGELOG.md ├── lib │ ├── movieapp_client.dart │ └── src │ │ └── protocol │ │ ├── example.dart │ │ └── protocol.dart ├── dartdoc_options.yaml ├── README.md ├── pubspec.yaml ├── .gitignore ├── analysis_options.yaml └── doc │ └── endpoint.md └── .github └── workflows └── deployment-aws.yml /movieapp_flutter/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform/ 2 | -------------------------------------------------------------------------------- /movieapp_server/deploy/gcp/terraform_gce/.gitignore: -------------------------------------------------------------------------------- 1 | credentials.json 2 | .terraform 3 | -------------------------------------------------------------------------------- /movieapp_client/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.0 2 | 3 | - Initial version, created by Stagehand 4 | -------------------------------------------------------------------------------- /movieapp_server/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.0 2 | 3 | - Initial version, created by Stagehand 4 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /movieapp_flutter/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /movieapp_client/lib/movieapp_client.dart: -------------------------------------------------------------------------------- 1 | export 'src/protocol/protocol.dart'; 2 | export 'package:serverpod_client/serverpod_client.dart'; 3 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /movieapp_flutter/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/web/favicon.png -------------------------------------------------------------------------------- /movieapp_client/dartdoc_options.yaml: -------------------------------------------------------------------------------- 1 | dartdoc: 2 | categories: 3 | "Endpoint": 4 | markdown: doc/endpoint.md 5 | name: Endpoint -------------------------------------------------------------------------------- /movieapp_flutter/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /movieapp_flutter/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/web/icons/Icon-192.png -------------------------------------------------------------------------------- /movieapp_flutter/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/web/icons/Icon-512.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /movieapp_server/config/generator.yaml: -------------------------------------------------------------------------------- 1 | type: server 2 | 3 | client_package_path: ../movieapp_client 4 | 5 | 6 | modules: 7 | serverpod_auth: 8 | nickname: auth -------------------------------------------------------------------------------- /movieapp_flutter/lib/core/error/failure.dart: -------------------------------------------------------------------------------- 1 | class Failure { 2 | final String message; 3 | const Failure([this.message = "An unexpected error occurred."]); 4 | } 5 | -------------------------------------------------------------------------------- /movieapp_flutter/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /movieapp_flutter/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /movieapp_flutter/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /movieapp_flutter/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /movieapp_server/lib/src/models/movie.yaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | class: Movie 4 | table: movie 5 | 6 | fields: 7 | title: String 8 | year: int 9 | imageUrl: String 10 | logline: String 11 | directorName: String -------------------------------------------------------------------------------- /movieapp_client/README.md: -------------------------------------------------------------------------------- 1 | # movieapp_client 2 | 3 | This is your Serverpod client. The code in here is mostly generated by 4 | Serverpod, but you may want to make changes if you are adding modules to your 5 | project. 6 | -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /movieapp_server/lib/src/generated/protocol.yaml: -------------------------------------------------------------------------------- 1 | asset: 2 | - getUploadDescription: 3 | - verifyUpload: 4 | example: 5 | - hello: 6 | movie: 7 | - list: 8 | - retrieve: 9 | - save: 10 | - delete: 11 | -------------------------------------------------------------------------------- /movieapp_server/.gcloudignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .dart_tool/ 3 | .packages 4 | 5 | # Conventional directory for build outputs 6 | build/ 7 | 8 | # Directory created by dartdoc 9 | doc/api/ 10 | -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/kotlin/com/example/movieapp_flutter/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.movieapp_flutter 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() 6 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /movieapp_flutter/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tylersavery/serverpod-clean-architecture/HEAD/movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/bloc/movie_list/movie_list_event.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | 3 | @immutable 4 | sealed class MovieListEvent {} 5 | 6 | final class FetchMoviesEvent extends MovieListEvent {} 7 | -------------------------------------------------------------------------------- /movieapp_client/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: movieapp_client 2 | description: Starting point for a Serverpod client. 3 | 4 | environment: 5 | sdk: '>=3.0.0 <4.0.0' 6 | 7 | dependencies: 8 | serverpod_client: 1.2.6 9 | serverpod_auth_client: 1.2.6 10 | -------------------------------------------------------------------------------- /movieapp_server/bin/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:movieapp_server/server.dart'; 2 | 3 | /// This is the starting point for your Serverpod server. Typically, there is 4 | /// no need to modify this file. 5 | void main(List args) { 6 | run(args); 7 | } 8 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/core/entities/user.dart: -------------------------------------------------------------------------------- 1 | class User { 2 | final int id; 3 | final String email; 4 | final String username; 5 | 6 | const User({ 7 | required this.id, 8 | required this.email, 9 | required this.username, 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /movieapp_server/.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .dart_tool/ 3 | .packages 4 | 5 | # Conventional directory for build outputs 6 | build/ 7 | 8 | # Directory created by dartdoc 9 | doc/api/ 10 | 11 | # Passwords file 12 | config/passwords.yaml 13 | -------------------------------------------------------------------------------- /movieapp_flutter/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip 6 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/core/error/exceptions.dart: -------------------------------------------------------------------------------- 1 | class ServerException implements Exception { 2 | final String message; 3 | const ServerException([this.message = "A problem occurred."]); 4 | 5 | @override 6 | String toString() { 7 | return message; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/core/utils/show_snackbar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void showSnackbar(BuildContext context, String message) { 4 | ScaffoldMessenger.of(context).showSnackBar( 5 | SnackBar( 6 | content: Text(message), 7 | ), 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /movieapp_server/migrations/20240418142408454/definition_project.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleName": "movieapp", 3 | "tables": [], 4 | "installedModules": [ 5 | { 6 | "module": "serverpod", 7 | "version": "20240115074235544" 8 | } 9 | ], 10 | "migrationApiVersion": 1 11 | } -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/auth/data/models/user_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:movieapp_flutter/core/entities/user.dart'; 2 | 3 | class UserModel extends User { 4 | const UserModel({ 5 | required super.id, 6 | required super.email, 7 | required super.username, 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/core/usecases/usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_flutter/core/error/failure.dart'; 3 | 4 | abstract interface class UseCase { 5 | Future> call(Params params); 6 | } 7 | 8 | class NoParams {} 9 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/core/utils/strings.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | String generateRandomString(int len) { 4 | var r = Random(); 5 | const chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890'; 6 | return List.generate(len, (index) => chars[r.nextInt(chars.length)]).join(); 7 | } 8 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/asset/presentation/bloc/asset_event.dart: -------------------------------------------------------------------------------- 1 | part of 'asset_bloc.dart'; 2 | 3 | @immutable 4 | sealed class AssetEvent {} 5 | 6 | final class AssetUploadImageEvent extends AssetEvent { 7 | final XFile image; 8 | 9 | AssetUploadImageEvent({required this.image}); 10 | } 11 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /movieapp_server/lib/src/web/widgets/default_page_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:serverpod/serverpod.dart'; 2 | 3 | class DefaultPageWidget extends Widget { 4 | DefaultPageWidget() : super(name: 'default') { 5 | values = { 6 | 'served': DateTime.now(), 7 | 'runmode': Serverpod.instance.runMode, 8 | }; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/bloc/movie_detail/movie_detail_event.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | 3 | @immutable 4 | sealed class MovieDetailEvent {} 5 | 6 | final class MovieDetailRetrieveEvent extends MovieDetailEvent { 7 | final int id; 8 | MovieDetailRetrieveEvent({required this.id}); 9 | } 10 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/core/widgets/loader.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class Loader extends StatelessWidget { 4 | const Loader({ 5 | super.key, 6 | }); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return const Center( 11 | child: CircularProgressIndicator(), 12 | ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/app_user/presentation/cubits/cubit/app_user_state.dart: -------------------------------------------------------------------------------- 1 | part of 'app_user_cubit.dart'; 2 | 3 | @immutable 4 | sealed class AppUserState {} 5 | 6 | final class AppUserInitial extends AppUserState {} 7 | 8 | final class AppUserLoggedIn extends AppUserState { 9 | final User user; 10 | AppUserLoggedIn(this.user); 11 | } 12 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/asset/domain/repositories/asset_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:image_picker/image_picker.dart'; 3 | import 'package:movieapp_flutter/core/error/failure.dart'; 4 | 5 | abstract interface class AssetRepository { 6 | Future> uploadImage({required XFile image}); 7 | } 8 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /movieapp_client/.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .dart_tool/ 3 | .packages 4 | 5 | # Omit commiting pubspec.lock for library packages: 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock 7 | pubspec.lock 8 | 9 | # Conventional directory for build outputs 10 | build/ 11 | 12 | # Directory created by dartdoc 13 | doc/api/ 14 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/main.tf: -------------------------------------------------------------------------------- 1 | # Terraform and AWS setup 2 | 3 | terraform { 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 4.13" 8 | } 9 | } 10 | 11 | required_version = ">= 1.1.9" 12 | } 13 | 14 | provider "aws" { 15 | # profile = "default" 16 | region = var.aws_region 17 | } 18 | -------------------------------------------------------------------------------- /movieapp_flutter/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /movieapp_server/lib/src/web/routes/root.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:movieapp_server/src/web/widgets/default_page_widget.dart'; 4 | import 'package:serverpod/serverpod.dart'; 5 | 6 | class RouteRoot extends WidgetRoute { 7 | @override 8 | Future build(Session session, HttpRequest request) async { 9 | return DefaultPageWidget(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/scripts/run_serverpod: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | RUNMODE=$(cat /home/ec2-user/runmode) 3 | SERVER_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) 4 | cd /home/ec2-user/serverpod/active/movieapp_server 5 | /usr/lib/dart/bin/dart --old_gen_heap_size=0 run bin/main.dill --mode $RUNMODE --server-id $SERVER_ID > /home/ec2-user/serverpod.log 2> /home/ec2-user/serverpod.err 6 | -------------------------------------------------------------------------------- /movieapp_server/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: movieapp_server 2 | description: Starting point for a Serverpod server. 3 | # version: 1.0.0 4 | # homepage: https://www.example.com 5 | 6 | environment: 7 | sdk: '>=3.0.0 <4.0.0' 8 | 9 | dependencies: 10 | serverpod: 1.2.6 11 | serverpod_auth_server: 1.2.6 12 | serverpod_cloud_storage_s3: ^1.2.6 13 | 14 | dev_dependencies: 15 | lints: ^3.0.0 16 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /movieapp_flutter/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /movieapp_flutter/android/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | rootProject.buildDir = '../build' 9 | subprojects { 10 | project.buildDir = "${rootProject.buildDir}/${project.name}" 11 | } 12 | subprojects { 13 | project.evaluationDependsOn(':app') 14 | } 15 | 16 | tasks.register("clean", Delete) { 17 | delete rootProject.buildDir 18 | } 19 | -------------------------------------------------------------------------------- /movieapp_server/migrations/migration_registry.txt: -------------------------------------------------------------------------------- 1 | ### AUTOMATICALLY GENERATED DO NOT MODIFY 2 | ### 3 | ### This file is generated by Serverpod when creating a migration, do not modify it 4 | ### manually. If a collision is detected in this file when doing a code merge, resolve 5 | ### the conflict by removing and recreating the conflicting migration. 6 | 7 | 20240418142408454 8 | 20240418143611250 9 | 20240418143756623 10 | 20240422145132179 11 | -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /movieapp_server/generated/tables.pgsql: -------------------------------------------------------------------------------- 1 | /* 2 | This file is no longer used. Version 1.2.0 and above use the new migration 3 | system to manage the database schema. 4 | 5 | Run "serverpod create-migration" to create a new migration. 6 | 7 | Run "dart bin/main.dart --role maintenance --apply-migrations" to apply the migration. 8 | 9 | See the official documentation for more information: 10 | https://docs.serverpod.dev/concepts/database/migrations 11 | */ -------------------------------------------------------------------------------- /movieapp_client/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # Defines a default set of lint rules enforced for 2 | # projects at Google. For details and rationale, 3 | # see https://github.com/dart-lang/pedantic#enabled-lints. 4 | 5 | # For lint rules and documentation, see http://dart-lang.github.io/linter/lints. 6 | # Uncomment to specify additional rules. 7 | # linter: 8 | # rules: 9 | # - camel_case_types 10 | 11 | analyzer: 12 | # exclude: 13 | # - path/to/excluded/files/** 14 | -------------------------------------------------------------------------------- /movieapp_flutter/README.md: -------------------------------------------------------------------------------- 1 | # movieapp_flutter 2 | 3 | A new Flutter project with Serverpod. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application that is using 8 | Serverpod. 9 | 10 | A great starting point for learning Serverpod is our documentation site at: 11 | [https://docs.serverpod.dev](https://docs.serverpod.dev). 12 | 13 | To run the project, first make sure that the server is running, then do: 14 | 15 | flutter run 16 | -------------------------------------------------------------------------------- /movieapp_server/README.md: -------------------------------------------------------------------------------- 1 | # movieapp_server 2 | 3 | This is the starting point for your Serverpod server. 4 | 5 | To run your server, you first need to start Postgres and Redis. It's easiest to do with Docker. 6 | 7 | docker compose up --build --detach 8 | 9 | Then you can start the Serverpod server. 10 | 11 | dart bin/main.dart 12 | 13 | When you are finished, you can shut down Serverpod with `Ctrl-C`, then stop Postgres and Redis. 14 | 15 | docker compose stop 16 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /movieapp_flutter/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/domain/repositories/movie_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | 3 | import 'package:movieapp_client/movieapp_client.dart'; 4 | import 'package:movieapp_flutter/core/error/failure.dart'; 5 | 6 | abstract interface class MovieRepository { 7 | Future>> list(); 8 | Future> retrieve(int id); 9 | Future> save(Movie movie); 10 | Future> delete(int id); 11 | } 12 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/scripts/install_dependencies: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat > /lib/systemd/system/serverpod.service << EOF 3 | [Unit] 4 | Description=Serverpod server 5 | After=multi-user.target 6 | 7 | [Service] 8 | User=ec2-user 9 | WorkingDirectory=/home/ec2-user 10 | ExecStart=/home/ec2-user/serverpod/active/movieapp_server/deploy/aws/scripts/run_serverpod 11 | Restart=always 12 | 13 | [Install] 14 | WantedBy=muti-user.target 15 | WantedBy=network-online.target 16 | EOF 17 | 18 | systemctl daemon-reload 19 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/asset/presentation/bloc/asset_state.dart: -------------------------------------------------------------------------------- 1 | part of 'asset_bloc.dart'; 2 | 3 | @immutable 4 | sealed class AssetState {} 5 | 6 | final class AssetStateInitial extends AssetState {} 7 | 8 | final class AssetStateLoading extends AssetState {} 9 | 10 | final class AssetStateSuccess extends AssetState { 11 | final String url; 12 | 13 | AssetStateSuccess(this.url); 14 | } 15 | 16 | final class AssetStateFailure extends AssetState { 17 | final String message; 18 | 19 | AssetStateFailure(this.message); 20 | } 21 | -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /movieapp_flutter/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); 14 | file_selector_plugin_register_with_registrar(file_selector_linux_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /movieapp_client/doc/endpoint.md: -------------------------------------------------------------------------------- 1 | # Callable endpoints 2 | 3 | Each class contains callable methods that will call a method on the server side. These are normally defined in the `endpoint` directory in your server project. This client sends requests to these endpoints and returns the result. 4 | 5 | Example usage: 6 | 7 | ```dart 8 | // How to use ExampleEndpoint. 9 | client.example.hello("world!"); 10 | 11 | // Generic format. 12 | client..(...); 13 | ``` 14 | 15 | Please see the full official documentation [here](https://docs.serverpod.dev) 16 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/scripts/appspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.0 2 | os: linux 3 | files: 4 | - source: /vendor/ 5 | destination: /home/ec2-user/serverpod/upload/vendor/ 6 | - source: /movieapp_server/ 7 | destination: /home/ec2-user/serverpod/upload/movieapp_server/ 8 | hooks: 9 | BeforeInstall: 10 | - location: movieapp_server/deploy/aws/scripts/install_dependencies 11 | timeout: 300 12 | runas: root 13 | ApplicationStart: 14 | - location: movieapp_server/deploy/aws/scripts/start_server 15 | timeout: 300 16 | runas: root 17 | -------------------------------------------------------------------------------- /movieapp_server/lib/src/endpoints/asset_endpoint.dart: -------------------------------------------------------------------------------- 1 | import 'package:serverpod/serverpod.dart'; 2 | 3 | class AssetEndpoint extends Endpoint { 4 | Future getUploadDescription(Session session, String path) async { 5 | return await session.storage.createDirectFileUploadDescription( 6 | storageId: 'public', 7 | path: path, 8 | ); 9 | } 10 | 11 | Future verifyUpload(Session session, String path) async { 12 | return await session.storage.verifyDirectFileUpload( 13 | storageId: 'public', 14 | path: path, 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/bloc/movie_manage/movie_manage_event.dart: -------------------------------------------------------------------------------- 1 | part of 'movie_manage_bloc.dart'; 2 | 3 | @immutable 4 | sealed class MovieManageEvent {} 5 | 6 | final class MovieManageRetrieveEvent extends MovieManageEvent { 7 | final int id; 8 | MovieManageRetrieveEvent(this.id); 9 | } 10 | 11 | final class MovieManageSaveEvent extends MovieManageEvent { 12 | final Movie movie; 13 | MovieManageSaveEvent(this.movie); 14 | } 15 | 16 | final class MovieManageDeleteEvent extends MovieManageEvent { 17 | final int movieId; 18 | MovieManageDeleteEvent(this.movieId); 19 | } 20 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/app_user/presentation/cubits/cubit/app_user_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:movieapp_flutter/core/entities/user.dart'; 4 | 5 | part 'app_user_state.dart'; 6 | 7 | class AppUserCubit extends Cubit { 8 | AppUserCubit() : super(AppUserInitial()); 9 | 10 | void updateUser(User? user) { 11 | if (user == null) { 12 | emit(AppUserInitial()); 13 | } else { 14 | emit(AppUserLoggedIn(user)); 15 | } 16 | } 17 | 18 | void logout() { 19 | updateUser(null); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /movieapp_server/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | postgres: 5 | image: postgres:14.1 6 | ports: 7 | - '8090:5432' 8 | environment: 9 | POSTGRES_USER: postgres 10 | POSTGRES_DB: movieapp 11 | POSTGRES_PASSWORD: "CTlGGpE0dL7vYSoHgBeXaUlBW74XTzVV" 12 | volumes: 13 | - movieapp_data:/var/lib/postgresql/data 14 | redis: 15 | image: redis:6.2.6 16 | ports: 17 | - '8091:6379' 18 | command: redis-server --requirepass "_Dq0OwBnSiA_oogY2gwyKl1VHDt52h1v" 19 | environment: 20 | - REDIS_REPLICATION_MODE=master 21 | volumes: 22 | movieapp_data: 23 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/auth/domain/usecases/user_logout.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_flutter/core/error/failure.dart'; 3 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 4 | import 'package:movieapp_flutter/features/auth/domain/respositories/auth_repository.dart'; 5 | 6 | class UserLogoutUseCase implements UseCase { 7 | final AuthRepository authRepository; 8 | 9 | const UserLogoutUseCase(this.authRepository); 10 | 11 | @override 12 | Future> call(NoParams params) async { 13 | return await authRepository.logout(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /movieapp_flutter/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | // import 'package:flutter/material.dart'; 9 | // import 'package:flutter_test/flutter_test.dart'; 10 | // 11 | // import 'package:PROJECTNAME_flutter/main.dart'; 12 | 13 | void main() { 14 | // Add your app tests here 15 | } 16 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | ConnectivityPlusWindowsPluginRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); 15 | FileSelectorWindowsRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("FileSelectorWindows")); 17 | } 18 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/vpc.tf: -------------------------------------------------------------------------------- 1 | module "vpc" { 2 | source = "terraform-aws-modules/vpc/aws" 3 | version = "2.77.0" 4 | 5 | name = "${var.project_name}-vpc" 6 | cidr = "10.0.0.0/16" 7 | 8 | azs = data.aws_availability_zones.available.names 9 | public_subnets = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"] 10 | enable_dns_hostnames = true 11 | enable_dns_support = true 12 | 13 | # create_database_subnet_group = true 14 | # create_database_subnet_route_table = true 15 | # create_database_internet_gateway_route = true 16 | 17 | # create_elasticache_subnet_group = true 18 | } 19 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/scripts/start_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Make sure permissions are correct for the serverpod directory 4 | chown -R ec2-user:ec2-user /home/ec2-user/serverpod 5 | 6 | # Run pub get as ec2-user 7 | cd /home/ec2-user/serverpod/upload/movieapp_server/ 8 | sudo -u ec2-user /usr/lib/dart/bin/dart pub get 9 | 10 | # Set correct permissions for start script 11 | chmod 755 deploy/aws/scripts/run_serverpod 12 | 13 | # Stop the server if it's running, copy files, and restart 14 | systemctl stop serverpod 15 | 16 | rm -rf /home/ec2-user/serverpod/active/ 17 | cp -rp /home/ec2-user/serverpod/upload/ /home/ec2-user/serverpod/active/ 18 | 19 | systemctl start serverpod 20 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/auth/domain/usecases/current_user.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_flutter/core/entities/user.dart'; 3 | import 'package:movieapp_flutter/core/error/failure.dart'; 4 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 5 | import 'package:movieapp_flutter/features/auth/domain/respositories/auth_repository.dart'; 6 | 7 | class CurrentUserUseCase implements UseCase { 8 | final AuthRepository authRepository; 9 | 10 | const CurrentUserUseCase(this.authRepository); 11 | 12 | @override 13 | Future> call(NoParams params) async { 14 | return authRepository.currentUser(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/domain/usecases/list_movies.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_client/movieapp_client.dart'; 3 | import 'package:movieapp_flutter/core/error/failure.dart'; 4 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 5 | import 'package:movieapp_flutter/features/movie/domain/repositories/movie_repository.dart'; 6 | 7 | class ListMoviesUseCase implements UseCase, NoParams> { 8 | final MovieRepository movieRepository; 9 | 10 | const ListMoviesUseCase(this.movieRepository); 11 | 12 | @override 13 | Future>> call(NoParams params) async { 14 | return await movieRepository.list(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = movieapp_flutter 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.movieappFlutter 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2024 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/bloc/movie_list/movie_list_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:movieapp_client/movieapp_client.dart'; 3 | 4 | @immutable 5 | sealed class MovieListState { 6 | const MovieListState(); 7 | } 8 | 9 | final class MovieListStateInitial extends MovieListState {} 10 | 11 | final class MovieListStateLoading extends MovieListState {} 12 | 13 | final class MovieListStateSuccess extends MovieListState { 14 | final List movies; 15 | 16 | const MovieListStateSuccess(this.movies); 17 | } 18 | 19 | final class MovieListStateFailure extends MovieListState { 20 | final String message; 21 | 22 | const MovieListStateFailure(this.message); 23 | } 24 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/bloc/movie_detail/movie_detail_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:movieapp_client/movieapp_client.dart'; 3 | 4 | @immutable 5 | sealed class MovieDetailState { 6 | const MovieDetailState(); 7 | } 8 | 9 | final class MovieDetailStateInitial extends MovieDetailState {} 10 | 11 | final class MovieDetailStateLoading extends MovieDetailState {} 12 | 13 | final class MovieDetailStateSuccess extends MovieDetailState { 14 | final Movie movie; 15 | 16 | const MovieDetailStateSuccess(this.movie); 17 | } 18 | 19 | final class MovieDetailStateFailure extends MovieDetailState { 20 | final String message; 21 | 22 | const MovieDetailStateFailure(this.message); 23 | } 24 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /movieapp_server/lib/src/endpoints/movie_endpoint.dart: -------------------------------------------------------------------------------- 1 | import 'package:movieapp_server/src/generated/protocol.dart'; 2 | import 'package:serverpod/serverpod.dart'; 3 | 4 | class MovieEndpoint extends Endpoint { 5 | Future> list(Session session) async { 6 | return Movie.db.find(session); 7 | } 8 | 9 | Future retrieve(Session session, int id) async { 10 | return Movie.db.findById(session, id); 11 | } 12 | 13 | Future save(Session session, Movie movie) async { 14 | return await (movie.id != null ? Movie.db.updateRow(session, movie) : Movie.db.insertRow(session, movie)); 15 | } 16 | 17 | Future delete(Session session, int id) async { 18 | await Movie.db.deleteWhere(session, where: (row) => row.id.equals(id)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/domain/usecases/delete_movie.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_flutter/core/error/failure.dart'; 3 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 4 | import 'package:movieapp_flutter/features/movie/domain/repositories/movie_repository.dart'; 5 | 6 | class DeleteMovieUseCase implements UseCase { 7 | final MovieRepository movieRepository; 8 | 9 | const DeleteMovieUseCase(this.movieRepository); 10 | 11 | @override 12 | Future> call(DeleteMovieParams params) async { 13 | return await movieRepository.delete(params.id); 14 | } 15 | } 16 | 17 | class DeleteMovieParams { 18 | final int id; 19 | const DeleteMovieParams({required this.id}); 20 | } 21 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/auth/presentation/bloc/auth_state.dart: -------------------------------------------------------------------------------- 1 | part of 'auth_bloc.dart'; 2 | 3 | @immutable 4 | sealed class AuthState { 5 | const AuthState(); 6 | } 7 | 8 | final class AuthStateInitial extends AuthState {} 9 | 10 | final class AuthStateLoading extends AuthState {} 11 | 12 | final class AuthStateSuccess extends AuthState { 13 | final User user; 14 | const AuthStateSuccess(this.user); 15 | } 16 | 17 | final class AuthStateFailure extends AuthState { 18 | final String message; 19 | const AuthStateFailure(this.message); 20 | } 21 | 22 | final class AuthStateConfirmationRequired extends AuthState { 23 | final String email; 24 | final String password; 25 | const AuthStateConfirmationRequired({ 26 | required this.email, 27 | required this.password, 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /movieapp_server/Dockerfile: -------------------------------------------------------------------------------- 1 | # If you update the dart version, make sure the image is 2 | # compatible with the busybox image. 3 | FROM dart:3.2.5 AS build 4 | 5 | WORKDIR /app 6 | COPY . . 7 | 8 | RUN dart pub get 9 | RUN dart compile exe bin/main.dart -o bin/main 10 | 11 | # If you update the busybox version, make sure the image is 12 | # compatible with the dart image. 13 | FROM busybox:1.36.1-glibc 14 | 15 | ENV runmode=development 16 | ENV serverid=default 17 | ENV logging=normal 18 | ENV role=monolith 19 | 20 | COPY --from=build /runtime/ / 21 | COPY --from=build /app/bin/main /app/bin/main 22 | COPY --from=build /app/config/ config/ 23 | COPY --from=build /app/web/ web/ 24 | 25 | EXPOSE 8080 26 | EXPOSE 8081 27 | EXPOSE 8082 28 | 29 | CMD app/bin/main --mode $runmode --server-id $serverid --logging $logging --role $role 30 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/domain/usecases/save_movie.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_client/movieapp_client.dart'; 3 | import 'package:movieapp_flutter/core/error/failure.dart'; 4 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 5 | import 'package:movieapp_flutter/features/movie/domain/repositories/movie_repository.dart'; 6 | 7 | class SaveMovieUseCase implements UseCase { 8 | final MovieRepository movieRepository; 9 | 10 | const SaveMovieUseCase(this.movieRepository); 11 | 12 | @override 13 | Future> call(SaveMovieParams params) async { 14 | return await movieRepository.save(params.movie); 15 | } 16 | } 17 | 18 | class SaveMovieParams { 19 | final Movie movie; 20 | const SaveMovieParams({required this.movie}); 21 | } 22 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/auth/domain/respositories/auth_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_flutter/core/entities/user.dart'; 3 | import 'package:movieapp_flutter/core/error/failure.dart'; 4 | 5 | abstract interface class AuthRepository { 6 | Either currentUser(); 7 | 8 | Future> loginWithEmailPassword({ 9 | required String email, 10 | required String password, 11 | }); 12 | 13 | Future> registerWithEmailAndPassword({ 14 | required String email, 15 | required String password, 16 | required String username, 17 | }); 18 | 19 | Future> confirmRegistration({ 20 | required String email, 21 | required String verificationCode, 22 | }); 23 | 24 | Future> logout(); 25 | } 26 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import connectivity_plus 9 | import file_selector_macos 10 | import path_provider_foundation 11 | import shared_preferences_foundation 12 | import sqflite 13 | 14 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 15 | ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) 16 | FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) 17 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 18 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 19 | SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) 20 | } 21 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/domain/usecases/retrieve_movie.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_client/movieapp_client.dart'; 3 | import 'package:movieapp_flutter/core/error/failure.dart'; 4 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 5 | import 'package:movieapp_flutter/features/movie/domain/repositories/movie_repository.dart'; 6 | 7 | class RetrieveMovieUseCase implements UseCase { 8 | final MovieRepository movieRepository; 9 | 10 | const RetrieveMovieUseCase(this.movieRepository); 11 | 12 | @override 13 | Future> call(RetrieveMovieParams params) async { 14 | return await movieRepository.retrieve(params.id); 15 | } 16 | } 17 | 18 | class RetrieveMovieParams { 19 | final int id; 20 | const RetrieveMovieParams({required this.id}); 21 | } 22 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/bloc/movie_manage/movie_manage_state.dart: -------------------------------------------------------------------------------- 1 | part of 'movie_manage_bloc.dart'; 2 | 3 | @immutable 4 | sealed class MovieManageState {} 5 | 6 | final class MovieManageStateInitial extends MovieManageState {} 7 | 8 | final class MovieManageStateLoading extends MovieManageState {} 9 | 10 | final class MovieManageStateRetrieveSuccess extends MovieManageState { 11 | final Movie movie; 12 | 13 | MovieManageStateRetrieveSuccess(this.movie); 14 | } 15 | 16 | final class MovieManageStateFailure extends MovieManageState { 17 | final String message; 18 | 19 | MovieManageStateFailure(this.message); 20 | } 21 | 22 | final class MovieManageStateSaveSuccess extends MovieManageState { 23 | final Movie movie; 24 | 25 | MovieManageStateSaveSuccess(this.movie); 26 | } 27 | 28 | final class MovieManageStateDeleteSuccess extends MovieManageState {} 29 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/asset/domain/usecases/upload_image.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:image_picker/image_picker.dart'; 3 | import 'package:movieapp_flutter/core/error/failure.dart'; 4 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 5 | import 'package:movieapp_flutter/features/asset/domain/repositories/asset_repository.dart'; 6 | 7 | class UploadImageUseCase implements UseCase { 8 | final AssetRepository assetRepository; 9 | 10 | const UploadImageUseCase(this.assetRepository); 11 | 12 | @override 13 | Future> call(UploadImageParams params) async { 14 | return await assetRepository.uploadImage(image: params.image); 15 | } 16 | } 17 | 18 | class UploadImageParams { 19 | final XFile image; 20 | 21 | const UploadImageParams({ 22 | required this.image, 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /movieapp_flutter/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | file_selector_linux 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /movieapp_flutter/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | } 9 | settings.ext.flutterSdkPath = flutterSdkPath() 10 | 11 | includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") 12 | 13 | repositories { 14 | google() 15 | mavenCentral() 16 | gradlePluginPortal() 17 | } 18 | } 19 | 20 | plugins { 21 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 22 | id "com.android.application" version "7.3.0" apply false 23 | id "org.jetbrains.kotlin.android" version "1.7.10" apply false 24 | } 25 | 26 | include ":app" 27 | -------------------------------------------------------------------------------- /movieapp_server/migrations/20240418143611250/migration.sql: -------------------------------------------------------------------------------- 1 | BEGIN; 2 | 3 | -- 4 | -- ACTION CREATE TABLE 5 | -- 6 | CREATE TABLE "movie" ( 7 | "id" serial PRIMARY KEY, 8 | "title" text NOT NULL, 9 | "year" integer NOT NULL, 10 | "imageUrl" text NOT NULL, 11 | "logline" text NOT NULL 12 | ); 13 | 14 | 15 | -- 16 | -- MIGRATION VERSION FOR movieapp 17 | -- 18 | INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") 19 | VALUES ('movieapp', '20240418143611250', now()) 20 | ON CONFLICT ("module") 21 | DO UPDATE SET "version" = '20240418143611250', "timestamp" = now(); 22 | 23 | -- 24 | -- MIGRATION VERSION FOR serverpod 25 | -- 26 | INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") 27 | VALUES ('serverpod', '20240115074235544', now()) 28 | ON CONFLICT ("module") 29 | DO UPDATE SET "version" = '20240115074235544', "timestamp" = now(); 30 | 31 | 32 | COMMIT; 33 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | connectivity_plus 7 | file_selector_windows 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/asset/data/repositories/asset_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:image_picker/image_picker.dart'; 3 | import 'package:movieapp_flutter/core/error/exceptions.dart'; 4 | import 'package:movieapp_flutter/core/error/failure.dart'; 5 | import 'package:movieapp_flutter/features/asset/data/datasources/asset_data_source.dart'; 6 | import 'package:movieapp_flutter/features/asset/domain/repositories/asset_repository.dart'; 7 | 8 | class AssetRepositoryImpl implements AssetRepository { 9 | final AssetDataSource dataSource; 10 | 11 | AssetRepositoryImpl(this.dataSource); 12 | 13 | @override 14 | Future> uploadImage({required XFile image}) async { 15 | try { 16 | final result = await dataSource.uploadImage(image); 17 | return right(result); 18 | } on ServerException catch (e) { 19 | return left(Failure(e.message)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /movieapp_flutter/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | 48 | -------------------------------------------------------------------------------- /movieapp_server/lib/src/future_calls/example_future_call.dart: -------------------------------------------------------------------------------- 1 | import 'package:serverpod/serverpod.dart'; 2 | 3 | // Future calls are calls that will be invoked at a later time. An example is if 4 | // you want to send a drip-email campaign after a user signs up. You can 5 | // schedule a future call for a day, a week, or a month. The calls are stored in 6 | // the database, so they will persist even if the server is restarted. 7 | // 8 | // To add a future call to your server, you need to register it in the 9 | // `server.dart` file. Schedule the call using the 10 | // `session.serverpod.futureCallWithDelay` or `session.serverpod.futureCallAtTime` 11 | // methods. You can optionally pass a serializable object together with the 12 | // call. 13 | 14 | class ExampleFutureCall extends FutureCall { 15 | @override 16 | Future invoke(Session session, SerializableEntity? object) async { 17 | // Do something interesting in the future here. 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /movieapp_server/deploy/gcp/terraform_gce/variables.tf: -------------------------------------------------------------------------------- 1 | # Project setup. 2 | 3 | variable "project" { 4 | type = string 5 | } 6 | 7 | variable "service_account_email" { 8 | type = string 9 | } 10 | 11 | variable "dns_managed_zone" { 12 | type = string 13 | } 14 | 15 | variable "top_domain" { 16 | type = string 17 | } 18 | 19 | variable "region" { 20 | type = string 21 | default = "us-central1" 22 | } 23 | 24 | variable "zone" { 25 | type = string 26 | default = "us-central1-c" 27 | } 28 | 29 | # Database 30 | 31 | variable "DATABASE_PASSWORD_PRODUCTION" { 32 | description = "The production database password, you can find it in the config/passwords.yaml file." 33 | type = string 34 | } 35 | 36 | variable "DATABASE_PASSWORD_STAGING" { 37 | description = "The staging database password, you can find it in the config/passwords.yaml file (no need to specify if you aren't deployning a staging environment)." 38 | type = string 39 | } 40 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /movieapp_server/lib/src/models/example.spy.yaml: -------------------------------------------------------------------------------- 1 | # Yaml-files in the `protocol` directory specify which serializable objects 2 | # should be generated. When you add or modify a file, you will need to run 3 | # `serverpod generate` to make the generated classes available in the server and 4 | # client. 5 | # 6 | # Please consult the documentation for more information on what you can add to 7 | # your yaml-files. 8 | 9 | 10 | # Name of the class to generate. 11 | class: Example 12 | 13 | # Add the table key, if this class represents a row in the database. 14 | #table: example 15 | 16 | # The fields (and columns if connected to the database) of the class. Supported types are 17 | # `bool`, `int`, `double`, `String`, `UuidValue`, `Duration`, `DateTime`, `ByteData`, 18 | # and other serializable classes, exceptions and enums. 19 | # You can also add lists of objects and types have support for null safety. 20 | # Eg. `List?` or `List`. 21 | fields: 22 | name: String 23 | data: int -------------------------------------------------------------------------------- /movieapp_server/web/templates/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Built with Serverpod 6 | 7 | 8 | 9 |
10 | 14 |
15 |
16 |

Served at: {{served}}

17 |

Run mode: {{runmode}}

18 |
19 |
20 | 27 |
28 | 29 | -------------------------------------------------------------------------------- /movieapp_server/deploy/gcp/terraform_gce/config.auto.tfvars: -------------------------------------------------------------------------------- 1 | # This is the main configuration file. You can deploy your Serverpod by only 2 | # doing changes to this file. Serverpod uses a minimal setup by default, but 3 | # you can edit the main.tf file to choose higher tiers for database and your 4 | # managed instances or enable additional services like Redis. 5 | # 6 | # You can find complete setup instructions at: 7 | # https://docs.serverpod.dev/ 8 | 9 | # The Project ID from the Google Cloud Console. 10 | project = "" 11 | 12 | # The service account email address authorized by your Google Cloud Console. 13 | service_account_email = "" 14 | 15 | # The name of your DNS zone. 16 | dns_managed_zone = "" 17 | 18 | # The top domain of your DNS zone. e.g. "examplepod.com" 19 | top_domain = "" 20 | 21 | # The region and zone to use for the deployment. Default values work. 22 | region = "us-central1" 23 | zone = "us-central1-c" 24 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/auth/domain/usecases/user_login.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_flutter/core/entities/user.dart'; 3 | import 'package:movieapp_flutter/core/error/failure.dart'; 4 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 5 | import 'package:movieapp_flutter/features/auth/domain/respositories/auth_repository.dart'; 6 | 7 | class UserLoginUseCase implements UseCase { 8 | final AuthRepository authRepository; 9 | 10 | const UserLoginUseCase(this.authRepository); 11 | 12 | @override 13 | Future> call(UserLoginParams params) async { 14 | return await authRepository.loginWithEmailPassword( 15 | email: params.email, 16 | password: params.password, 17 | ); 18 | } 19 | } 20 | 21 | class UserLoginParams { 22 | final String email; 23 | final String password; 24 | 25 | const UserLoginParams({ 26 | required this.email, 27 | required this.password, 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/init-script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Update yum packages" 3 | yum update -y 4 | 5 | # Install yum packages 6 | echo "Installing ruby" 7 | yum install ruby -y 8 | ehco "Installing wget" 9 | yum install wget -y 10 | 11 | # Install Dart 12 | echo "Installing dart" 13 | wget -q https://storage.googleapis.com/dart-archive/channels/stable/release/2.18.1/sdk/dartsdk-linux-x64-release.zip 14 | unzip -q dartsdk-linux-x64-release.zip 15 | sudo mv dart-sdk/ /usr/lib/dart/ 16 | sudo chmod -R 755 /usr/lib/dart/ 17 | echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> /etc/profile.d/script.sh 18 | 19 | # Install CodeDeploy agent 20 | echo "Installing CodeDeploy agent" 21 | cd /home/ec2-user 22 | wget https://aws-codedeploy-us-west-2.s3.us-west-2.amazonaws.com/latest/install 23 | chmod +x ./install 24 | ./install auto 25 | rm install 26 | 27 | # Set runmode 28 | echo "Setting runmode" 29 | echo ${runmode} > /home/ec2-user/runmode 30 | chown ec2-user:ec2-user /home/ec2-user/runmode 31 | 32 | echo "Setup done" 33 | -------------------------------------------------------------------------------- /movieapp_server/migrations/20240418143756623/migration.sql: -------------------------------------------------------------------------------- 1 | BEGIN; 2 | 3 | -- 4 | -- ACTION DROP TABLE 5 | -- 6 | DROP TABLE "movie" CASCADE; 7 | 8 | -- 9 | -- ACTION CREATE TABLE 10 | -- 11 | CREATE TABLE "movie" ( 12 | "id" serial PRIMARY KEY, 13 | "title" text NOT NULL, 14 | "year" integer NOT NULL, 15 | "imageUrl" text NOT NULL, 16 | "logline" text NOT NULL, 17 | "directorName" text NOT NULL 18 | ); 19 | 20 | 21 | -- 22 | -- MIGRATION VERSION FOR movieapp 23 | -- 24 | INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") 25 | VALUES ('movieapp', '20240418143756623', now()) 26 | ON CONFLICT ("module") 27 | DO UPDATE SET "version" = '20240418143756623', "timestamp" = now(); 28 | 29 | -- 30 | -- MIGRATION VERSION FOR serverpod 31 | -- 32 | INSERT INTO "serverpod_migrations" ("module", "version", "timestamp") 33 | VALUES ('serverpod', '20240115074235544', now()) 34 | ON CONFLICT ("module") 35 | DO UPDATE SET "version" = '20240115074235544', "timestamp" = now(); 36 | 37 | 38 | COMMIT; 39 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/asset/presentation/bloc/asset_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter_bloc/flutter_bloc.dart'; 5 | import 'package:image_picker/image_picker.dart'; 6 | import 'package:movieapp_flutter/features/asset/domain/usecases/upload_image.dart'; 7 | 8 | part 'asset_event.dart'; 9 | part 'asset_state.dart'; 10 | 11 | class AssetBloc extends Bloc { 12 | final UploadImageUseCase uploadImage; 13 | AssetBloc({required this.uploadImage}) : super(AssetStateInitial()) { 14 | on((event, emit) => emit(AssetStateLoading())); 15 | 16 | on(_handleUploadImage); 17 | } 18 | 19 | FutureOr _handleUploadImage(AssetUploadImageEvent event, Emitter emit) async { 20 | final result = await uploadImage(UploadImageParams(image: event.image)); 21 | 22 | result.fold( 23 | (failure) => emit(AssetStateFailure(failure.message)), 24 | (url) => emit(AssetStateSuccess(url)), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/auth/domain/usecases/user_register.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_flutter/core/error/failure.dart'; 3 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 4 | import 'package:movieapp_flutter/features/auth/domain/respositories/auth_repository.dart'; 5 | 6 | class UserRegisterUseCase implements UseCase { 7 | final AuthRepository authRepository; 8 | 9 | const UserRegisterUseCase(this.authRepository); 10 | 11 | @override 12 | Future> call(UserRegisterParams params) async { 13 | return await authRepository.registerWithEmailAndPassword( 14 | email: params.email, 15 | password: params.password, 16 | username: params.username, 17 | ); 18 | } 19 | } 20 | 21 | class UserRegisterParams { 22 | final String email; 23 | final String password; 24 | final String username; 25 | 26 | const UserRegisterParams({ 27 | required this.email, 28 | required this.password, 29 | required this.username, 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/auth/presentation/bloc/auth_event.dart: -------------------------------------------------------------------------------- 1 | part of 'auth_bloc.dart'; 2 | 3 | @immutable 4 | sealed class AuthEvent {} 5 | 6 | final class AuthLoginEvent extends AuthEvent { 7 | final String email; 8 | final String password; 9 | 10 | AuthLoginEvent({ 11 | required this.email, 12 | required this.password, 13 | }); 14 | } 15 | 16 | final class AuthRegisterEvent extends AuthEvent { 17 | final String email; 18 | final String password; 19 | final String username; 20 | 21 | AuthRegisterEvent({ 22 | required this.email, 23 | required this.password, 24 | required this.username, 25 | }); 26 | } 27 | 28 | final class AuthConfirmRegistrationEvent extends AuthEvent { 29 | final String email; 30 | final String verificationCode; 31 | final String password; 32 | 33 | AuthConfirmRegistrationEvent({ 34 | required this.email, 35 | required this.verificationCode, 36 | required this.password, 37 | }); 38 | } 39 | 40 | final class AuthLogoutEvent extends AuthEvent {} 41 | 42 | final class AuthIsUserLoggedInEvent extends AuthEvent {} 43 | -------------------------------------------------------------------------------- /movieapp_flutter/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "movieapp_flutter", 3 | "short_name": "movieapp_flutter", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/pages/movie_list_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:go_router/go_router.dart'; 3 | import 'package:movieapp_flutter/features/app_user/presentation/widgets/app_user_dropdown.dart'; 4 | import 'package:movieapp_flutter/features/movie/presentation/pages/movie_edit_page.dart'; 5 | import 'package:movieapp_flutter/features/movie/presentation/widgets/movie_list_widget.dart'; 6 | 7 | class MovieListPage extends StatelessWidget { 8 | static String route() => "/movies"; 9 | 10 | const MovieListPage({super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | appBar: AppBar( 16 | title: const Text("Movies"), 17 | actions: const [ 18 | AppUserDropdown(), 19 | ], 20 | ), 21 | floatingActionButton: FloatingActionButton( 22 | onPressed: () { 23 | context.push(MovieEditPage.routeNew()); 24 | }, 25 | child: const Icon(Icons.add), 26 | ), 27 | body: const MovieListWidget(), 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/bloc/movie_list/movie_list_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_bloc/flutter_bloc.dart'; 2 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 3 | import 'package:movieapp_flutter/features/movie/domain/usecases/list_movies.dart'; 4 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_list/movie_list_event.dart'; 5 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_list/movie_list_state.dart'; 6 | 7 | class MovieListBloc extends Bloc { 8 | final ListMoviesUseCase listMovies; 9 | 10 | MovieListBloc({required this.listMovies}) : super(MovieListStateInitial()) { 11 | on((_, emit) => emit(MovieListStateLoading())); 12 | on(_onFetchMovies); 13 | } 14 | 15 | Future _onFetchMovies(MovieListEvent event, Emitter emit) async { 16 | final result = await listMovies(NoParams()); 17 | 18 | result.fold( 19 | (failure) => emit(MovieListStateFailure(failure.message)), 20 | (movies) => emit(MovieListStateSuccess(movies)), 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/bloc/movie_detail/movie_detail_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_bloc/flutter_bloc.dart'; 2 | import 'package:movieapp_flutter/features/movie/domain/usecases/retrieve_movie.dart'; 3 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_detail/movie_detail_event.dart'; 4 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_detail/movie_detail_state.dart'; 5 | 6 | class MovieDetailBloc extends Bloc { 7 | final RetrieveMovieUseCase retrieveMovie; 8 | 9 | MovieDetailBloc({required this.retrieveMovie}) : super(MovieDetailStateInitial()) { 10 | on((_, emit) => emit(MovieDetailStateLoading())); 11 | on(_onFetchMovie); 12 | } 13 | 14 | Future _onFetchMovie(MovieDetailRetrieveEvent event, Emitter emit) async { 15 | final result = await retrieveMovie(RetrieveMovieParams(id: event.id)); 16 | 17 | result.fold( 18 | (failure) => emit(MovieDetailStateFailure(failure.message)), 19 | (movie) => emit(MovieDetailStateSuccess(movie)), 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /movieapp_server/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/app_user/presentation/widgets/app_user_dropdown.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:movieapp_flutter/features/app_user/presentation/cubits/cubit/app_user_cubit.dart'; 4 | import 'package:movieapp_flutter/features/auth/presentation/bloc/auth_bloc.dart'; 5 | 6 | class AppUserDropdown extends StatelessWidget { 7 | const AppUserDropdown({super.key}); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return BlocBuilder( 12 | builder: (context, state) { 13 | if (state is! AppUserLoggedIn) { 14 | return const SizedBox(); 15 | } 16 | 17 | return PopupMenuButton(itemBuilder: (context) { 18 | return [ 19 | PopupMenuItem( 20 | child: Text(state.user.username), 21 | ), 22 | PopupMenuItem( 23 | child: const Text("Logout"), 24 | onTap: () { 25 | context.read().add(AuthLogoutEvent()); 26 | }, 27 | ), 28 | ]; 29 | }); 30 | }, 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /movieapp_server/config/development.yaml: -------------------------------------------------------------------------------- 1 | # This is the configuration file for your local development environment. By 2 | # default, it runs a single server on port 8080. To set up your server, you will 3 | # need to add the name of the database you are connecting to and the user name. 4 | # The password for the database is stored in the config/passwords.yaml. 5 | # 6 | # When running your server locally, the server ports are the same as the public 7 | # facing ports. 8 | 9 | # Configuration for the main API server. 10 | apiServer: 11 | port: 8080 12 | publicHost: localhost 13 | publicPort: 8080 14 | publicScheme: http 15 | 16 | # Configuration for the Insights server. 17 | insightsServer: 18 | port: 8081 19 | publicHost: localhost 20 | publicPort: 8081 21 | publicScheme: http 22 | 23 | # Configuration for the web server. 24 | webServer: 25 | port: 8082 26 | publicHost: localhost 27 | publicPort: 8082 28 | publicScheme: http 29 | 30 | # This is the database setup for your server. 31 | database: 32 | host: localhost 33 | port: 8090 34 | name: movieapp 35 | user: postgres 36 | 37 | # This is the setup for Redis. 38 | redis: 39 | enabled: false 40 | host: localhost 41 | port: 8091 -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /movieapp_server/lib/src/endpoints/example_endpoint.dart: -------------------------------------------------------------------------------- 1 | import 'package:serverpod/serverpod.dart'; 2 | 3 | // This is an example endpoint of your server. It's best practice to use the 4 | // `Endpoint` ending of the class name, but it will be removed when accessing 5 | // the endpoint from the client. I.e., this endpoint can be accessed through 6 | // `client.example` on the client side. 7 | 8 | // After adding or modifying an endpoint, you will need to run 9 | // `serverpod generate` to update the server and client code. 10 | class ExampleEndpoint extends Endpoint { 11 | // You create methods in your endpoint which are accessible from the client by 12 | // creating a public method with `Session` as its first parameter. 13 | // `bool`, `int`, `double`, `String`, `UuidValue`, `Duration`, `DateTime`, `ByteData`, 14 | // and other serializable classes, exceptions and enums from your from your `protocol` directory. 15 | // The methods should return a typed future; the same types as for the parameters are 16 | // supported. The `session` object provides access to the database, logging, 17 | // passwords, and information about the request being made to the server. 18 | Future hello(Session session, String name) async { 19 | return 'Hello $name'; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/auth/domain/usecases/user_confirm_registration.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_flutter/core/entities/user.dart'; 3 | import 'package:movieapp_flutter/core/error/failure.dart'; 4 | import 'package:movieapp_flutter/core/usecases/usecase.dart'; 5 | import 'package:movieapp_flutter/features/auth/domain/respositories/auth_repository.dart'; 6 | 7 | class UserConfirmRegistrationUseCase implements UseCase { 8 | final AuthRepository authRepository; 9 | 10 | const UserConfirmRegistrationUseCase(this.authRepository); 11 | 12 | @override 13 | Future> call(UserConfirmRegistrationParams params) async { 14 | final confirmationResult = await authRepository.confirmRegistration( 15 | email: params.email, 16 | verificationCode: params.verificationCode, 17 | ); 18 | 19 | return await confirmationResult.fold((failure) => left(failure), (r) async { 20 | return await authRepository.loginWithEmailPassword( 21 | email: params.email, 22 | password: params.password, 23 | ); 24 | }); 25 | } 26 | } 27 | 28 | class UserConfirmRegistrationParams { 29 | final String email; 30 | final String verificationCode; 31 | final String password; 32 | 33 | const UserConfirmRegistrationParams({ 34 | required this.email, 35 | required this.verificationCode, 36 | required this.password, 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"movieapp_flutter", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /movieapp_flutter/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | target 'RunnerTests' do 35 | inherit! :search_paths 36 | end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_macos_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/data/datasources/movie_datasource.dart: -------------------------------------------------------------------------------- 1 | import 'package:movieapp_client/movieapp_client.dart'; 2 | import 'package:movieapp_flutter/core/error/exceptions.dart'; 3 | 4 | abstract interface class MovieDatasource { 5 | Future> list(); 6 | Future retrieve(int id); 7 | Future save(Movie movie); 8 | Future delete(int id); 9 | } 10 | 11 | class MovieDatasourceImpl implements MovieDatasource { 12 | final Client client; 13 | // final SessionManager sessionManager; 14 | 15 | MovieDatasourceImpl(this.client); 16 | 17 | @override 18 | Future> list() async { 19 | try { 20 | return await client.movie.list(); 21 | } catch (e) { 22 | throw ServerException(e.toString()); 23 | } 24 | } 25 | 26 | @override 27 | Future retrieve(int id) async { 28 | print(id); 29 | try { 30 | final result = await client.movie.retrieve(id); 31 | if (result == null) { 32 | throw const ServerException("Movie not found"); 33 | } 34 | return result; 35 | } catch (e) { 36 | throw ServerException(e.toString()); 37 | } 38 | } 39 | 40 | @override 41 | Future save(Movie movie) async { 42 | try { 43 | return await client.movie.save(movie); 44 | } catch (e) { 45 | throw ServerException(e.toString()); 46 | } 47 | } 48 | 49 | @override 50 | Future delete(int id) async { 51 | try { 52 | await client.movie.delete(id); 53 | } catch (e) { 54 | throw ServerException(e.toString()); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '12.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/asset/data/datasources/asset_data_source.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:image_picker/image_picker.dart'; 4 | import 'package:movieapp_client/movieapp_client.dart'; 5 | import 'package:movieapp_flutter/core/error/exceptions.dart'; 6 | import 'package:movieapp_flutter/core/utils/strings.dart'; 7 | 8 | abstract interface class AssetDataSource { 9 | Future uploadImage(XFile image); 10 | } 11 | 12 | class AssetDataSourceImpl implements AssetDataSource { 13 | final Client client; 14 | 15 | AssetDataSourceImpl(this.client); 16 | 17 | @override 18 | Future uploadImage(XFile image) async { 19 | final name = "${generateRandomString(16)}.${image.path.split('.').last}"; 20 | 21 | final uploadDescription = await client.asset.getUploadDescription(name); 22 | 23 | if (uploadDescription == null) { 24 | throw const ServerException("Upload not successful"); 25 | } 26 | 27 | final uploader = FileUploader(uploadDescription); 28 | 29 | final stream = image.openRead(); 30 | final length = (await image.readAsBytes()).length; 31 | 32 | await uploader.upload(stream, length); 33 | 34 | final success = await client.asset.verifyUpload(name); 35 | 36 | if (!success) { 37 | throw const ServerException("Upload failed"); 38 | } 39 | 40 | final Map decodedDescription = jsonDecode(uploadDescription); 41 | 42 | if (!decodedDescription.containsKey('url')) { 43 | throw const ServerException("No Upload URL"); 44 | } 45 | 46 | return "${decodedDescription['url']}/$name"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /movieapp_server/web/static/css/style.css: -------------------------------------------------------------------------------- 1 | html { 2 | box-sizing: border-box; 3 | font-size: 14px; 4 | font-family: Arial, Helvetica, sans-serif; 5 | background: url('/images/background.svg') no-repeat center center fixed; 6 | -webkit-background-size: cover; 7 | -moz-background-size: cover; 8 | -o-background-size: cover; 9 | background-size: cover; 10 | } 11 | 12 | *, *:before, *:after { 13 | box-sizing: inherit; 14 | } 15 | 16 | body, h1, h2, h3, h4, h5, h6, p, ol, ul { 17 | margin: 0; 18 | padding: 0; 19 | font-weight: normal; 20 | } 21 | 22 | ol, ul { 23 | list-style: none; 24 | } 25 | 26 | img { 27 | max-width: 100%; 28 | height: auto; 29 | } 30 | 31 | body { 32 | padding: 16px; 33 | } 34 | 35 | hr { 36 | margin-top: 16px; margin-bottom: 16px; 37 | border: 0; 38 | height: 1px; 39 | background: #999; 40 | } 41 | 42 | .content { 43 | min-width: 300px; 44 | position: absolute; 45 | left: 50%; 46 | top: 50%; 47 | -webkit-transform: translate(-50%, -50%); 48 | transform: translate(-50%, -50%); 49 | background-color: white; 50 | border-radius: 8px; 51 | padding: 16px; 52 | box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 53 | } 54 | 55 | .logo-box a { 56 | text-decoration: none; 57 | font-weight: bold; 58 | color: #666; 59 | } 60 | 61 | .logo-box { 62 | text-align: center; 63 | } 64 | 65 | .info-box p { 66 | margin-top: 2px; 67 | } 68 | 69 | .link-box { 70 | text-align: center; 71 | color: #999; 72 | } 73 | 74 | .link-box a { 75 | text-decoration: none; 76 | } -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/data/repositories/movie_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_client/movieapp_client.dart'; 3 | import 'package:movieapp_flutter/core/error/exceptions.dart'; 4 | import 'package:movieapp_flutter/core/error/failure.dart'; 5 | import 'package:movieapp_flutter/features/movie/data/datasources/movie_datasource.dart'; 6 | import 'package:movieapp_flutter/features/movie/domain/repositories/movie_repository.dart'; 7 | 8 | class MovieRepositoryImpl implements MovieRepository { 9 | final MovieDatasource datasource; 10 | 11 | MovieRepositoryImpl(this.datasource); 12 | 13 | @override 14 | Future>> list() async { 15 | try { 16 | return right(await datasource.list()); 17 | } on ServerException catch (e) { 18 | return left(Failure(e.message)); 19 | } 20 | } 21 | 22 | @override 23 | Future> retrieve(int id) async { 24 | try { 25 | return right(await datasource.retrieve(id)); 26 | } on ServerException catch (e) { 27 | return left(Failure(e.message)); 28 | } 29 | } 30 | 31 | @override 32 | Future> save(Movie movie) async { 33 | try { 34 | return right(await datasource.save(movie)); 35 | } on ServerException catch (e) { 36 | return left(Failure(e.message)); 37 | } 38 | } 39 | 40 | @override 41 | Future> delete(int id) async { 42 | try { 43 | return right(await datasource.delete(id)); 44 | } on ServerException catch (e) { 45 | return left(Failure(e.message)); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /movieapp_flutter/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /movieapp_server/config/production.yaml: -------------------------------------------------------------------------------- 1 | # This is the configuration file for your production environment. 2 | # Typically, you will want to route the traffic through a load balancer 3 | # which adds SSL security through https. If you use Serverpod's standard 4 | # Terraform scripts to deploy your server, all you need to change in 5 | # this file is the examplepod.com domain name. 6 | 7 | # Configuration for the main API server. 8 | apiServer: 9 | port: 8080 10 | publicHost: api.examplepod.com 11 | publicPort: 443 12 | publicScheme: https 13 | 14 | # Configuration for the Insights server. 15 | insightsServer: 16 | port: 8081 17 | publicHost: insights.examplepod.com 18 | publicPort: 443 19 | publicScheme: https 20 | 21 | # Configuration for the web server. 22 | webServer: 23 | port: 8082 24 | publicHost: app.examplepod.com 25 | publicPort: 443 26 | publicScheme: https 27 | 28 | # This is the database setup for your servers. The default for the Google Cloud 29 | # Engine Terraform configuration is to connect on a private IP address. 30 | # If you are connecting on a public IP (e.g. on AWS or Google Cloud Run), you 31 | # connect on the public IP of the database e.g. database.examplepod.com. 32 | database: 33 | host: database.private-production.examplepod.com 34 | port: 5432 35 | name: serverpod 36 | user: postgres 37 | 38 | # This is the setup for Redis. The default for the Google Cloud Engine Terraform 39 | # configuration is to connect on a private IP address. 40 | # If you are connecting on a public IP (e.g. on AWS or Google Cloud Run), you 41 | # connect on the public IP of the database e.g. redis.examplepod.com. 42 | redis: 43 | enabled: false 44 | host: redis.private-production.examplepod.com 45 | port: 6379 46 | -------------------------------------------------------------------------------- /movieapp_server/deploy/gcp/console_gcr/cloud-run-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # These are the variables that need to be set to be able to deploy to cloud run. 4 | # You can find the values in the Google Cloud Console. 5 | DATABASE_INSTANCE_CONNECTION_NAME="" 6 | SERVICE_ACCOUNT="" 7 | 8 | # Optionally configure the region and runmode (staging is also viable). 9 | REGION="us-central1" 10 | RUNMODE="production" 11 | 12 | 13 | # Check that we are running the script from the correct directory. 14 | if [ ! -f config/production.yaml ]; then 15 | echo "Run this script from the root of your server directory (e.g., mypod/mypod_server)." 16 | exit 1 17 | fi 18 | 19 | 20 | # Deploy the API server. 21 | echo "Deploying API server..." 22 | 23 | gcloud run deploy serverpod-api \ 24 | --source=. \ 25 | --region=$REGION \ 26 | --platform=managed \ 27 | --service-account=$SERVICE_ACCOUNT \ 28 | --port=8080 \ 29 | --set-cloudsql-instances=$DATABASE_INSTANCE_CONNECTION_NAME \ 30 | --execution-environment=gen2 \ 31 | --set-env-vars="runmode=$RUNMODE" \ 32 | --set-env-vars="role=serverless" \ 33 | --allow-unauthenticated 34 | 35 | 36 | # Deploy the Insights server. This is used by the Serverpod Insights app. It 37 | # can provide run time information and logs from the API server. 38 | echo "Deploying Insights server..." 39 | 40 | gcloud run deploy serverpod-insights \ 41 | --source=. \ 42 | --region=$REGION \ 43 | --platform=managed \ 44 | --service-account=$SERVICE_ACCOUNT \ 45 | --port=8081 \ 46 | --set-cloudsql-instances=$DATABASE_INSTANCE_CONNECTION_NAME \ 47 | --execution-environment=gen2 \ 48 | --set-env-vars="runmode=$RUNMODE" \ 49 | --set-env-vars="role=serverless" \ 50 | --allow-unauthenticated 51 | -------------------------------------------------------------------------------- /movieapp_server/migrations/20240418143611250/migration.json: -------------------------------------------------------------------------------- 1 | { 2 | "actions": [ 3 | { 4 | "type": "createTable", 5 | "createTable": { 6 | "name": "movie", 7 | "dartName": "Movie", 8 | "module": "movieapp", 9 | "schema": "public", 10 | "columns": [ 11 | { 12 | "name": "id", 13 | "columnType": 2, 14 | "isNullable": false, 15 | "columnDefault": "nextval('movie_id_seq'::regclass)", 16 | "dartType": "int?" 17 | }, 18 | { 19 | "name": "title", 20 | "columnType": 0, 21 | "isNullable": false, 22 | "dartType": "String" 23 | }, 24 | { 25 | "name": "year", 26 | "columnType": 2, 27 | "isNullable": false, 28 | "dartType": "int" 29 | }, 30 | { 31 | "name": "imageUrl", 32 | "columnType": 0, 33 | "isNullable": false, 34 | "dartType": "String" 35 | }, 36 | { 37 | "name": "logline", 38 | "columnType": 0, 39 | "isNullable": false, 40 | "dartType": "String" 41 | } 42 | ], 43 | "foreignKeys": [], 44 | "indexes": [ 45 | { 46 | "indexName": "movie_pkey", 47 | "elements": [ 48 | { 49 | "type": 0, 50 | "definition": "id" 51 | } 52 | ], 53 | "type": "btree", 54 | "isUnique": true, 55 | "isPrimary": true 56 | } 57 | ], 58 | "managed": true 59 | } 60 | } 61 | ], 62 | "warnings": [], 63 | "migrationApiVersion": 1 64 | } -------------------------------------------------------------------------------- /movieapp_server/migrations/20240418143611250/definition_project.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleName": "movieapp", 3 | "tables": [ 4 | { 5 | "name": "movie", 6 | "dartName": "Movie", 7 | "module": "movieapp", 8 | "schema": "public", 9 | "columns": [ 10 | { 11 | "name": "id", 12 | "columnType": 2, 13 | "isNullable": false, 14 | "columnDefault": "nextval('movie_id_seq'::regclass)", 15 | "dartType": "int?" 16 | }, 17 | { 18 | "name": "title", 19 | "columnType": 0, 20 | "isNullable": false, 21 | "dartType": "String" 22 | }, 23 | { 24 | "name": "year", 25 | "columnType": 2, 26 | "isNullable": false, 27 | "dartType": "int" 28 | }, 29 | { 30 | "name": "imageUrl", 31 | "columnType": 0, 32 | "isNullable": false, 33 | "dartType": "String" 34 | }, 35 | { 36 | "name": "logline", 37 | "columnType": 0, 38 | "isNullable": false, 39 | "dartType": "String" 40 | } 41 | ], 42 | "foreignKeys": [], 43 | "indexes": [ 44 | { 45 | "indexName": "movie_pkey", 46 | "elements": [ 47 | { 48 | "type": 0, 49 | "definition": "id" 50 | } 51 | ], 52 | "type": "btree", 53 | "isUnique": true, 54 | "isPrimary": true 55 | } 56 | ], 57 | "managed": true 58 | } 59 | ], 60 | "installedModules": [ 61 | { 62 | "module": "serverpod", 63 | "version": "20240115074235544" 64 | }, 65 | { 66 | "module": "movieapp", 67 | "version": "20240418142408454" 68 | } 69 | ], 70 | "migrationApiVersion": 1 71 | } -------------------------------------------------------------------------------- /movieapp_client/lib/src/protocol/example.dart: -------------------------------------------------------------------------------- 1 | /* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ 2 | /* To generate run: "serverpod generate" */ 3 | 4 | // ignore_for_file: library_private_types_in_public_api 5 | // ignore_for_file: public_member_api_docs 6 | // ignore_for_file: implementation_imports 7 | // ignore_for_file: use_super_parameters 8 | // ignore_for_file: type_literal_in_constant_pattern 9 | 10 | // ignore_for_file: no_leading_underscores_for_library_prefixes 11 | import 'package:serverpod_client/serverpod_client.dart' as _i1; 12 | 13 | abstract class Example extends _i1.SerializableEntity { 14 | Example._({ 15 | required this.name, 16 | required this.data, 17 | }); 18 | 19 | factory Example({ 20 | required String name, 21 | required int data, 22 | }) = _ExampleImpl; 23 | 24 | factory Example.fromJson( 25 | Map jsonSerialization, 26 | _i1.SerializationManager serializationManager, 27 | ) { 28 | return Example( 29 | name: serializationManager.deserialize(jsonSerialization['name']), 30 | data: serializationManager.deserialize(jsonSerialization['data']), 31 | ); 32 | } 33 | 34 | String name; 35 | 36 | int data; 37 | 38 | Example copyWith({ 39 | String? name, 40 | int? data, 41 | }); 42 | @override 43 | Map toJson() { 44 | return { 45 | 'name': name, 46 | 'data': data, 47 | }; 48 | } 49 | } 50 | 51 | class _ExampleImpl extends Example { 52 | _ExampleImpl({ 53 | required String name, 54 | required int data, 55 | }) : super._( 56 | name: name, 57 | data: data, 58 | ); 59 | 60 | @override 61 | Example copyWith({ 62 | String? name, 63 | int? data, 64 | }) { 65 | return Example( 66 | name: name ?? this.name, 67 | data: data ?? this.data, 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/cloudfront-web-staging.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | alb_origin_id_staging = "${var.project_name}-web-staging" 3 | } 4 | 5 | resource "aws_cloudfront_distribution" "web_staging" { 6 | count = var.enable_staging_server ? 1 : 0 7 | 8 | origin { 9 | origin_id = local.alb_origin_id_staging 10 | domain_name = aws_lb.serverpod_staging[0].dns_name 11 | custom_origin_config { 12 | http_port = 80 13 | https_port = 443 14 | origin_protocol_policy = "http-only" 15 | origin_ssl_protocols = ["SSLv3"] 16 | } 17 | } 18 | enabled = true 19 | 20 | aliases = ["${var.subdomain_web_staging}.${var.top_domain}"] 21 | 22 | default_cache_behavior { 23 | allowed_methods = ["HEAD", "DELETE", "POST", "GET", "OPTIONS", "PUT", "PATCH"] 24 | cached_methods = ["HEAD", "GET"] 25 | target_origin_id = local.alb_origin_id_staging 26 | 27 | forwarded_values { 28 | query_string = true 29 | 30 | cookies { 31 | forward = "all" 32 | } 33 | 34 | headers = ["*"] 35 | } 36 | 37 | viewer_protocol_policy = "redirect-to-https" 38 | min_ttl = 0 39 | default_ttl = 0 40 | max_ttl = 0 41 | } 42 | 43 | price_class = "PriceClass_100" 44 | 45 | viewer_certificate { 46 | acm_certificate_arn = var.cloudfront_certificate_arn 47 | ssl_support_method = "sni-only" 48 | } 49 | 50 | restrictions { 51 | geo_restriction { 52 | restriction_type = "none" 53 | } 54 | } 55 | } 56 | 57 | resource "aws_route53_record" "web_staging" { 58 | count = var.enable_staging_server ? 1 : 0 59 | 60 | zone_id = var.hosted_zone_id 61 | name = "${var.subdomain_web_staging}.${var.top_domain}" 62 | type = "CNAME" 63 | ttl = "300" 64 | records = ["${aws_cloudfront_distribution.web_staging[0].domain_name}"] 65 | } -------------------------------------------------------------------------------- /movieapp_flutter/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "300451adae589accbece3490f4396f10bdf15e6e" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 300451adae589accbece3490f4396f10bdf15e6e 17 | base_revision: 300451adae589accbece3490f4396f10bdf15e6e 18 | - platform: android 19 | create_revision: 300451adae589accbece3490f4396f10bdf15e6e 20 | base_revision: 300451adae589accbece3490f4396f10bdf15e6e 21 | - platform: ios 22 | create_revision: 300451adae589accbece3490f4396f10bdf15e6e 23 | base_revision: 300451adae589accbece3490f4396f10bdf15e6e 24 | - platform: linux 25 | create_revision: 300451adae589accbece3490f4396f10bdf15e6e 26 | base_revision: 300451adae589accbece3490f4396f10bdf15e6e 27 | - platform: macos 28 | create_revision: 300451adae589accbece3490f4396f10bdf15e6e 29 | base_revision: 300451adae589accbece3490f4396f10bdf15e6e 30 | - platform: web 31 | create_revision: 300451adae589accbece3490f4396f10bdf15e6e 32 | base_revision: 300451adae589accbece3490f4396f10bdf15e6e 33 | - platform: windows 34 | create_revision: 300451adae589accbece3490f4396f10bdf15e6e 35 | base_revision: 300451adae589accbece3490f4396f10bdf15e6e 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /movieapp_server/web/static/images/background.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /movieapp_server/config/staging.yaml: -------------------------------------------------------------------------------- 1 | # This is the configuration file for your staging environment. The staging 2 | # environment is meant to resemble the production environment as much as 3 | # possible and may connect to production databases services and data. You use it 4 | # for final testing before deploying the production server. 5 | # 6 | # Typically, you will want to route the traffic through a load balancer 7 | # which adds SSL security through https. If you use Serverpod's standard 8 | # Terraform scripts to deploy your server, all you need to change in 9 | # this file is the examplepod.com domain name. 10 | 11 | # Configuration for the main API server. 12 | apiServer: 13 | port: 8080 14 | publicHost: api-staging.examplepod.com 15 | publicPort: 443 16 | publicScheme: https 17 | 18 | # Configuration for the Insights server. 19 | insightsServer: 20 | port: 8081 21 | publicHost: insights-staging.examplepod.com 22 | publicPort: 443 23 | publicScheme: https 24 | 25 | # Configuration for the web server. 26 | webServer: 27 | port: 8082 28 | publicHost: app-staging.examplepod.com 29 | publicPort: 443 30 | publicScheme: https 31 | 32 | # This is the database setup for your servers. The default for the Google Cloud 33 | # Engine Terraform configuration is to connect on a private IP address. 34 | # If you are connecting on a public IP (e.g. on AWS or Google Cloud Run), you 35 | # connect on the public IP of the database e.g. database-staging.examplepod.com. 36 | database: 37 | host: database.private-staging.examplepod.com 38 | port: 5432 39 | name: serverpod 40 | user: postgres 41 | 42 | # This is the setup for Redis. The default for the Google Cloud Engine Terraform 43 | # configuration is to connect on a private IP address. 44 | # If you are connecting on a public IP (e.g. on AWS or Google Cloud Run), you 45 | # connect on the public IP of the database e.g. redis-staging.examplepod.com. 46 | redis: 47 | enabled: false 48 | host: redis.private-staging.examplepod.com 49 | port: 6379 50 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/staging.tf: -------------------------------------------------------------------------------- 1 | resource "aws_launch_configuration" "staging" { 2 | count = var.enable_staging_server ? 1 : 0 3 | 4 | name_prefix = "${var.project_name}-staging-" 5 | image_id = var.instance_ami 6 | # image_id = data.aws_ami.amazon-linux.id 7 | instance_type = var.staging_instance_type 8 | user_data = templatefile("init-script.sh", { runmode = "staging" }) 9 | 10 | security_groups = [ 11 | aws_security_group.serverpod.id, 12 | aws_security_group.ssh.id 13 | ] 14 | 15 | iam_instance_profile = aws_iam_instance_profile.codedeploy_profile.name 16 | 17 | lifecycle { 18 | create_before_destroy = true 19 | } 20 | } 21 | 22 | resource "aws_autoscaling_group" "staging" { 23 | count = var.enable_staging_server ? 1 : 0 24 | 25 | min_size = var.staging_autoscaling_min_size 26 | max_size = var.staging_autoscaling_max_size 27 | desired_capacity = var.staging_autoscaling_desired_capacity 28 | launch_configuration = aws_launch_configuration.staging[0].name 29 | vpc_zone_identifier = module.vpc.public_subnets 30 | 31 | target_group_arns = [ 32 | aws_lb_target_group.api_staging[0].arn, 33 | aws_lb_target_group.insights_staging[0].arn, 34 | aws_lb_target_group.web_staging[0].arn 35 | ] 36 | 37 | tag { 38 | key = "Name" 39 | value = "${var.project_name}-serverpod-staging" 40 | propagate_at_launch = true 41 | } 42 | 43 | tag { 44 | key = "CodeDeploy" 45 | value = "${var.project_name}-staging" 46 | propagate_at_launch = true 47 | } 48 | } 49 | 50 | resource "aws_codedeploy_deployment_group" "staging" { 51 | count = var.enable_staging_server ? 1 : 0 52 | 53 | app_name = aws_codedeploy_app.serverpod.name 54 | deployment_group_name = "${var.project_name}-staging-group" 55 | service_role_arn = aws_iam_role.codedeploy_role.arn 56 | autoscaling_groups = [aws_autoscaling_group.staging[0].id] 57 | } -------------------------------------------------------------------------------- /movieapp_server/lib/src/generated/example.dart: -------------------------------------------------------------------------------- 1 | /* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ 2 | /* To generate run: "serverpod generate" */ 3 | 4 | // ignore_for_file: library_private_types_in_public_api 5 | // ignore_for_file: public_member_api_docs 6 | // ignore_for_file: implementation_imports 7 | // ignore_for_file: use_super_parameters 8 | // ignore_for_file: type_literal_in_constant_pattern 9 | 10 | // ignore_for_file: no_leading_underscores_for_library_prefixes 11 | import 'package:serverpod/serverpod.dart' as _i1; 12 | 13 | abstract class Example extends _i1.SerializableEntity { 14 | Example._({ 15 | required this.name, 16 | required this.data, 17 | }); 18 | 19 | factory Example({ 20 | required String name, 21 | required int data, 22 | }) = _ExampleImpl; 23 | 24 | factory Example.fromJson( 25 | Map jsonSerialization, 26 | _i1.SerializationManager serializationManager, 27 | ) { 28 | return Example( 29 | name: serializationManager.deserialize(jsonSerialization['name']), 30 | data: serializationManager.deserialize(jsonSerialization['data']), 31 | ); 32 | } 33 | 34 | String name; 35 | 36 | int data; 37 | 38 | Example copyWith({ 39 | String? name, 40 | int? data, 41 | }); 42 | @override 43 | Map toJson() { 44 | return { 45 | 'name': name, 46 | 'data': data, 47 | }; 48 | } 49 | 50 | @override 51 | Map allToJson() { 52 | return { 53 | 'name': name, 54 | 'data': data, 55 | }; 56 | } 57 | } 58 | 59 | class _ExampleImpl extends Example { 60 | _ExampleImpl({ 61 | required String name, 62 | required int data, 63 | }) : super._( 64 | name: name, 65 | data: data, 66 | ); 67 | 68 | @override 69 | Example copyWith({ 70 | String? name, 71 | int? data, 72 | }) { 73 | return Example( 74 | name: name ?? this.name, 75 | data: data ?? this.data, 76 | ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /movieapp_server/migrations/20240418143756623/definition_project.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleName": "movieapp", 3 | "tables": [ 4 | { 5 | "name": "movie", 6 | "dartName": "Movie", 7 | "module": "movieapp", 8 | "schema": "public", 9 | "columns": [ 10 | { 11 | "name": "id", 12 | "columnType": 2, 13 | "isNullable": false, 14 | "columnDefault": "nextval('movie_id_seq'::regclass)", 15 | "dartType": "int?" 16 | }, 17 | { 18 | "name": "title", 19 | "columnType": 0, 20 | "isNullable": false, 21 | "dartType": "String" 22 | }, 23 | { 24 | "name": "year", 25 | "columnType": 2, 26 | "isNullable": false, 27 | "dartType": "int" 28 | }, 29 | { 30 | "name": "imageUrl", 31 | "columnType": 0, 32 | "isNullable": false, 33 | "dartType": "String" 34 | }, 35 | { 36 | "name": "logline", 37 | "columnType": 0, 38 | "isNullable": false, 39 | "dartType": "String" 40 | }, 41 | { 42 | "name": "directorName", 43 | "columnType": 0, 44 | "isNullable": false, 45 | "dartType": "String" 46 | } 47 | ], 48 | "foreignKeys": [], 49 | "indexes": [ 50 | { 51 | "indexName": "movie_pkey", 52 | "elements": [ 53 | { 54 | "type": 0, 55 | "definition": "id" 56 | } 57 | ], 58 | "type": "btree", 59 | "isUnique": true, 60 | "isPrimary": true 61 | } 62 | ], 63 | "managed": true 64 | } 65 | ], 66 | "installedModules": [ 67 | { 68 | "module": "serverpod", 69 | "version": "20240115074235544" 70 | }, 71 | { 72 | "module": "movieapp", 73 | "version": "20240418143611250" 74 | } 75 | ], 76 | "migrationApiVersion": 1 77 | } -------------------------------------------------------------------------------- /movieapp_flutter/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /movieapp_server/lib/server.dart: -------------------------------------------------------------------------------- 1 | import 'package:serverpod/serverpod.dart'; 2 | 3 | import 'package:movieapp_server/src/web/routes/root.dart'; 4 | import 'src/generated/protocol.dart'; 5 | import 'src/generated/endpoints.dart'; 6 | 7 | import 'package:serverpod_auth_server/module.dart' as auth; 8 | import 'package:serverpod_cloud_storage_s3/serverpod_cloud_storage_s3.dart' as s3; 9 | 10 | // This is the starting point of your Serverpod server. In most cases, you will 11 | // only need to make additions to this file if you add future calls, are 12 | // configuring Relic (Serverpod's web-server), or need custom setup work. 13 | 14 | void run(List args) async { 15 | // Initialize Serverpod and connect it with your generated code. 16 | final pod = Serverpod( 17 | args, 18 | Protocol(), 19 | Endpoints(), 20 | ); 21 | 22 | // If you are using any future calls, they need to be registered here. 23 | // pod.registerFutureCall(ExampleFutureCall(), 'exampleFutureCall'); 24 | 25 | auth.AuthConfig.set( 26 | auth.AuthConfig( 27 | sendValidationEmail: (session, email, validationCode) async { 28 | // TODO: send email to user with validation code 29 | print(validationCode); 30 | 31 | return true; 32 | }, 33 | sendPasswordResetEmail: (session, userInfo, validationCode) async { 34 | // TODO: send email to user with validation code 35 | print(validationCode); 36 | 37 | return true; 38 | }, 39 | ), 40 | ); 41 | 42 | // Setup a default page at the web root. 43 | pod.webServer.addRoute(RouteRoot(), '/'); 44 | pod.webServer.addRoute(RouteRoot(), '/index.html'); 45 | // Serve all files in the /static directory. 46 | pod.webServer.addRoute( 47 | RouteStaticDirectory(serverDirectory: 'static', basePath: '/'), 48 | '/*', 49 | ); 50 | 51 | pod.addCloudStorage(s3.S3CloudStorage( 52 | serverpod: pod, 53 | storageId: 'public', 54 | public: true, 55 | region: 'ca-central-1', 56 | bucket: 'listie-dev', 57 | )); 58 | 59 | // Start the server. 60 | await pod.start(); 61 | } 62 | -------------------------------------------------------------------------------- /movieapp_flutter/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | movieapp_flutter 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /movieapp_server/migrations/20240422145132179/definition_project.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleName": "movieapp", 3 | "tables": [ 4 | { 5 | "name": "movie", 6 | "dartName": "Movie", 7 | "module": "movieapp", 8 | "schema": "public", 9 | "columns": [ 10 | { 11 | "name": "id", 12 | "columnType": 2, 13 | "isNullable": false, 14 | "columnDefault": "nextval('movie_id_seq'::regclass)", 15 | "dartType": "int?" 16 | }, 17 | { 18 | "name": "title", 19 | "columnType": 0, 20 | "isNullable": false, 21 | "dartType": "String" 22 | }, 23 | { 24 | "name": "year", 25 | "columnType": 2, 26 | "isNullable": false, 27 | "dartType": "int" 28 | }, 29 | { 30 | "name": "imageUrl", 31 | "columnType": 0, 32 | "isNullable": false, 33 | "dartType": "String" 34 | }, 35 | { 36 | "name": "logline", 37 | "columnType": 0, 38 | "isNullable": false, 39 | "dartType": "String" 40 | }, 41 | { 42 | "name": "directorName", 43 | "columnType": 0, 44 | "isNullable": false, 45 | "dartType": "String" 46 | } 47 | ], 48 | "foreignKeys": [], 49 | "indexes": [ 50 | { 51 | "indexName": "movie_pkey", 52 | "elements": [ 53 | { 54 | "type": 0, 55 | "definition": "id" 56 | } 57 | ], 58 | "type": "btree", 59 | "isUnique": true, 60 | "isPrimary": true 61 | } 62 | ], 63 | "managed": true 64 | } 65 | ], 66 | "installedModules": [ 67 | { 68 | "module": "serverpod", 69 | "version": "20240115074235544" 70 | }, 71 | { 72 | "module": "serverpod_auth", 73 | "version": "20240115074239642" 74 | }, 75 | { 76 | "module": "movieapp", 77 | "version": "20240418143756623" 78 | } 79 | ], 80 | "migrationApiVersion": 1 81 | } -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/cloudfront-web.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | alb_origin_id = "${var.project_name}-web" 3 | } 4 | 5 | resource "aws_cloudfront_distribution" "web" { 6 | origin { 7 | origin_id = local.alb_origin_id 8 | domain_name = aws_lb.serverpod.dns_name 9 | custom_origin_config { 10 | http_port = 80 11 | https_port = 443 12 | origin_protocol_policy = "http-only" 13 | origin_ssl_protocols = ["SSLv3"] 14 | } 15 | } 16 | enabled = true 17 | 18 | aliases = ["${var.subdomain_web}.${var.top_domain}", "${var.top_domain}"] 19 | 20 | default_cache_behavior { 21 | allowed_methods = ["HEAD", "DELETE", "POST", "GET", "OPTIONS", "PUT", "PATCH"] 22 | cached_methods = ["HEAD", "GET"] 23 | target_origin_id = local.alb_origin_id 24 | 25 | forwarded_values { 26 | query_string = true 27 | 28 | cookies { 29 | forward = "all" 30 | } 31 | 32 | headers = ["*"] 33 | } 34 | 35 | viewer_protocol_policy = "redirect-to-https" 36 | min_ttl = 0 37 | default_ttl = 0 38 | max_ttl = 0 39 | } 40 | 41 | price_class = "PriceClass_100" 42 | 43 | viewer_certificate { 44 | acm_certificate_arn = var.cloudfront_certificate_arn 45 | ssl_support_method = "sni-only" 46 | } 47 | 48 | restrictions { 49 | geo_restriction { 50 | restriction_type = "none" 51 | } 52 | } 53 | } 54 | 55 | resource "aws_route53_record" "web" { 56 | zone_id = var.hosted_zone_id 57 | name = "${var.subdomain_web}.${var.top_domain}" 58 | type = "CNAME" 59 | ttl = "300" 60 | records = ["${aws_cloudfront_distribution.web.domain_name}"] 61 | } 62 | 63 | resource "aws_route53_record" "web_top_domain" { 64 | count = var.use_top_domain_for_web ? 1 : 0 65 | zone_id = var.hosted_zone_id 66 | name = var.top_domain 67 | type = "A" 68 | alias { 69 | name = aws_cloudfront_distribution.web.domain_name 70 | zone_id = aws_cloudfront_distribution.web.hosted_zone_id 71 | evaluate_target_health = false 72 | } 73 | } -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Movieapp Flutter 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | movieapp_flutter 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | NSPhotoLibraryUsageDescription 49 | For uploading photos 50 | NSCameraUsageDescription 51 | For uploading photos 52 | NSMicrophoneUsageDescription 53 | For uploading photos 54 | 55 | 56 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/storage.tf: -------------------------------------------------------------------------------- 1 | # S3 buckets 2 | resource "aws_s3_bucket" "public_storage" { 3 | bucket = var.public_storage_bucket_name 4 | force_destroy = true 5 | 6 | tags = { 7 | Name = "${var.project_name} public storage" 8 | } 9 | } 10 | 11 | resource "aws_s3_bucket_acl" "public_storage" { 12 | bucket = aws_s3_bucket.public_storage.id 13 | acl = "private" 14 | } 15 | 16 | resource "aws_s3_bucket" "private_storage" { 17 | bucket = var.private_storage_bucket_name 18 | force_destroy = true 19 | 20 | tags = { 21 | Name = "${var.project_name} private storage" 22 | } 23 | } 24 | 25 | resource "aws_s3_bucket_acl" "private_storage" { 26 | bucket = aws_s3_bucket.private_storage.id 27 | acl = "private" 28 | } 29 | 30 | locals { 31 | s3_origin_id = "${var.project_name}-storage" 32 | } 33 | 34 | resource "aws_cloudfront_distribution" "public_storage" { 35 | origin { 36 | origin_id = local.s3_origin_id 37 | domain_name = aws_s3_bucket.public_storage.bucket_regional_domain_name 38 | } 39 | enabled = true 40 | 41 | aliases = ["${var.subdomain_storage}.${var.top_domain}"] 42 | 43 | default_cache_behavior { 44 | allowed_methods = ["GET", "HEAD"] 45 | cached_methods = ["GET", "HEAD"] 46 | target_origin_id = local.s3_origin_id 47 | 48 | forwarded_values { 49 | query_string = false 50 | cookies { 51 | forward = "none" 52 | } 53 | } 54 | viewer_protocol_policy = "redirect-to-https" 55 | min_ttl = 0 56 | default_ttl = 3600 57 | max_ttl = 86400 58 | } 59 | 60 | price_class = "PriceClass_100" 61 | 62 | viewer_certificate { 63 | acm_certificate_arn = var.cloudfront_certificate_arn 64 | ssl_support_method = "sni-only" 65 | } 66 | 67 | restrictions { 68 | geo_restriction { 69 | restriction_type = "none" 70 | } 71 | } 72 | } 73 | 74 | resource "aws_route53_record" "public_storage" { 75 | zone_id = var.hosted_zone_id 76 | name = "${var.subdomain_storage}.${var.top_domain}" 77 | type = "CNAME" 78 | ttl = "300" 79 | records = ["${aws_cloudfront_distribution.public_storage.domain_name}"] 80 | } -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/database.tf: -------------------------------------------------------------------------------- 1 | resource "aws_db_instance" "postgres" { 2 | identifier = var.project_name 3 | allocated_storage = 10 4 | engine = "postgres" 5 | engine_version = "14.2" 6 | instance_class = "db.t3.micro" 7 | db_name = "serverpod" 8 | username = "postgres" 9 | password = var.DATABASE_PASSWORD_PRODUCTION 10 | skip_final_snapshot = true 11 | vpc_security_group_ids = [ 12 | aws_security_group.database.id 13 | ] 14 | publicly_accessible = true 15 | db_subnet_group_name = module.vpc.database_subnet_group_name 16 | } 17 | 18 | resource "aws_route53_record" "database" { 19 | zone_id = var.hosted_zone_id 20 | name = "${var.subdomain_database}.${var.top_domain}" 21 | type = "CNAME" 22 | ttl = "300" 23 | records = ["${aws_db_instance.postgres.address}"] 24 | } 25 | 26 | # Makes the database accessible from anywhere. 27 | resource "aws_security_group" "database" { 28 | name = "${var.project_name}-database" 29 | ingress { 30 | from_port = 5432 31 | to_port = 5432 32 | protocol = "tcp" 33 | cidr_blocks = ["0.0.0.0/0"] 34 | } 35 | } 36 | 37 | # Staging 38 | resource "aws_db_instance" "postgres_staging" { 39 | count = var.enable_staging_server ? 1 : 0 40 | 41 | identifier = "${var.project_name}-staging" 42 | allocated_storage = 10 43 | engine = "postgres" 44 | engine_version = "14.2" 45 | instance_class = "db.t3.micro" 46 | db_name = "serverpod" 47 | username = "postgres" 48 | password = var.DATABASE_PASSWORD_STAGING 49 | skip_final_snapshot = true 50 | vpc_security_group_ids = [ 51 | aws_security_group.database.id 52 | ] 53 | publicly_accessible = true 54 | db_subnet_group_name = module.vpc.database_subnet_group_name 55 | } 56 | 57 | resource "aws_route53_record" "database_staging" { 58 | count = var.enable_staging_server ? 1 : 0 59 | 60 | zone_id = var.hosted_zone_id 61 | name = "${var.subdomain_database_staging}.${var.top_domain}" 62 | type = "CNAME" 63 | ttl = "300" 64 | records = ["${aws_db_instance.postgres_staging[0].address}"] 65 | } -------------------------------------------------------------------------------- /movieapp_flutter/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | id "dev.flutter.flutter-gradle-plugin" 5 | } 6 | 7 | def localProperties = new Properties() 8 | def localPropertiesFile = rootProject.file('local.properties') 9 | if (localPropertiesFile.exists()) { 10 | localPropertiesFile.withReader('UTF-8') { reader -> 11 | localProperties.load(reader) 12 | } 13 | } 14 | 15 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 16 | if (flutterVersionCode == null) { 17 | flutterVersionCode = '1' 18 | } 19 | 20 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 21 | if (flutterVersionName == null) { 22 | flutterVersionName = '1.0' 23 | } 24 | 25 | android { 26 | namespace "com.example.movieapp_flutter" 27 | compileSdk flutter.compileSdkVersion 28 | ndkVersion flutter.ndkVersion 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | 35 | kotlinOptions { 36 | jvmTarget = '1.8' 37 | } 38 | 39 | sourceSets { 40 | main.java.srcDirs += 'src/main/kotlin' 41 | } 42 | 43 | defaultConfig { 44 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 45 | applicationId "com.example.movieapp_flutter" 46 | // You can update the following values to match your application needs. 47 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 48 | minSdkVersion flutter.minSdkVersion 49 | targetSdkVersion flutter.targetSdkVersion 50 | versionCode flutterVersionCode.toInteger() 51 | versionName flutterVersionName 52 | } 53 | 54 | buildTypes { 55 | release { 56 | // TODO: Add your own signing config for the release build. 57 | // Signing with the debug keys for now, so `flutter run --release` works. 58 | signingConfig signingConfigs.debug 59 | } 60 | } 61 | } 62 | 63 | flutter { 64 | source '../..' 65 | } 66 | 67 | dependencies {} 68 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:movieapp_flutter/features/app_user/presentation/cubits/cubit/app_user_cubit.dart'; 4 | import 'package:movieapp_flutter/core/router/app_router.dart'; 5 | import 'package:movieapp_flutter/dependencies.dart'; 6 | import 'package:movieapp_flutter/features/asset/presentation/bloc/asset_bloc.dart'; 7 | import 'package:movieapp_flutter/features/auth/presentation/bloc/auth_bloc.dart'; 8 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_list/movie_list_bloc.dart'; 9 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_detail/movie_detail_bloc.dart'; 10 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_manage/movie_manage_bloc.dart'; 11 | 12 | void main() async { 13 | WidgetsFlutterBinding.ensureInitialized(); 14 | await initDependencies(); 15 | runApp( 16 | MultiBlocProvider( 17 | providers: [ 18 | BlocProvider( 19 | create: (_) => serviceLocator(), 20 | ), 21 | BlocProvider( 22 | create: (_) => serviceLocator()..add(AuthIsUserLoggedInEvent()), 23 | ), 24 | BlocProvider( 25 | create: (_) => serviceLocator(), 26 | ), 27 | BlocProvider( 28 | create: (_) => serviceLocator(), 29 | ), 30 | BlocProvider( 31 | create: (_) => serviceLocator(), 32 | ), 33 | BlocProvider( 34 | create: (_) => serviceLocator(), 35 | ), 36 | ], 37 | child: const MyApp(), 38 | ), 39 | ); 40 | } 41 | 42 | class MyApp extends StatelessWidget { 43 | const MyApp({super.key}); 44 | 45 | @override 46 | Widget build(BuildContext context) { 47 | return BlocListener( 48 | listener: (context, state) { 49 | AppRouter.router.refresh(); 50 | }, 51 | child: MaterialApp.router( 52 | title: "Clean Serverpod", 53 | theme: ThemeData.dark(), 54 | debugShowCheckedModeBanner: false, 55 | routerConfig: AppRouter.router, 56 | ), 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/asset/presentation/widgets/upload_file_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:image_picker/image_picker.dart'; 4 | import 'package:movieapp_flutter/features/asset/presentation/bloc/asset_bloc.dart'; 5 | 6 | class UploadFileWidget extends StatelessWidget { 7 | final String url; 8 | final String label; 9 | final Function(String url) onComplete; 10 | const UploadFileWidget({ 11 | super.key, 12 | required this.url, 13 | required this.onComplete, 14 | this.label = 'File', 15 | }); 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return BlocConsumer( 20 | listener: (context, state) { 21 | if (state is AssetStateSuccess) { 22 | onComplete(state.url); 23 | } 24 | }, 25 | builder: (context, state) { 26 | return Row( 27 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 28 | children: [ 29 | Column( 30 | mainAxisSize: MainAxisSize.min, 31 | crossAxisAlignment: CrossAxisAlignment.start, 32 | children: [ 33 | Text(label), 34 | if (url.isNotEmpty) 35 | Image.network( 36 | url, 37 | width: 50, 38 | height: 50, 39 | fit: BoxFit.contain, 40 | ), 41 | ], 42 | ), 43 | Row( 44 | mainAxisSize: MainAxisSize.min, 45 | children: [ 46 | ElevatedButton( 47 | onPressed: () async { 48 | final picker = ImagePicker(); 49 | final image = await picker.pickImage(source: ImageSource.gallery); 50 | 51 | if (image != null) { 52 | if (context.mounted) { 53 | context.read().add(AssetUploadImageEvent(image: image)); 54 | } 55 | } 56 | }, 57 | child: Text(url.isEmpty ? "Upload" : "Replace")) 58 | ], 59 | ) 60 | ], 61 | ); 62 | }, 63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/bloc/movie_manage/movie_manage_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter_bloc/flutter_bloc.dart'; 5 | import 'package:movieapp_client/movieapp_client.dart'; 6 | import 'package:movieapp_flutter/features/movie/domain/usecases/delete_movie.dart'; 7 | import 'package:movieapp_flutter/features/movie/domain/usecases/retrieve_movie.dart'; 8 | import 'package:movieapp_flutter/features/movie/domain/usecases/save_movie.dart'; 9 | 10 | part 'movie_manage_event.dart'; 11 | part 'movie_manage_state.dart'; 12 | 13 | class MovieManageBloc extends Bloc { 14 | final RetrieveMovieUseCase retrieveMovie; 15 | final SaveMovieUseCase saveMovie; 16 | final DeleteMovieUseCase deleteMovie; 17 | 18 | MovieManageBloc({ 19 | required this.retrieveMovie, 20 | required this.saveMovie, 21 | required this.deleteMovie, 22 | }) : super(MovieManageStateInitial()) { 23 | on((event, emit) => emit(MovieManageStateLoading())); 24 | on(_onRetrieveMovie); 25 | on(_onSaveMovie); 26 | on(_onDeleteMovie); 27 | } 28 | 29 | FutureOr _onRetrieveMovie(MovieManageRetrieveEvent event, Emitter emit) async { 30 | final result = await retrieveMovie(RetrieveMovieParams(id: event.id)); 31 | 32 | result.fold( 33 | (failure) => emit(MovieManageStateFailure(failure.message)), 34 | (movie) => emit(MovieManageStateRetrieveSuccess(movie)), 35 | ); 36 | } 37 | 38 | FutureOr _onSaveMovie(MovieManageSaveEvent event, Emitter emit) async { 39 | final result = await saveMovie(SaveMovieParams(movie: event.movie)); 40 | result.fold( 41 | (failure) => emit(MovieManageStateFailure(failure.message)), 42 | (movie) => emit(MovieManageStateSaveSuccess(movie)), 43 | ); 44 | } 45 | 46 | FutureOr _onDeleteMovie(MovieManageDeleteEvent event, Emitter emit) async { 47 | final result = await deleteMovie(DeleteMovieParams(id: event.movieId)); 48 | 49 | result.fold( 50 | (failure) => emit(MovieManageStateFailure(failure.message)), 51 | (_) => emit(MovieManageStateDeleteSuccess()), 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/redis.tf: -------------------------------------------------------------------------------- 1 | resource "aws_elasticache_cluster" "redis" { 2 | count = var.enable_redis ? 1 : 0 3 | 4 | cluster_id = var.project_name 5 | engine = "redis" 6 | node_type = "cache.t4g.micro" 7 | num_cache_nodes = 1 8 | engine_version = "6.x" 9 | port = 6379 10 | apply_immediately = true 11 | security_group_ids = [aws_security_group.redis[0].id] 12 | subnet_group_name = aws_elasticache_subnet_group.redis[0].name 13 | } 14 | 15 | resource "aws_route53_record" "redis" { 16 | count = var.enable_redis ? 1 : 0 17 | 18 | zone_id = var.hosted_zone_id 19 | name = "${var.subdomain_redis}.${var.top_domain}" 20 | type = "CNAME" 21 | ttl = "300" 22 | records = ["${aws_elasticache_cluster.redis[0].cache_nodes[0].address}"] 23 | } 24 | 25 | # Makes Redis accessible from the serverpod only. 26 | resource "aws_security_group" "redis" { 27 | count = var.enable_redis ? 1 : 0 28 | 29 | name = "${var.project_name}-redis" 30 | ingress { 31 | from_port = 6379 32 | to_port = 6379 33 | protocol = "tcp" 34 | security_groups = [aws_security_group.serverpod.id] 35 | } 36 | 37 | vpc_id = module.vpc.vpc_id 38 | } 39 | 40 | resource "aws_elasticache_subnet_group" "redis" { 41 | count = var.enable_redis ? 1 : 0 42 | 43 | name = "${var.project_name}-subnet" 44 | subnet_ids = module.vpc.public_subnets 45 | } 46 | 47 | # Staging 48 | resource "aws_elasticache_cluster" "redis_staging" { 49 | count = var.enable_redis && var.enable_staging_server ? 1 : 0 50 | 51 | cluster_id = var.project_name 52 | engine = "redis" 53 | node_type = "cache.t4g.micro" 54 | num_cache_nodes = 1 55 | engine_version = "6.x" 56 | port = 6379 57 | apply_immediately = true 58 | security_group_ids = [aws_security_group.redis[0].id] 59 | subnet_group_name = aws_elasticache_subnet_group.redis[0].name 60 | } 61 | 62 | resource "aws_route53_record" "redis_staging" { 63 | count = var.enable_redis && var.enable_staging_server ? 1 : 0 64 | 65 | zone_id = var.hosted_zone_id 66 | name = "${var.subdomain_redis_staging}.${var.top_domain}" 67 | type = "CNAME" 68 | ttl = "300" 69 | records = ["${aws_elasticache_cluster.redis_staging[0].cache_nodes[0].address}"] 70 | } -------------------------------------------------------------------------------- /movieapp_flutter/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 32 | 33 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /movieapp_server/migrations/20240418143756623/migration.json: -------------------------------------------------------------------------------- 1 | { 2 | "actions": [ 3 | { 4 | "type": "deleteTable", 5 | "deleteTable": "movie" 6 | }, 7 | { 8 | "type": "createTable", 9 | "createTable": { 10 | "name": "movie", 11 | "dartName": "Movie", 12 | "module": "movieapp", 13 | "schema": "public", 14 | "columns": [ 15 | { 16 | "name": "id", 17 | "columnType": 2, 18 | "isNullable": false, 19 | "columnDefault": "nextval('movie_id_seq'::regclass)", 20 | "dartType": "int?" 21 | }, 22 | { 23 | "name": "title", 24 | "columnType": 0, 25 | "isNullable": false, 26 | "dartType": "String" 27 | }, 28 | { 29 | "name": "year", 30 | "columnType": 2, 31 | "isNullable": false, 32 | "dartType": "int" 33 | }, 34 | { 35 | "name": "imageUrl", 36 | "columnType": 0, 37 | "isNullable": false, 38 | "dartType": "String" 39 | }, 40 | { 41 | "name": "logline", 42 | "columnType": 0, 43 | "isNullable": false, 44 | "dartType": "String" 45 | }, 46 | { 47 | "name": "directorName", 48 | "columnType": 0, 49 | "isNullable": false, 50 | "dartType": "String" 51 | } 52 | ], 53 | "foreignKeys": [], 54 | "indexes": [ 55 | { 56 | "indexName": "movie_pkey", 57 | "elements": [ 58 | { 59 | "type": 0, 60 | "definition": "id" 61 | } 62 | ], 63 | "type": "btree", 64 | "isUnique": true, 65 | "isPrimary": true 66 | } 67 | ], 68 | "managed": true 69 | } 70 | } 71 | ], 72 | "warnings": [ 73 | { 74 | "type": "tableDropped", 75 | "message": "One or more columns are added to table \"movie\" which cannot be added in a table migration. The complete table will be deleted and recreated.", 76 | "table": "movie", 77 | "columns": [ 78 | "directorName" 79 | ], 80 | "destrucive": true 81 | } 82 | ], 83 | "migrationApiVersion": 1 84 | } -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/widgets/movie_list_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:movieapp_flutter/core/widgets/loader.dart'; 5 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_list/movie_list_bloc.dart'; 6 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_list/movie_list_event.dart'; 7 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_list/movie_list_state.dart'; 8 | import 'package:movieapp_flutter/features/movie/presentation/pages/movie_detail_page.dart'; 9 | 10 | class MovieListWidget extends StatefulWidget { 11 | const MovieListWidget({super.key}); 12 | 13 | @override 14 | State createState() => _MovieListWidgetState(); 15 | } 16 | 17 | class _MovieListWidgetState extends State { 18 | @override 19 | void initState() { 20 | super.initState(); 21 | 22 | context.read().add(FetchMoviesEvent()); 23 | } 24 | 25 | @override 26 | void dispose() { 27 | super.dispose(); 28 | } 29 | 30 | @override 31 | Widget build(BuildContext context) { 32 | return BlocBuilder( 33 | builder: (context, state) { 34 | switch (state) { 35 | case MovieListStateInitial(): 36 | return const SizedBox.shrink(); 37 | case MovieListStateLoading(): 38 | return const Loader(); 39 | case MovieListStateSuccess(): 40 | final movies = state.movies; 41 | return ListView.builder( 42 | itemCount: movies.length, 43 | itemBuilder: (context, index) { 44 | final movie = movies[index]; 45 | return Card( 46 | child: ListTile( 47 | title: Text(movie.title), 48 | subtitle: Text("Released in ${movie.year}"), 49 | onTap: () { 50 | context.push(MovieDetailPage.route(movie.id)); 51 | }, 52 | ), 53 | ); 54 | }, 55 | ); 56 | case MovieListStateFailure(): 57 | return Center( 58 | child: Text(state.message), 59 | ); 60 | } 61 | }, 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /movieapp_flutter/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/code-deploy.tf: -------------------------------------------------------------------------------- 1 | 2 | # Code deploy setup 3 | 4 | resource "aws_iam_instance_profile" "codedeploy_profile" { 5 | name = "${var.project_name}-codedeploy-profile" 6 | role = aws_iam_role.codedeploy_role.name 7 | } 8 | 9 | resource "aws_iam_role" "codedeploy_role" { 10 | name = "${var.project_name}-codedeploy-role" 11 | 12 | assume_role_policy = < 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/core/router/app_router.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_bloc/flutter_bloc.dart'; 2 | import 'package:go_router/go_router.dart'; 3 | import 'package:movieapp_flutter/features/app_user/presentation/cubits/cubit/app_user_cubit.dart'; 4 | import 'package:movieapp_flutter/features/auth/presentation/pages/login_page.dart'; 5 | import 'package:movieapp_flutter/features/auth/presentation/pages/register_confirmation_page.dart'; 6 | import 'package:movieapp_flutter/features/auth/presentation/pages/register_page.dart'; 7 | import 'package:movieapp_flutter/features/movie/presentation/pages/movie_detail_page.dart'; 8 | import 'package:movieapp_flutter/features/movie/presentation/pages/movie_edit_page.dart'; 9 | import 'package:movieapp_flutter/features/movie/presentation/pages/movie_list_page.dart'; 10 | 11 | class AppRouter { 12 | static GoRouter router = GoRouter( 13 | initialLocation: LoginPage.route(), 14 | routes: [ 15 | GoRoute( 16 | path: LoginPage.route(), 17 | builder: (context, _) => const LoginPage(), 18 | ), 19 | GoRoute( 20 | path: RegisterPage.route(), 21 | builder: (context, _) => const RegisterPage(), 22 | ), 23 | GoRoute( 24 | path: RegisterConfirmationPage.route(), 25 | builder: (context, _) => const RegisterConfirmationPage(), 26 | ), 27 | GoRoute( 28 | path: MovieListPage.route(), 29 | builder: (context, _) => const MovieListPage(), 30 | ), 31 | GoRoute( 32 | path: MovieEditPage.routeNew(), 33 | builder: (context, _) => const MovieEditPage(), 34 | ), 35 | GoRoute( 36 | path: MovieEditPage.route(), 37 | builder: (context, state) => MovieEditPage( 38 | movieId: int.parse(state.pathParameters['id'] ?? '0'), 39 | ), 40 | ), 41 | GoRoute( 42 | path: MovieDetailPage.route(), 43 | builder: (context, state) => MovieDetailPage( 44 | movieId: int.parse( 45 | state.pathParameters['id'] ?? '0', 46 | ), 47 | ), 48 | ), 49 | ], 50 | redirect: (context, state) { 51 | final userState = context.read().state; 52 | 53 | final publicRoutes = [ 54 | LoginPage.route(), 55 | RegisterPage.route(), 56 | RegisterConfirmationPage.route(), 57 | ]; 58 | 59 | if (!publicRoutes.contains(state.matchedLocation)) { 60 | if (userState is AppUserInitial) { 61 | return LoginPage.route(); 62 | } 63 | } 64 | 65 | return null; 66 | }, 67 | ); 68 | } 69 | -------------------------------------------------------------------------------- /.github/workflows/deployment-aws.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to AWS 2 | on: 3 | push: 4 | branches: [ deployment-aws-production, deployment-aws-staging ] 5 | workflow_dispatch: 6 | inputs: 7 | target: 8 | description: 'Target' 9 | required: true 10 | default: 'production' 11 | type: choice 12 | options: 13 | - 'staging' 14 | - 'production' 15 | jobs: 16 | deploy: 17 | name: Deploy to AWS 18 | runs-on: ubuntu-latest 19 | 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@v2 23 | with: 24 | submodules: recursive 25 | 26 | - name: Setup Dart SDK 27 | uses: dart-lang/setup-dart@v1.3 28 | with: 29 | sdk: 3.0 30 | 31 | - name: Configure AWS credentials 32 | uses: aws-actions/configure-aws-credentials@v1 33 | with: 34 | aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} 35 | aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 36 | aws-region: us-west-2 37 | 38 | - name: Create passwords file 39 | working-directory: movieapp_server 40 | shell: bash 41 | env: 42 | SERVERPOD_PASSWORDS: ${{ secrets.SERVERPOD_PASSWORDS }} 43 | run: | 44 | pwd 45 | echo "$SERVERPOD_PASSWORDS" > config/passwords.yaml 46 | ls config/ 47 | 48 | - name: Get Dart packages 49 | working-directory: movieapp_server 50 | run: dart pub get 51 | 52 | - name: Compile server 53 | working-directory: movieapp_server 54 | run: dart compile kernel bin/main.dart 55 | 56 | - name: Create CodeDeploy Deployment 57 | id: deploy 58 | env: 59 | PROJECT_NAME: movieapp 60 | AWS_NAME: movieapp 61 | DEPLOYMENT_BUCKET: movieapp-deployment-1559488 62 | TARGET: ${{ github.event.inputs.target }} 63 | run: | 64 | # Deploy server to AWS 65 | TARGET="${TARGET:=${GITHUB_REF##*-}}" 66 | echo "Deploying to target: $TARGET" 67 | mkdir -p vendor 68 | cp "${PROJECT_NAME}_server/deploy/aws/scripts/appspec.yml" appspec.yml 69 | zip -r deployment.zip . 70 | aws s3 cp deployment.zip "s3://${DEPLOYMENT_BUCKET}/deployment.zip" 71 | aws deploy create-deployment \ 72 | --application-name "${AWS_NAME}-app" \ 73 | --deployment-group-name "${AWS_NAME}-${TARGET}-group" \ 74 | --deployment-config-name CodeDeployDefault.OneAtATime \ 75 | --s3-location "bucket=${DEPLOYMENT_BUCKET},key=deployment.zip,bundleType=zip" 76 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/auth/data/repositories/auth_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:movieapp_flutter/core/entities/user.dart'; 3 | import 'package:movieapp_flutter/core/error/exceptions.dart'; 4 | import 'package:movieapp_flutter/core/error/failure.dart'; 5 | import 'package:movieapp_flutter/features/auth/data/datasources/auth_datasource.dart'; 6 | import 'package:movieapp_flutter/features/auth/domain/respositories/auth_repository.dart'; 7 | 8 | class AuthRepositoryImpl implements AuthRepository { 9 | final AuthDataSource dataSource; 10 | 11 | const AuthRepositoryImpl(this.dataSource); 12 | 13 | @override 14 | Either currentUser() { 15 | final user = dataSource.currentUser(); 16 | 17 | if (user == null) { 18 | return left(const Failure('User not logged in')); 19 | } 20 | 21 | return right(user); 22 | } 23 | 24 | @override 25 | Future> loginWithEmailPassword({ 26 | required String email, 27 | required String password, 28 | }) async { 29 | try { 30 | final result = await dataSource.loginWithEmailAndPassword( 31 | email: email, 32 | password: password, 33 | ); 34 | 35 | return right(result); 36 | } on ServerException catch (e) { 37 | return left(Failure(e.message)); 38 | } 39 | } 40 | 41 | @override 42 | Future> registerWithEmailAndPassword({ 43 | required String email, 44 | required String password, 45 | required String username, 46 | }) async { 47 | try { 48 | final success = await dataSource.registerWithEmailAndPassword( 49 | email: email, 50 | password: password, 51 | username: username, 52 | ); 53 | 54 | if (success) { 55 | return right(true); 56 | } 57 | 58 | return left(const Failure("Could not register")); 59 | } on ServerException catch (e) { 60 | return left(Failure(e.message)); 61 | } 62 | } 63 | 64 | @override 65 | Future> confirmRegistration({ 66 | required String email, 67 | required String verificationCode, 68 | }) async { 69 | try { 70 | final user = await dataSource.confirmRegistration( 71 | email: email, 72 | verificationCode: verificationCode, 73 | ); 74 | 75 | return right(user); 76 | } on ServerException catch (e) { 77 | return left(Failure(e.message)); 78 | } 79 | } 80 | 81 | @override 82 | Future> logout() async { 83 | try { 84 | await dataSource.logout(); 85 | return right(null); 86 | } on ServerException catch (e) { 87 | return left(Failure(e.message)); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /movieapp_server/deploy/aws/terraform/instances.tf: -------------------------------------------------------------------------------- 1 | 2 | # EC2 auto scaling cluster and security groups 3 | 4 | data "aws_availability_zones" "available" { 5 | state = "available" 6 | } 7 | 8 | # TODO: Fix? 9 | data "aws_ami" "amazon-linux" { 10 | most_recent = true 11 | owners = ["amazon"] 12 | 13 | filter { 14 | name = "name" 15 | values = ["amzn-ami-hvm-*-x86_64-ebs"] 16 | } 17 | } 18 | 19 | resource "aws_launch_configuration" "serverpod" { 20 | name_prefix = "${var.project_name}-" 21 | image_id = var.instance_ami 22 | # image_id = data.aws_ami.amazon-linux.id 23 | instance_type = var.instance_type 24 | user_data = templatefile("init-script.sh", { runmode = "production" }) 25 | 26 | security_groups = [ 27 | aws_security_group.serverpod.id, 28 | aws_security_group.ssh.id 29 | ] 30 | 31 | iam_instance_profile = aws_iam_instance_profile.codedeploy_profile.name 32 | 33 | lifecycle { 34 | create_before_destroy = true 35 | } 36 | } 37 | 38 | resource "aws_autoscaling_group" "serverpod" { 39 | min_size = var.autoscaling_min_size 40 | max_size = var.autoscaling_max_size 41 | desired_capacity = var.autoscaling_desired_capacity 42 | launch_configuration = aws_launch_configuration.serverpod.name 43 | vpc_zone_identifier = module.vpc.public_subnets 44 | 45 | target_group_arns = [ 46 | aws_lb_target_group.api.arn, 47 | aws_lb_target_group.insights.arn, 48 | aws_lb_target_group.web.arn 49 | ] 50 | 51 | tag { 52 | key = "Name" 53 | value = "${var.project_name}-serverpod" 54 | propagate_at_launch = true 55 | } 56 | 57 | tag { 58 | key = "CodeDeploy" 59 | value = var.project_name 60 | propagate_at_launch = true 61 | } 62 | } 63 | 64 | resource "aws_security_group" "serverpod" { 65 | name = "${var.project_name}-serverpod" 66 | 67 | ingress { 68 | from_port = 8080 69 | to_port = 8082 70 | protocol = "tcp" 71 | security_groups = [aws_security_group.api.id] 72 | } 73 | 74 | egress { 75 | from_port = 0 76 | to_port = 0 77 | protocol = "-1" 78 | cidr_blocks = ["0.0.0.0/0"] 79 | } 80 | 81 | vpc_id = module.vpc.vpc_id 82 | } 83 | 84 | resource "aws_security_group" "ssh" { 85 | name = "${var.project_name}-ssh" 86 | 87 | ingress { 88 | from_port = 22 89 | to_port = 22 90 | protocol = "tcp" 91 | cidr_blocks = ["0.0.0.0/0"] 92 | } 93 | 94 | egress { 95 | from_port = 0 96 | to_port = 0 97 | protocol = "-1" 98 | cidr_blocks = ["0.0.0.0/0"] 99 | } 100 | 101 | vpc_id = module.vpc.vpc_id 102 | } 103 | -------------------------------------------------------------------------------- /movieapp_server/deploy/gcp/terraform_gce/main.tf: -------------------------------------------------------------------------------- 1 | # Set up and configure Terraform and the Google Cloud provider. 2 | terraform { 3 | required_providers { 4 | google = { 5 | source = "hashicorp/google" 6 | version = "4.51.0" 7 | } 8 | } 9 | } 10 | 11 | provider "google" { 12 | credentials = file("credentials.json") 13 | 14 | project = var.project 15 | region = var.region 16 | zone = var.zone 17 | } 18 | 19 | # Add a Serverpod module configured for production. Full documentation on all 20 | # options is available at: 21 | # https://github.com/serverpod/terraform-google-serverpod-cloud-engine 22 | 23 | module "serverpod_production" { 24 | # References the Serverpod module from GitHub. 25 | source = "github.com/serverpod/terraform-google-serverpod-cloud-engine?ref=stable-1.1" 26 | 27 | # Required parameters. 28 | project = var.project 29 | service_account_email = var.service_account_email 30 | 31 | runmode = "production" 32 | 33 | region = var.region 34 | zone = var.zone 35 | 36 | dns_managed_zone = var.dns_managed_zone 37 | top_domain = var.top_domain 38 | 39 | # Size of the auto scaling group. 40 | autoscaling_min_size = 1 41 | autoscaling_max_size = 2 42 | 43 | # Password for the production database. 44 | database_password = var.DATABASE_PASSWORD_PRODUCTION 45 | 46 | # Adds Cloud Storage buckets for file uploads. 47 | enable_storage = true 48 | 49 | # Adds Redis for caching and communication between servers. 50 | enable_redis = false 51 | 52 | # Makes it possible to SSH into the individual server instances. 53 | enable_ssh = true 54 | } 55 | 56 | 57 | # If you want to set up a staging environment, you can add a second module 58 | # configured for staging. Just uncomment the following code and change the 59 | # parameters as needed (default options should work too). 60 | 61 | # module "serverpod_staging" { 62 | # # References the Serverpod module from GitHub. 63 | # source = "github.com/serverpod/terraform-google-serverpod-cloud-engine?ref=stable-1.1" 64 | 65 | # # Required parameters. 66 | # project = var.project 67 | # service_account_email = var.service_account_email 68 | 69 | # runmode = "staging" 70 | 71 | # region = var.region 72 | # zone = var.zone 73 | 74 | # dns_managed_zone = var.dns_managed_zone 75 | # top_domain = var.top_domain 76 | 77 | # # Prefix for the staging, added to all subdomains. 78 | # subdomain_prefix = "staging-" 79 | 80 | # # Size of the auto scaling group. 81 | # autoscaling_min_size = 1 82 | # autoscaling_max_size = 2 83 | 84 | # # Password for the production database. 85 | # database_password = var.DATABASE_PASSWORD_STAGING 86 | 87 | # # Adds Cloud Storage buckets for file uploads. 88 | # enable_storage = true 89 | 90 | # # Adds Redis for caching and communication between servers. 91 | # enable_redis = false 92 | 93 | # # Makes it possible to SSH into the individual server instances. 94 | # enable_ssh = true 95 | # } 96 | -------------------------------------------------------------------------------- /movieapp_client/lib/src/protocol/protocol.dart: -------------------------------------------------------------------------------- 1 | /* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ 2 | /* To generate run: "serverpod generate" */ 3 | 4 | // ignore_for_file: library_private_types_in_public_api 5 | // ignore_for_file: public_member_api_docs 6 | // ignore_for_file: implementation_imports 7 | // ignore_for_file: use_super_parameters 8 | // ignore_for_file: type_literal_in_constant_pattern 9 | 10 | library protocol; // ignore_for_file: no_leading_underscores_for_library_prefixes 11 | 12 | import 'package:serverpod_client/serverpod_client.dart' as _i1; 13 | import 'example.dart' as _i2; 14 | import 'movie.dart' as _i3; 15 | import 'package:movieapp_client/src/protocol/movie.dart' as _i4; 16 | import 'package:serverpod_auth_client/module.dart' as _i5; 17 | export 'example.dart'; 18 | export 'movie.dart'; 19 | export 'client.dart'; 20 | 21 | class Protocol extends _i1.SerializationManager { 22 | Protocol._(); 23 | 24 | factory Protocol() => _instance; 25 | 26 | static final Map customConstructors = {}; 27 | 28 | static final Protocol _instance = Protocol._(); 29 | 30 | @override 31 | T deserialize( 32 | dynamic data, [ 33 | Type? t, 34 | ]) { 35 | t ??= T; 36 | if (customConstructors.containsKey(t)) { 37 | return customConstructors[t]!(data, this) as T; 38 | } 39 | if (t == _i2.Example) { 40 | return _i2.Example.fromJson(data, this) as T; 41 | } 42 | if (t == _i3.Movie) { 43 | return _i3.Movie.fromJson(data, this) as T; 44 | } 45 | if (t == _i1.getType<_i2.Example?>()) { 46 | return (data != null ? _i2.Example.fromJson(data, this) : null) as T; 47 | } 48 | if (t == _i1.getType<_i3.Movie?>()) { 49 | return (data != null ? _i3.Movie.fromJson(data, this) : null) as T; 50 | } 51 | if (t == List<_i4.Movie>) { 52 | return (data as List).map((e) => deserialize<_i4.Movie>(e)).toList() 53 | as dynamic; 54 | } 55 | try { 56 | return _i5.Protocol().deserialize(data, t); 57 | } catch (_) {} 58 | return super.deserialize(data, t); 59 | } 60 | 61 | @override 62 | String? getClassNameForObject(Object data) { 63 | String? className; 64 | className = _i5.Protocol().getClassNameForObject(data); 65 | if (className != null) { 66 | return 'serverpod_auth.$className'; 67 | } 68 | if (data is _i2.Example) { 69 | return 'Example'; 70 | } 71 | if (data is _i3.Movie) { 72 | return 'Movie'; 73 | } 74 | return super.getClassNameForObject(data); 75 | } 76 | 77 | @override 78 | dynamic deserializeByClassName(Map data) { 79 | if (data['className'].startsWith('serverpod_auth.')) { 80 | data['className'] = data['className'].substring(15); 81 | return _i5.Protocol().deserializeByClassName(data); 82 | } 83 | if (data['className'] == 'Example') { 84 | return deserialize<_i2.Example>(data['data']); 85 | } 86 | if (data['className'] == 'Movie') { 87 | return deserialize<_i3.Movie>(data['data']); 88 | } 89 | return super.deserializeByClassName(data); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /movieapp_flutter/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /movieapp_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /movieapp_flutter/lib/features/movie/presentation/pages/movie_detail_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:movieapp_flutter/core/utils/show_snackbar.dart'; 5 | import 'package:movieapp_flutter/core/widgets/loader.dart'; 6 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_detail/movie_detail_bloc.dart'; 7 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_detail/movie_detail_event.dart'; 8 | import 'package:movieapp_flutter/features/movie/presentation/bloc/movie_detail/movie_detail_state.dart'; 9 | import 'package:movieapp_flutter/features/movie/presentation/pages/movie_edit_page.dart'; 10 | 11 | class MovieDetailPage extends StatefulWidget { 12 | static String route([int? movieId]) => "/movies/${movieId ?? ':id'}"; 13 | 14 | final int movieId; 15 | 16 | const MovieDetailPage({super.key, required this.movieId}); 17 | 18 | @override 19 | State createState() => _MovieDetailPageState(); 20 | } 21 | 22 | class _MovieDetailPageState extends State { 23 | @override 24 | void initState() { 25 | super.initState(); 26 | context.read().add(MovieDetailRetrieveEvent(id: widget.movieId)); 27 | } 28 | 29 | @override 30 | Widget build(BuildContext context) { 31 | return BlocConsumer( 32 | listener: (context, state) { 33 | if (state is MovieDetailStateFailure) { 34 | showSnackbar(context, state.message); 35 | 36 | context.pop(); 37 | } 38 | }, 39 | builder: (context, state) { 40 | switch (state) { 41 | case MovieDetailStateLoading(): 42 | return const Scaffold(body: Loader()); 43 | case MovieDetailStateFailure(): 44 | return Scaffold( 45 | body: Center( 46 | child: Text(state.message), 47 | )); 48 | case MovieDetailStateInitial(): 49 | return const Scaffold(body: SizedBox()); 50 | case MovieDetailStateSuccess(): 51 | final movie = state.movie; 52 | 53 | return Scaffold( 54 | appBar: AppBar( 55 | title: Text(movie.title), 56 | actions: [ 57 | IconButton( 58 | onPressed: () { 59 | context.push(MovieEditPage.route(movie.id)); 60 | }, 61 | icon: const Icon(Icons.edit)) 62 | ], 63 | ), 64 | body: Center( 65 | child: Column( 66 | children: [ 67 | Text("Released: ${movie.year}"), 68 | Text("Director: ${movie.directorName}"), 69 | Text("Logline: ${movie.logline}"), 70 | if (movie.imageUrl.isNotEmpty) 71 | Image.network( 72 | movie.imageUrl, 73 | width: double.infinity, 74 | ) 75 | ], 76 | ), 77 | ), 78 | ); 79 | } 80 | }, 81 | ); 82 | } 83 | } 84 | --------------------------------------------------------------------------------