Skip to content

About

TempHire converted from Angular to React 19, with Mantine, React Router and Vite, plus a guide to React for Angular developers. The same line-of-business app on Breeze 3 and .NET 10: one set of validation rules for client and server, multi-tenancy, OAuth 2.1 sign-in and Quinn, an AI assistant over MCP, on a server shared with the Angular version.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TempHire (React + BreezeJS + .NET)

TempHire is a reference implementation of a data-driven line-of-business application: a staffing company's people, with their addresses, phone numbers, rates, skills and work history, searched in a grid and edited in a form, with validation, save and cancel - plus an AI assistant, multi-tenancy, roles and OAuth 2.1 sign-in.

This repository is the React version. It is a framework conversion of temphire.angular: the same application, screen for screen, with the Angular client rewritten in React. Both run on the same .NET server, temphire.server, which is a git submodule in each repository's server/ folder (see The server). It is meant for anyone weighing a move from Angular to React - to see what changes, what doesn't, and how the concepts map.

Every converted file also names the Angular file it came from, so the two repositories can be read side by side.

Angular version This version
UI framework Angular 22 (standalone, zoneless, signals) React 19 with TypeScript
Build Angular CLI Vite 8
Routing Angular Router React Router 8 (data router)
Components Optimus UI 2 (MIT fork of PrimeNG) Mantine 9 (MIT)
Forms Signal Forms Mantine useForm; entity inputs bound to Breeze
Tests Vitest Vitest + React Testing Library
Data breeze-client 3 breeze-client 3 - unchanged
Server temphire.server: ASP.NET Core 10, Breeze .NET 8, EF Core 10, OpenIddict the same server

Prerequisites

  • .NET SDK 10.0 or later
  • Node.js 26.13.0, pinned in .node-version (nvs auto picks it up)
  • SQL Server LocalDB (Visual Studio's "Data storage and processing" workload, or SQL Server Express), or any SQL Server - see the server's prerequisites
  • For Quinn: Ollama with qwen3:4b-instruct (the default), or an Anthropic API key for Claude - see Quinn

Running it

The server is a git submodule, so clone with --recurse-submodules:

git clone --recurse-submodules https://github.com/Breeze/temphire.react.git

In a clone made without it, run git submodule update --init once. After a git pull that moves the submodule to another commit, run git submodule update to check that commit out.

Then two terminals; the server first, because the client loads its Breeze and validation metadata from it.

1. Server (http://localhost:5100)

cd server/TempHire.Server
dotnet run

On first start it creates and seeds its two databases, TempHireReact and TempHireReactIdentity: two companies, two users each, and 25 staffing resources per company. The port and the database names are this version's, set in server.appsettings.json (see Next to the Angular version). It also describes its API with Swagger UI, at http://localhost:5100/swagger, where its root redirects; sign in with Authorize (see the server's Swagger).

2. Client (http://localhost:5173)

cd client
npm install
npm start

Vite opens the app; it sends you to the server's sign-in page. Sign in as one of the sample users, such as anna@harbor.test (an Editor at Harbor Staffing) or ben@harbor.test (a Reader there). The password is password for all of them, and in development the sign-in page lists them for one-click sign-in.

Next to the Angular version

The two versions can run at the same time. This one uses ports 5100 (server) and 5173 (client), where the Angular version uses 5000 and 4200, and its own databases, so neither touches the other's data. The server is the same; server.appsettings.json, in this repository's root, gives it this version's URL, databases and dev-server origin, overriding its appsettings.json (see In a client repository). The two share the server's user secrets, so a Claude API key stored for one is used by both.

Building for production

cd client
npm run build:server     # builds into ../server/TempHire.Server/wwwroot

The server then serves the app itself at http://localhost:5100.

Tests and checks

cd client
npm test                 # Vitest, in watch mode; npx vitest run for a single run
npm run lint             # ESLint, including the React Hooks rules
npm run typecheck        # TypeScript

cd ../server
dotnet test TempHire.Server.Tests   # saves, rules, sample data, queries, who may call what

How the React client is built

The short version, for orientation; REACT-FOR-ANGULAR-DEVELOPERS.md explains each point.

  • Services in context. createAppServices (core/services/app-services.tsx) creates the long-lived services once - the entity manager provider, the unit-of-work manager, the auth service - and AppServicesProvider puts them in React context, where components get them with useServices(). That is the app's dependency injection.
  • Breeze entities and rendering. Breeze entities are mutable; React re-renders on state changes. The unit of work bridges the two: it notifies its subscribers whenever an entity in it changes, and a component that calls useUnitOfWork(unitOfWork) renders again. Inputs bound to an entity property (core/validation/EntityFields.tsx) write straight to the entity and show its validation errors (see Validation).
  • One fetch for everything. apiFetch attaches the access token, renews it before it expires, and signs in again on a 401. Breeze is configured to use it too.
  • Routing. React Router loaders check the session and the roles before a page renders - what Angular's guards did - and useBlocker asks before leaving Resource Management with unsaved edits.
  • Dialogs are promise-returning functions (openDialog, confirm, ...) over Mantine's modals. They resolve with what the user chose: a message box with its button ('ok', 'cancel', ...), a dialog with its result or undefined. Cancelling is an answer, not an error.
  • Errors go to one place. main.tsx passes the window's error and unhandledrejection events to showError, and an ErrorBoundary catches errors thrown while rendering - together what Angular's global ErrorHandler does. A command that fails, called from a click, reaches showError that way; components catch only an error they act on, such as rolling back a failed delete.

The React Compiler

The React Compiler memoizes components at build time: it adds what useMemo, useCallback and React.memo would add by hand, so a value, a callback or a stretch of JSX is reused while its inputs are unchanged. TempHire runs it through Babel (vite.config.ts) in annotation mode: only a component that starts with the 'use memo' directive is compiled.

Compiled Not compiled
Home, FrameworkMark, QuinnLogo, MessageBox, ResourceSearch (its rows are plain DTOs), Usage (plain data from the API), Quinn (its conversation is a new snapshot on every change), QuinnQuestion (a question from that snapshot) The resource screen, its sections and cards, the Entity* inputs, AddressLine1Input, the name editor and ItemSelector: they render Breeze entities. The providers and the app shell: they hold mutable services.

Why not the components that render Breeze entities. The compiler decides what changed by object identity, and assumes props and state are never changed in place. Breeze entities are changed in place: address.city = 'Spokane' changes the same address object, and the component re-renders because useUnitOfWork says an entity changed, then reads the new value. A compiled component sees the same address it saw before and reuses what it built from it. This was tried: with 'use memo' in the address card, the card still re-renders, but it shows the old city, and ResourceAddress.spec.tsx fails ("expected 'Tacoma' to be 'Spokane'"). The compiler raises no error for it, so nothing but a test would catch it. Compiling those components would mean giving them immutable snapshots of the entities, or the unit of work's version as a prop, which would change how the client works for a speed-up its screens don't need.

Marking another component. Add 'use memo' only to a component whose props are plain values and whose state changes by replacement: never one that takes an entity, a unit of work, or a service object that changes in place. panicThreshold: 'all_errors' fails the build if the compiler can't compile a marked component, so a mark is never silently ignored. The react-hooks lint rules, written for the compiler, check every component either way.

Entity classes are generated

The classes in client/src/app/core/model are generated from the server's model by Breeze's entity generator, as in the Angular version:

cd client
npm run model            # export the metadata from the server, then generate
npm run model:generate   # generate from the checked-in metadata.json only

See client/src/app/core/model/README.md for which parts of those files you may edit.


Quinn

A round button in the bottom right corner opens a chat pane with Quinn, who answers questions about your company's staffing data in plain language. The people Quinn mentions are links that open them in Resource Management. Quinn runs in the server, which exposes the data as an MCP server at /mcp; it calls the tools with your own access token, so it sees only your company's data, and only if your role allows.

An editor can also ask Quinn to change an existing address of a staffing resource, an experiment in letting Quinn change data. If the person has several addresses, or the address service finds several matches, the pane shows them as radio buttons with OK and Cancel; before anything is saved, it shows the current and the new address with Confirm and Cancel (QuinnQuestion). Those questions come from the server's tools, and the user answers them, not Quinn: see Changing an address through Quinn. Once the address is saved, the search list and the open resource refresh (EventAggregator.savedElsewhere); if the user is editing that resource with unsaved changes, ResourceMgt asks whether to discard them, and if not, refreshes the rest and keeps their changes for them to save.

The Agent section of server/TempHire.Server/appsettings.json picks the model: Ollama (default, local) or Claude.

  • Ollama: install it from https://ollama.com/download, then ollama pull qwen3:4b-instruct.
  • Claude: run server/Set-ClaudeApiKey.ps1 -UseClaude in PowerShell; it prompts for the API key and stores it in the server's user secrets, never in appsettings.json. -UseOllama switches back.

Budgets. Answers from a paid model cost money, so the server gives each user and each company a budget in dollars per day, week and month, for each model: as shipped, $0.50 a day per user and $10 a month per company for Claude (about 38 and 770 questions); Ollama is free and unlimited.

  • The user menu. The signed-in user in the top right corner opens a menu with Usage and Logout.
  • The usage page (client/src/app/usage/, route /usage) shows, per model, what Quinn's answers cost you and your company today, this week and this month, against the budgets, with the tokens they took. Bars turn amber at 80% and red when a budget is used up; an unlimited model shows its tokens only.
  • Quinn's pane reads the same figures when it opens and after every answer. While a budget is used up it says which one and how long until it starts over, counting down, and disables the question box until then; the server refuses such a question anyway. A budget can be overrun slightly: the question that crosses it is answered in full.

The server's README describes how Quinn works, compares the two models, and covers setting up Ollama, setting up Claude and the budgets - what they buy, how usage is counted, and how to change the budgets or the prices - in detail.

Validation

Validation uses IdeaBlade Validation 0.1.0: ideablade-validation on npm and IdeaBlade.Validation on NuGet. As with any 0.x version, its API may still change between minor versions.

The rules are the server's, in two places: the entities' data annotations ([Required], [StringLength]), which reach the client in the Breeze metadata, and the validation metadata (server/TempHire.Server/Validation/validation.metadata.json) for the rules annotations cannot express - U.S. addresses with a state and a ZIP code, phone numbers in any of the common U.S. formats (written as (206) 555-1234 when the user leaves the field), rates, valid dates, a plausible date of birth (neither in the future nor more than 123 years ago), and a resource with at least one address and one phone number who is at least 18 years old when hired. Both are read by IdeaBlade.Validation / ideablade-validation, which surfaces every rule as the same kind of ValidationError on both sides; the server's README describes the server half in Validation. On the client:

  • At sign-in EntityManagerProvider loads the validation metadata (api/validation/Metadata) next to the Breeze metadata, gives it Breeze's display names (displayNameMetadata) and installs it into Breeze (installBreezeValidators), so Breeze runs every rule before a save.
  • The app's validation service is created in createAppServices and provided by <ValidationProvider> in main.tsx. Resource Management has its own (useValidationScope(unitOfWork.entityStore)), whose entity store is the unit of work being shown. It also validates that unit of work continuously (validateEntityStore()): every live entity against every rule, sync and async, the metadata's and Breeze's, again whenever an entity changes. The fields, the tab marks and the Save button follow that one result. Saving goes through SaveHandler (core/services/save-handler.ts, useServices().saveHandler), which every workspace uses: it validates the unit of work again when Save is clicked (validateEntityStoreOneTime), since the continuous result catches up with an edit a moment later and a Save clicked right after an edit would otherwise miss it. Nothing is saved while any rule is broken, async ones included: the handler shows every error and says why. After every save (a deletion too), each unit-of-work manager drops its shared cache, on the saved event (EventAggregator), so the read-only views re-read what was saved.
  • Entity editors wrap each card or row in <ValidationForm model={entity}>, which validates the whole entity; each Entity* input (core/validation/EntityFields.tsx) shows the errors to show about its property (useFieldValidation), and reports the user's edits and leaving the field with markTouched. Breeze's own rules reach the inputs through the breeze validator, the same way as the server's. A rule about two fields shows on both: "at least 18 years old when hired" names both dates, and changing either re-checks the other.
  • A new resource is not all red at once. ResourceMgt creates an ErrorVisibility with breezeIsNew, reports the unit of work's validation to it (observeEntities), and provides it to the detail (ErrorVisibilityProvider); validation itself is unchanged. Loaded entities show all their errors. A new one - a resource, or an address or phone number added to one - starts with its first errors hidden: a field's show once the user edits or leaves it, and an error the user causes shows at once, on every field it is about, touched or not. Save stays enabled while rules are broken: clicking it shows every error, and a "Not saved" notification says why nothing happened and where to look. An entity added after that starts with its errors hidden again. The library's Showing errors describes the rules.
  • Rules about a whole entity, such as "at least one address", have no field. Validating the whole unit of work keeps them current - deleting a resource's last address breaks the resource's rule without changing the resource - and the address and phone lists show them from the same result (useEntityStoreValidation()), through useShownErrors, so they follow the same rules: a new resource's messages show on a save attempt, or when the user deletes the last address or phone number. A new resource starts without an address or a phone number, and the last one of each can be deleted, so the rule is the user's to satisfy.
  • Tabs with errors are marked. Each detail tab shows a red count of the errors it has to show, so a problem on a tab the user is not looking at does not have to be hunted for. The counts come from the same validation of the unit of work, not from the fields - the lazy tabs have none until they are opened - and follow the error visibility (useErrorVisibility() and useErrorVisibilityVersion() in ResourceDetail): a new resource's tabs are marked once the user breaks a rule or tries to save. resource-tabs.ts places each error on a tab by the type of its entity, and the resource's own rules by their id; its test fails for an entity type or a rule nobody has placed.
  • The name editor validates a ResourceName view model with the service (core/validation/client-validation-metadata.ts); its properties inherit StaffingResource's Breeze rules with from, so nothing is restated. It shows a name's errors once the user has left its field (Mantine's validateInputOnBlur), not through the screen's ErrorVisibility, and OK waits until the names are valid.
  • Display names live in one place, core/model-display-names.ts, and the validation messages use them too.

On the server: validating the database as it will be after the save

The server checks every save against the same metadata, and not only against what the save holds: it loads the related entities the rules read, applies the save on top, and validates the database as it will be after the save. So a rule that two users break together - each deleting a different one of a resource's two addresses - is caught even though neither save was wrong on its own, and no concurrency check would catch it. The code that loads those entities is TempHire's own, written from its model, and an AI coding assistant can keep it in step with the rules. The server's README explains it in Validating the database as it will be after the save.

Concurrency

Every entity the client can save has a RowVersion, and a save that would overwrite or delete a row someone else saved in the meantime fails with a concurrency conflict (409); see Concurrency in the server's README. The client tells the user so, in plain words, rather than showing the database's message: someone else changed this data, so click Refresh to load the latest, then make the changes again and save (CONCURRENCY_CONFLICT in core/services/error-handler.ts).

Editing the rules

The rules can be edited by hand, or in the IdeaBlade Validation Editor, a desktop app that writes the metadata through forms and checks it with the library as you type. Open temphire.ivproj at the root of this repo in it: that opens both metadata files, the server's validation.metadata.json and the client's client-validation-metadata.ts, and loads what the forms and the code completion in expressions offer: the entities from client/metadata.json (regenerated with npm run model), the list projection in core/projections/, and the name editor's ResourceName (ResourceNameEditor.tsx). A new file in core/projections/ is picked up as soon as it's written.

The server

The server is ASP.NET Core 10 with the Breeze .NET server 8 and EF Core 10 on SQL Server, shared with the Angular version. It lives in its own repository, temphire.server, included here as a git submodule in server/, and its README documents it. In short, it:

  • serves the Breeze metadata, queries and saves, and the validation metadata, and checks every save against the same rules as the client, on the database as it will be after the save;

  • confines each user to their company's data, the company taken from their email domain;

  • suggests U.S. addresses as an editor types the first address line, and picking one fills the address form: address completion, from OpenStreetMap data through Photon, with no API key;

  • signs users in as its own OAuth 2.1 authorization server, with ASP.NET Core Identity and OpenIddict, and enforces the Editor and Reader roles;

  • runs Quinn, with an MCP server that other MCP clients such as Claude Code can use as well - with this version's port:

    claude mcp add --transport http temphire-react http://localhost:5100/mcp
    
  • creates, migrates and seeds its databases on startup.

What this version sets differently - the server's URL, its databases and the dev server's origin - is in server.appsettings.json (see Next to the Angular version).

The sections of its README:

Changing the server. server/ is a clone of temphire.server: commit and push there, then commit the submodule's new commit here, so this repository records which server version it runs with.


Layout

temphire.react/
├── server.appsettings.json         # what the server does differently for this version
├── server/                         # git submodule: temphire.server (see its README's Layout)
│   ├── TempHire.sln
│   ├── TempHire.Model/             # entities, DbContexts, migrations, sample data
│   ├── TempHire.Server/            # Breeze, validation, OAuth, Quinn and MCP
│   └── TempHire.Server.Tests/      # saves, rules, sample data, queries, who may call what
├── temphire.ivproj                 # IdeaBlade Validation Editor project (see Editing the rules)
└── client/
    ├── metadata.json               # Breeze metadata exported from the server
    ├── vite.config.ts              # build, dev server and tests
    └── src/
        ├── main.tsx                # start-up: providers, Breeze, the router
        ├── styles.css              # the app's look
        └── app/
            ├── App.tsx             # the shell: toolbar, page, Quinn
            ├── app.routes.tsx      # routes, loaders, lazy pages
            ├── core/
            │   ├── model/          # generated entity classes
            │   ├── services/       # auth, apiFetch, Breeze managers, units of work, dialogs, toolbar
            │   ├── hooks/          # useUnitOfWork, useBusy
            │   ├── validation/     # the Entity* inputs, the client validation metadata
            │   └── theme/          # the Mantine theme
            ├── auth-callback/      # where sign-in returns to
            ├── home/
            ├── resource-mgt/       # the workspace, its search, detail, dialogs and sections
            ├── quinn/              # the chat pane
            └── usage/              # Quinn's usage and budgets, from the user menu

Configuration

Setting Where Notes
urls, ConnectionStrings:*, AllowedClientOrigins server.appsettings.json This version's server URL (http://localhost:5100), databases (TempHireReact, TempHireReactIdentity) and dev server origin (http://localhost:5173), overriding the server's appsettings.json
Ports server.appsettings.json, client/vite.config.ts 5100 and 5173; the client's environment.ts names the server's
Agent:* server/TempHire.Server/appsettings.json, user secrets Quinn's model and budgets (Agent:Quotas); see Quinn

The server's other settings are in its README.

Known gaps

  • The main bundle is large: about 740 kB, 230 kB compressed - React, Mantine and Breeze - and Vite warns about it. The pages themselves load as separate chunks.

  • No end-to-end tests. There are unit tests on both tiers: over 100 in the client (Vitest and React Testing Library) and over 60 on the server. The client's cover:

    • the services: the sign-in guard, the API fetch, the dialogs, the error handler, the save handler and the staffing resource repository;
    • validation: the server's rules as the client runs them, the field bindings and display names;
    • Resource Management: the search box, the address list, the tabs' error marks and the "Not saved" message;
    • Quinn's conversation and links to people, and the usage page.

    The server's are listed in its README. The screens themselves were checked by hand in a browser.

About

TempHire converted from Angular to React 19, with Mantine, React Router and Vite, plus a guide to React for Angular developers. The same line-of-business app on Breeze 3 and .NET 10: one set of validation rules for client and server, multi-tenancy, OAuth 2.1 sign-in and Quinn, an AI assistant over MCP, on a server shared with the Angular version.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages