Recommended structure
Entry point
bin/server.dart owns process-level orchestration:
- Create and configure
App - Register providers
- Boot the application
- Resolve the router and static file server
- Construct
AppKernel - Bind
HttpServer - Handle shutdown failures
Configuration
lib/src/config is the default directory read by AppConfig.create(). Each JSON filename becomes a dotted-key namespace:
HTTP code
Place route registration functions inlib/src/http/routes and invoke them after resolving Router.
http/middleware for reusable application middleware. Server-rendered templates belong in http/views; request.view('dashboard.index') resolves to dashboard/index.html.
Public CSS, JavaScript, images, and other static assets belong in http/public, the default root used by StaticFilesServer.
Application services
Useproviders for service-container bindings and startup work. Database models and migrations can live under database. These locations are conventions for maintainability; providers and models are ordinary Dart types and can be organized differently when your domain requires it.
Tests
Keep framework and application tests undertest. Separate container/provider tests from HTTP behavior tests so boot failures and request failures are easy to diagnose.
Architecture
Learn how these pieces cooperate at runtime.
Build a small app
Apply the structure to a working JSON API.