Rostra
Case Study
Overview
A rostering app for multi-site restaurants. Staff swap shifts from their phone, managers approve in one tap with labour cost shown live, a demand forecast suggests how many people each hour needs, and a cherry blossom tree grows the more you use it.
Built to cut weekly rostering from ~3 hours to under 1. The forecast misses by 1.5 customers an hour against 2.0 for “same as last week”, tested on 13 held-out weeks of synthetic trading.
Where it started
During my years managing restaurants, I loved spending time on the roster, and the staff loved checking it. Rostra gives rostering a more fun spin while staying informative, taking the best parts of every rostering tool I used.
The design was sparked by my love for nature: an overgrown forest at golden hour on the sign-in page, and a low-poly cherry blossom tree on Home that grows the longer you use the app.
Swaps in one tap
Staff ask a teammate to cover from their phone, and the manager approves in one tap with the cost impact shown. Before a swap is even offered, Rostra checks the cover can actually work it.
src/Rostra.Api/Shifts/SwapEndpoints.cs
app.MapPost("/shifts/{id:int}/swap", RequestSwap)
.RequireAuthorization("Staff")
.AddEndpointFilter<OwnShiftFilter>();
static async Task<IResult> RequestSwap(
int id, SwapRequest req, RostraDb db, INotifier notify)
{
var shift = await db.Shifts
.Include(s => s.Staff)
.FirstOrDefaultAsync(s => s.Id == id);
if (shift is null) return Results.NotFound();
var cover = await db.Staff.FindAsync(req.CoverId);
if (cover is null || !cover.CanWork(shift))
return Results.Conflict("Cover is not available");
shift.PendingCoverId = cover.Id;
await db.SaveChangesAsync();
await notify.ManagerAsync(shift, cover);
return Results.Accepted();
}
Who can actually cover
Every cover suggestion explains itself. Rostra checks availability, approved leave, station training and clashes with the cover's other shifts, and shows the reason in the picker, like “Already working 4–11”.
src/Rostra.Api/Domain/Staff.cs
public bool CanWork(Shift shift) => WhyCannotWork(shift) is null;
/// <summary>Returns a short, human reason this person can't take the shift, or null if they can.</summary>
public string? WhyCannotWork(Shift shift)
{
if (Id == shift.StaffId) return "Already on this shift";
if (!IsActive || CompanyId != shift.CompanyId) return "Not on the roster";
if (!AvailableDays.HasFlag(Week.DayFlag(shift.Start.DayOfWeek)))
return $"Unavailable on {shift.Start.DayOfWeek}s";
var day = DateOnly.FromDateTime(shift.Start);
if (TimeOff.Any(t => t.Status == RequestStatus.Approved && t.From <= day && t.To >= day)) return "On leave";
if (!Stations.HasFlag(shift.Station)) return $"Not trained on {shift.Station}";
var clash = Shifts.FirstOrDefault(s => s.Id != shift.Id && s.Start < shift.End && shift.Start < s.End);
if (clash is not null) return $"Already working {Week.Compact(clash.Start, clash.End)}";
return null;
}
Labour cost, live
The roster shows labour cost against the week's budget as you build it, with weekend penalty rates applied, and flags award issues as warnings rather than blocks: under 10 hours' rest, over 38 hours a week, no meal break past 5 hours. The manager decides, but nothing slips through unnoticed.
src/Rostra.Api/Domain/Labour.cs
public static readonly Penalties Penalties = new(1.25m, 1.50m);
public static decimal Multiplier(DateTime start) => start.DayOfWeek switch
{
DayOfWeek.Saturday => Penalties.Saturday,
DayOfWeek.Sunday => Penalties.Sunday,
_ => 1m,
};
public static decimal Cost(double hours, decimal rate, DateTime start) => (decimal)hours * rate * Multiplier(start);
The Grove
Your cherry blossom tree grows with the time you actively spend in Rostra, from Seedling to Ancient Tree. Apples are roster weeks (red once published or worked, green while still to come), fireflies are kudos from teammates, and petals drift down onto the lawn.
src/Rostra.Api/wwwroot/js/growth.js
export const GROWTH_HOURS = 5; // the curve's time constant: ~63% grown after 5 hours of use
export const FRUITING = 0.3; // apples appear once the tree reaches this growth (~1.8 h)
export const growthFor = (seconds) => Math.min(0.995, Math.max(0.05, 1 - Math.exp(-(seconds / 3600) / GROWTH_HOURS)));
export const STAGES = [
{ at: 0, name: 'Seedling' }, { at: 0.15, name: 'Sapling' }, { at: FRUITING, name: 'Young Tree' },
{ at: 0.6, name: 'Mature Tree' }, { at: 0.85, name: 'Ancient Tree' },
];
Version 3.1: forecasting demand
This section used to say the feature I'd add next was a holiday and event tracker that told managers whether a shift needed more staff on or fewer. Version 3.1 builds it. Rostra now predicts each store's customers hour by hour, suggests how many people each station needs, and checks that against the roster on screen.
There's no real point-of-sale history to learn from, so the data is synthetic, and the app says so. A generator creates two years of believable, deliberately messy trading for the eight demo sites: breakfast and dinner peaks, weather, promotions, duplicate and voided sales, outages, and public and school holidays worked out from each state's own rules.
A model that can't see the future
Every input is at least a week old: the same hour last week and the week before, four-week averages, holidays, promos and weather. That one rule lets a single model forecast the whole next week without using anything it couldn't have known, and a test checks it. The model is a small PyTorch network that predicts each hour relative to the store's own 28-day level, so it works for a quiet suburban grill and a busy CBD site alike.
Over 13 held-out weeks it misses by 1.5 customers an hour, against 2.0 for the usual “same as last week” guess. The randomness in the data alone accounts for 1.3. A typical hour only sees about five customers, so the daily error, 13.7%, is the number that matters for a roster.
From Python to C#
The model is trained in Python but runs inside the ASP.NET API: it's exported to ONNX and loaded with ONNX Runtime. In a hand-off like that, the risky part is the features, not the model. So the C# feature builder is tested against pandas on 505 hours of a deliberately awkward fixture (WA, Easter, a promo and a missing weather day) and agrees to within 1e-9, and the C# predictions match PyTorch to within 1e-4.
Suggestions a manager can argue with
The staffing rule is deliberately simple: predicted customers divided by how many one person handles on that station, rounded up, never below the station's minimum. Managers can see the rule and change it for their site. Under the roster, a Demand & Staffing panel charts predicted customers against suggested and rostered staff and lists what to fix, like “Under-staffed 17–23 · short up to 3 people”. Rostered counts are worked out in the browser, so adding a shift clears its flag straight away.
src/Rostra.Api/Forecasting/Staffing.cs
/// <summary>People needed on one station: ceil(predicted ÷ rate), at least MinStaff, zero when closed or off-hours.</summary>
public static int Suggest(double predictedTransactions, StationRule rule, int hourOfDay, double openThreshold)
{
if (predictedTransactions < openThreshold || !rule.ActiveAt(hourOfDay) || rule.TransactionsPerStaffHour <= 0) return 0;
// The small epsilon keeps 16.0000001 / 8 from rounding up to 3 people.
var needed = (int)Math.Ceiling(predictedTransactions / rule.TransactionsPerStaffHour - 1e-9);
return Math.Max(rule.MinStaff, needed);
}
public static HourStatus Classify(bool open, int suggested, int rostered, int overTolerance) =>
!open ? HourStatus.Closed
: rostered < suggested ? HourStatus.Under
: rostered > suggested + overTolerance ? HourStatus.Over
: HourStatus.Ok;