
Explore Dart Frog API development with clean architecture, comparing Shelf and Serverpod, and learn to build production-ready back-end apis using postgres, hot reload, middleware, and testing.
Develop a clean architecture todo API with Dart Frog, covering routes, authentication, testing, and deployment to cloud databases using PostgreSQL and MongoDB, plus file uploads with Cloudinary.
Explore how the dart data class generator extension and json_serializable streamline data serialization/de-serialization and data class creation, including fromJson, toJson, copyWith, and toString, with vscode lint guidance.
Learn how to generate Dart data classes with the Dart data class generator extension, clone with copyWith, and implement value equality using const constructors and the equatable package.
Apply the json_serializable package to generate fromJson and toJson methods for a Post model, wiring http requests to jsonplaceholder and building code with json_annotation and build_runner.
Ensure Dart SDK version 3 or later and upgrade if needed, then install and verify the dart_frog_cli with dart_frog --version. Create a new app: dart_frog create project_name and explore cli.
Use the dart_frog cli to create the dart_frog_first app and explore the generated routes and onRequest handler. Start the dev server on port 8080 with hot reload.
Configure analysis_options.yaml in a clean architecture Dart Frog project to tailor lint rules by disabling warnings such as file_names and avoid_print, and exclude build and generated files.
Install Postman on macOS, choose the correct chip version, and use the lightweight api client to test jsonplaceholder get /posts and prepare collections and environments for the clean todo api.
Install Postman on Windows, create a Postman account for full features, and test GET requests to jsonplaceholder; the course will cover collections, environments, and automating queries.
Learn how dart_frog maps urls to route files, creates route handlers with onRequest, and handles http methods using HttpMethod (get, post, put, delete) to return appropriate responses.
Learn to access request headers via the headers property, return them with Response.json, and explore GET, POST, PUT, DELETE methods and content-length behavior.
Learn how to send information to an endpoint using query parameters and access them via request.uri.queryParameters. Return a json response showing the parameter map.
Explore how to send data with a request body, create a dedicated route for string data, and handle post requests to return the body and its type to the client.
Explore handling json request bodies in a Dart Frog API: access request.json, await the result, and return a json response with body type and content for post requests.
Learn how to handle urlencoded form data in a Dart Frog API by building an endpoint /request/body/form/urlencoded that processes application/x-www-form-urlencoded with formData fields and files, and returns its runtime types.
Learn to implement a /request/body/form/multipart endpoint that processes multipart/form-data, validates a photo (image/png) and a memo (application/pdf) via formData, and returns success or detailed errors.
Learn to use dart:io HttpStatus constants to express common status codes, inspect the response object, test a /response/status_code endpoint, and ensure responses use appropriate codes like 200, 201, and 401.
Explore how to serialize dart objects in response bodies using json_serializable and to json serialization, organize a clean dart_frog app with routes and models, and handle dynamic routes with build_runner.
Explore dynamic routes and route parameters in dart_frog, using path segments like /posts/[postId]/comments/[commentId], handle GET requests and query parameters, and manage 405 and 404 responses.
Create a dynamic route with multiple parameters /dynamic/users/[userId]/posts/[postId], extract userId and postId, respond with Response.json for get requests, and return 405 for other methods, tested via postman at localhost:8080/dynamic/users/1/posts/100.
Learn to implement wildcard routes in Dart Frog with three dot notation to route all subpaths to one handler, handling get requests with json responses and returning 405 for others.
Learn how route conflicts and rogue routes occur in dart_frog, and how to prevent, detect, and resolve them by organizing api.dart and index.dart and testing production builds.
Learn how to implement Dart Frog middleware to run pre and post request code, apply authentication and response modifications across endpoints, and manage middleware with _middleware.dart files.
Create and apply root, dynamic, and posts middleware in a dart_frog app; observe execution order and request forwarding, with before and after prints for each route.
Chain multiple middlewares using the use function, refactor root, dynamic, and posts route middleware, and verify behavior with Postman on endpoints like /dynamic/posts/1, /dynamic/comments/today, and /hello.
Explore how to chain middlewares in dart_frog using the use function, apply a request logger, and understand execution order and the Handler versus Middleware types.
Experiment with chaining middleware in dart_frog by duplicating _rootMiddleware and adjusting roots to observe bottom-up execution order, requestLogger impact, and dependency injection.
Explore how dart_frog uses providers to inject dependencies into RequestContext via a lazy create callback, read them in routes, and how provider order changes values.
Learn to inject async values with providers in dart_frog, using futures and context.read to access user and asyncUser, and test middleware order on the /asyncvalues route.
Learn how providers implement lazy loading in dart frog by creating values only when accessed, as shown by the NeverInvoked route example.
This lecture explores provider lazy initialization and whether a new instance is created per request, using a never_invoked route and a post repository to fetch data from jsonplaceholder.
Create a new route and middleware for cachevalues, implement a post repository provider with caching using an http client, handle get requests, and test with Postman.
Learn to use bottom-to-top provider order for dependency injection, implement wheel and car providers in a new orders route, and read wheel context to build a Car.
Explore dependency injection in Dart Frog by sharing a single http.Client via httpProvider and injecting it into PostRepository with context.read, and observe middleware provider order effects.
Learn how to serve static files with Dart Frog by placing assets in the public directory, accessing them via localhost:8080/filename, and using custom entry points to serve other folders.
Create a Dart Frog server route that handles post requests to upload a png image via form data, validates image/png, enforces a 1 MB limit, and uploads to Cloudinary.
Configure cloudinary with environment keys and a cloud name, enable https, and upload files from local or remote sources in a Dart Frog app; retrieve publicId and secureUrl.
Upload images to the dart frog server via cloudinary, handling errors with try-catch, validating file size against a 1 megabyte limit, and returning json response including url, formData, and message.
Install cloudinary and path, configure signed cloudinary, and create a route to upload files as List<int> bytes. Implement an uploadFile function, handle responses, and verify uploads via Postman and cloudinary.
Explore how to unit test Dart Frog route handlers and middleware using the test and mocktail packages, ensuring isolated tests and controllable dependencies via mocking.
Test a Dart Frog route by mocking RequestContext with mocktail, verify 200 status and 'Welcome to Dart Frog!' using AAA pattern. Run tests in VSCode or via dart test.
Learn to mock requests and test API handlers in Dart Frog by creating a _MockRequest, stubbing context and request properties, and verifying onRequest with expectLater.
Test post method with a text/plain body using HttpHeaders.contentTypeHeader and ContentType mimeType; stub the mock context, send Request.post to http //localhost, and verify 200 with bodyType and content.
Mock a post request with _MockRequest, stub HttpMethod.post and contentTypeTextPlainHeader, and return a String via thenAnswer; organize tests with setUp, setUpAll, tearDown, and tearDownAll using MockRequestContext and test json.
Learn to test JSON type request bodies in a Dart Frog clean architecture project, covering non-post 405 responses and POST requests with JSON bodies and 200 returns.
Learn to handle application/x-www-form-urlencoded and multipart/form-data in Dart Frog, implement post route logic with formData, and test with mocks across multiple scenarios.
Test post requests with multipart/form-data to verify 400 errors when photo is missing or not image/png, and 200 success for valid uploads.
Test reading injected RequestContext values in the onRequest handler, verify 200 status and greeting body, and demonstrate context.read semantics with asyncvalues and middleware order.
Learn to test middleware in a Dart Frog app by injecting a value into RequestContext using provider, wiring a dummy handler, and verifying Hello World is accessible.
Test chained async middleware in a Dart Frog app by injecting two user values and a Future into the RequestContext via userProvider, anotherUserProvider, and asyncUserProvider, and verify access with context.provide.
Explore testing the cachevalues middleware in a Dart Frog API, showing how to inject http.Client into PostRepository via RequestContext providers, mock tests, and verify behavior.
Develop route tests in dart_frog by mocking RequestContext and PostRepository, validating non-get methods, parse int errors, repository failures, and successful id route responses.
Explore how to implement flexible authentication in dart_frog using the dart_frog_auth package, covering basic and bearer authentication, token structure, and security considerations.
Learn to implement basic and bearer authentication with the dart_frog_auth package by applying middleware to routes, protecting admin paths while keeping posts public, and wiring user models and repositories.
Explore how to selectively apply basic or bearer authentication in Dart Frog middleware using applies to protect non-post routes. Post requests remain unauthenticated in a RESTful users API.
Differentiate authentication from authorization and see how dart_frog_auth returns 401 and 403. Learn a self-delete example and the basics of basic and bearer auth.
Build a dart frog api with clean architecture by implementing a user model and basic authentication. Create signup and signin endpoints with uuid and toJson that omits password.
Create a memory-based user repository using a _users map to perform signup, signin, find by id, update, and delete operations, ensuring unique emails and redacting passwords with copyWith.
Build sign up and sign in routes using dart_frog, validate username, email, and password with UserRepository, return 201 or 400, and generate a token with Utils.createToken.
Create dynamic /users/[id] routes for get, update, and delete, and resolve conflicts by moving signin and signup to an auth folder; enforce authorization via the authenticated user id.
Implement update and delete user routes in Dart Frog API with clean architecture, performing authorization checks, validating usernames (2-12 chars), and returning proper json responses and http statuses.
Create a root middleware that injects a cached UserRepository into the RequestContext and wires a basicAuthentication flow for user routes, applying it only to routes other than signup and signin.
Test basic authentication by signing up and signing in via /auth/signup and /auth/signin, observe 400 and 201 responses, and verify the base64 encoded token.
Build a bearer authentication flow using json web tokens by creating a JwtService that signs and verifies tokens with dart_jsonwebtoken, SecretKey, and HS256, including expiresIn handling.
Implement bearer authentication by updating signup and signin to generate and sign tokens with JwtService, using a payload of user id, and verify tokens in middleware.
Test bearer authentication in a dart_frog api by signing up, signing in, and managing users with bearer tokens. Verify token payload and expiration via jwt.io and observe authorization flow.
Apply clean architecture to a to-do api, separating ui, business logic, and data access with a four-circle dependency model and a three tier architecture to promote loose coupling and testability.
Explore the three-tier architecture: UI, business logic, and repository, and how use cases, entities, ports, and adapters enable loose coupling through dependency inversion.
Study clean architecture fundamentals, focusing on the data layer and gateways, the domain repository pattern, and dependency inversion to decouple business rules from data sources.
Create a clean architecture todo API with dart_frog_cli, auto-generating routes for auth, todos, and users, and organize request handlers, controllers, and presenters in the presentation layer.
Explore Dart's call method on function types, including nullable functions with null aware operators. Create callable objects by implementing call in a class to support clean architecture use cases.
Learn to handle errors in Dart with functional approaches using the either type, by building a jsonplaceholder todo fetch app with http, a Todo model, and fromJson.
Apply the Either type to represent error and success in dart API calls. Use Left and Right with match or fold to handle errors and successful Todo results from getEitherTodo.
Learn to build a to-do API with dart_frog by connecting to PostgreSQL and MongoDB, install and connect locally, and perform CRUD operations, with cloud options via supabase and MongoDB Atlas.
Install postgres on macOS using Postgres.app for easy server management, then set up pgAdmin4 to access PostgreSQL, initialize the server, and connect to localhost:5432.
Install Postgres on Windows using the EDB installer, configure components, data directory, and password, connect with pgAdmin 4, then proceed to install MongoDB and MongoDB Compass.
Implement a postgres-based user save using the postgres package, create a db connection and constants for dbName and users table, and scaffold CRUD operations with error handling.
Learn to connect to postgres_db via DbConnection, execute sql with Sql.named, insert a user into the users table, handle server exceptions, and close the connection.
Create a user in a Dart app with clean architecture and PostgreSQL. Use prepared statements and Sql.named with parameters to insert data and return records with returning.
Demonstrates updating and deleting users using update_user.dart and delete_user.dart in a Dart Postgres app, updating username and email with COALESCE and RETURNING, and discusses affectedRows for non-existent id.
Install the uuid package, create uuid_users with id as a uuid primary key using gen_random_uuid, test runtime types, and perform crud with the postgres package, and follow snake_case naming conventions.
Install MongoDB on macOS by setting up Xcode command line tools and Homebrew, then install mongodb-community@8.0 and run mongod as a service. Install MongoDB Compass and connect to mongodb://localhost:27017/.
Install MongoDB on Windows, complete the setup, install the shell and Compass, configure the system path, and verify with mongod and mongosh to connect to the local database.
learn how to store data in MongoDB from a Dart app using the mongo_dart package, and understand how mongo_dart compares with orm and realm for database access.
Explore MongoDB basics by comparing collections, documents, and fields with SQL tables, and see how NoSQL structures resemble JSON, introducing the mongo_dart package.
Create a simple command line app to test crud operations with mongo_dart. Learn to connect using Db.create or uriString and understand legacyFind and modernFind wrappers.
Learn to save a user with mongo_dart by creating a create_user.dart, connect to a local database via a reusable DbConnection, and define constants for dbName and usersCollection to enable CRUD.
Learn to connect to a mongo_db database, reference the users collection, and insert a user document with username, email, password, createdAt, and updatedAt using insertOne.
Create a unique index on the email field in MongoDB Compass to prevent duplicates when inserting users, and verify outcomes with isSuccess and nInserted.
Explore how to create and validate a MongoDB schema with Compass using the validation tab and a jsonSchema, defining username, email, password, createdAt, and updatedAt, and handling validation errors.
Explore find_users.dart by chaining query builders with the fluent mongo_dart API, compare to map queries, and convert results to a list while optionally excluding _id and selecting username and email.
Create find_one_user.dart by copying find_users.dart, remove queries under usersCollection, and use findOne to return a nullable Map, printing results and illustrating the first matching document, optional args, and ObjectId.parse handling.
Create delete_user.dart, apply deleteOne on the users collection, verify deletions with nRemoved via MongoDB compass, and learn options to return the deleted document using findOne or findAndModify.
Explore updates in mongo_dart using updateOne with a selector and modifier, including upsert, and learn that updateOne returns a write result and may require manual retrieval of the updated document.
Learn to update a user with modernFindAndModify in Dart, using query and modify builders, and control returnNew and updatedExisting, then verify with MongoDB compass and uuid in _id.
Install and use the uuid package to create and test uuid ids in a Dart app, customize DbConstants, and explore String vs UuidValue storage with v4obj and validation.
Recently, the use of Dart has been rapidly expanding into backend server development. Just like JavaScript is utilized for web, mobile, and server development, Dart is starting to be utilized for full stack development.
In this course, you will learn about Dart Frog, which is widely used for Dart backend development, and build an API server with a clean architecture based on that knowledge.
If you're looking for a deep understanding of Dart Frog and want to practice all the concepts, this is the course for you.
In particular, I've been careful to create a balance between theory and practice.
Let's take a quick look at everything we'll be covering in this course.
- Dart Data Class Generator extension and Json Serializable package
- Dart Frog basics: learn and practice concepts like routes, middleware, dependency injection, static files, and more.
- Uploading files to Cloudinary: Learn how to store and access multimedia data in the storage provided by Cloudinary.
- Testing Dart Frog: Learn how to test for route handlers, providers, and middleware.
- Dart Frog Authentication: Learn basic authentication and bearer authentication provided by the dart_frog_auth package
- Clean Architecture Overview: Learn an overview of Clean Architecture and why it's needed
- Callable Classes and Either Type: Learn about callable classes, which will be useful when creating APIs with Clean Architecture, and the concept of Either Type, which makes error handling easier.
- postgres package: Learn about the postgres package, which enables CRUD operations using SQL against the PostgreSQL database on the Dart Frog server.
- mongo_dart package: Learn about the mongo_dart package, which allows you to perform CRUD operations on a MongoDB database using a mongo shell-like syntax on a Dart Frog server.
- Create a Todo API using Clean Architecture: Create a Todo API with authentication, user management, and todo management features using Clean Architecture.
- Deploy Todo API to globe: Learn how to deploy Dart Frog server to globe, a platform that makes it easy to deploy Dart apps.