Architecture
One page for every option
This page covers every choice of --Persistence, --Auth, --IncludeTests and --Aspire. A label says which options a part is for; the copy in your app's docs/ folder has only yours. ApiHost stands for your app's name.
The Todo feature is a working example of each pattern. Copy it when you add your own features (see Add a feature).
Backend
With accounts
- Endpoints. Each endpoint is a static method with
[WolverineGet]or[WolverinePost]. Wolverine finds it automatically and injects what it asks for. Seesrc/ApiHost/Features/Todos/. - Validation.
CreateTodoValidator(FluentValidation) runs before the endpoint. An invalid request gets a 400 response withProblemDetails, which the React form displays. - Messages and the outbox. Completing a Todo returns a
TodoCompletedmessage from the endpoint. Wolverine saves it in the same database transaction as the change (the transactional outbox) andTodoCompletedHandlerhandles it in the background, even after a restart. - Marten Event sourcing. A Todo is a stream of events (
TodoCreated, thenTodoCompleted). The complete endpoint uses Wolverine's aggregate handler workflow:[WriteAggregate]loads the Todo from its events, and the method returns the events to append. An inline snapshot projection keeps aTododocument up to date for queries. - Scheduled messages. "Remind me…" on a Todo calls
POST /api/todos/{id}/remind, which schedules aTodoReminderDuemessage for later (Features/Todos/RemindTodoEndpoint.cs). Scheduled messages are stored in PostgreSQL, so reminders still fire after a restart. When it's due,TodoReminderDueHandlerpushes atodo-reminderto the browser, unless the Todo was completed in the meantime. - Realtime updates. Creating or completing a Todo sends a
todo-changedmessage to the browser over SignalR (TodoChanged, routed inProgram.cs), and every open tab refetches. Each user only receives updates about their own Todos. - Code generation. Wolverine generates code for each endpoint and handler. In Development it does so at runtime, so changes need no extra step;
dotnet publishgenerates it ahead of time and Production loads it ready-made, failing at startup if any is missing. - Accounts. ASP.NET Core Identity with JWT access tokens and rotating refresh tokens; see Accounts.
Without accounts
- Endpoints. Each endpoint is a static method with
[WolverineGet]or[WolverinePost]. Wolverine finds it automatically and injects what it asks for. Seesrc/ApiHost/Features/Todos/. - Validation.
CreateTodoValidator(FluentValidation) runs before the endpoint. An invalid request gets a 400 response withProblemDetails, which the React form displays. - Messages and the outbox. Completing a Todo returns a
TodoCompletedmessage from the endpoint. Wolverine saves it in the same database transaction as the change (the transactional outbox) andTodoCompletedHandlerhandles it in the background, even after a restart. - Marten Event sourcing. A Todo is a stream of events (
TodoCreated, thenTodoCompleted). The complete endpoint uses Wolverine's aggregate handler workflow:[WriteAggregate]loads the Todo from its events, and the method returns the events to append. An inline snapshot projection keeps aTododocument up to date for queries. - Scheduled messages. "Remind me…" on a Todo calls
POST /api/todos/{id}/remind, which schedules aTodoReminderDuemessage for later (Features/Todos/RemindTodoEndpoint.cs). Scheduled messages are stored in PostgreSQL, so reminders still fire after a restart. When it's due,TodoReminderDueHandlerpushes atodo-reminderto the browser, unless the Todo was completed in the meantime. - Realtime updates. Creating or completing a Todo sends a
todo-changedmessage to the browser over SignalR (TodoChanged, routed inProgram.cs), and every open tab refetches. - Code generation. Wolverine generates code for each endpoint and handler. In Development it does so at runtime, so changes need no extra step;
dotnet publishgenerates it ahead of time and Production loads it ready-made, failing at startup if any is missing.
Frontend
With accounts
- Routes. React Router in framework mode, as a single-page app with no rendering server.
src/Client/src/routes.tsmaps each URL to a route module inroutes/, which default-exports the page.root.tsxis the HTML document, andApp.tsxthe frame around every page (header, navigation, footer, incomponents/Layout.tsx). Each page's code loads when it's first visited, so the first page view downloads less JavaScript. - Pre-rendered public pages. The build renders the public pages (the home page, by default) into real HTML, so search engines and link previews see their content without running JavaScript, and a CDN can cache them. The app then takes over in the browser (hydration). Every other page starts from a fallback page. Code that runs while a public page renders must not use
windowordocument, since pre-rendering runs it in Node; use them in effects and event handlers. - Page titles and search engines. Each route module's
handlesets its page title and whether search engines may index it (components/PageMeta.tsx); only the home page may by default, and every other page getsnoindex.src/pages.tslists every page's path and which are public: the build pre-renders those and writes the list intoclient-routes.json, from which the API answers 404 for other paths and buildssitemap.xml. A unit test checks it matchesroutes.ts. The default description and link-preview tags are inroot.tsx: describe your product there. - Server data. TanStack Query caches the Todo list (
features/todos/todoQueries.ts). Changes and SignalR messages invalidate it, which refetches it. - The API client (
lib/api/client.ts) is typed from the API's OpenAPI document (lib/api/schema.d.ts, regenerated withnpm run gen:apiwhile the API runs). It adds the access token to each request and, on a 401, refreshes the tokens once and retries. - One deployable. In development, the Vite dev server forwards
/api(including the SignalR WebSocket) to the API, so the browser talks to one origin and no CORS is needed. In production, the API serves the built client fromwwwroot.
Without accounts
- Routes. React Router in framework mode, as a single-page app with no rendering server.
src/Client/src/routes.tsmaps each URL to a route module inroutes/, which default-exports the page.root.tsxis the HTML document, andApp.tsxthe frame around every page (header, navigation, footer, incomponents/Layout.tsx). Each page's code loads when it's first visited, so the first page view downloads less JavaScript. - Pre-rendered public pages. The build renders the public pages (the home page, by default) into real HTML, so search engines and link previews see their content without running JavaScript, and a CDN can cache them. The app then takes over in the browser (hydration). Every other page starts from a fallback page. Code that runs while a public page renders must not use
windowordocument, since pre-rendering runs it in Node; use them in effects and event handlers. - Page titles and search engines. Each route module's
handlesets its page title and whether search engines may index it (components/PageMeta.tsx); only the home page may by default, and every other page getsnoindex.src/pages.tslists every page's path and which are public: the build pre-renders those and writes the list intoclient-routes.json, from which the API answers 404 for other paths and buildssitemap.xml. A unit test checks it matchesroutes.ts. The default description and link-preview tags are inroot.tsx: describe your product there. - Server data. TanStack Query caches the Todo list (
features/todos/todoQueries.ts). Changes and SignalR messages invalidate it, which refetches it. - The API client (
lib/api/client.ts) is typed from the API's OpenAPI document (lib/api/schema.d.ts, regenerated withnpm run gen:apiwhile the API runs). - One deployable. In development, the Vite dev server forwards
/api(including the SignalR WebSocket) to the API, so the browser talks to one origin and no CORS is needed. In production, the API serves the built client fromwwwroot.