Afterglow Software

Capabilities

Stock you can trace

Every stock number can be explained. Nobody types it in. Each sale, return, delivery, and count is a line on its trail, and the lines always add up to the number.

How to read this datasheet

Every number has a trail

Each change is written down as it happens: an order, a cancellation, a run arriving, a count, samples, or damage. Add the lines up and you get the number, so a question about stock always has an answer.

Stock moves only through events. Each change runs as one D1 batch: an UPDATE to the product’s stock and an INSERT into stock_events with the change, its kind (one of 11, from start to adjust), the lot, what it came from (an order, a run, a creator), the reason, and who made it. A batch is one transaction, so the number and its line are written together or not at all.

kinds of change, each named
11
numbers typed in by hand
0

The last one sells once

When two people reach for the last one at the same moment, one gets it. The other hears it just sold out before any payment page opens, so nobody pays for something that isn’t there.

The products table carries CHECK (stock >= 0). Going to payment takes the stock in one batch, written as held at checkout. A second batch that would take stock below zero fails the CHECK, rolls back whole, and the buyer is told it sold out. The Stripe Checkout session lasts 31 minutes. A scheduled sweep asks Stripe about any session still open 5 minutes past that, then places the order or returns the stock as cancel events.

a bag is held while its buyer pays
31 min

Sets sell from their pieces

A gift set has no stock of its own. It’s made of the products in it, so it sells out the moment any piece does, and each one sold comes off every piece.

A kit’s availability is the lowest, across its pieces, of the piece’s stock divided by how many the kit holds, rounded down. Its events are written as events for each piece, so every piece’s trail stays complete.

Back in stock, once

Customers can ask to hear when something’s back. When it is, each person gets one email, even if the job that sends them runs twice at the same moment. Asking twice doesn’t add anyone twice.

Requests are unique per email and product. The job picks requests for active products with stock, skips suppressed addresses, and claims each one with an UPDATE that sets notified_at only where it’s still empty, before the email is written. A second copy running at once finds the claim taken and sends nothing. Up to 500 requests a run.

email per person, per product
1

The detail

Switch to Technical for what an IT team asks.

Counting the shelf
A count at the warehouse writes only the difference, with the reason. History is never overwritten.A count records counted minus expected as a count event, where expected is what can be sold plus what’s promised to paid orders not yet shipped. The line reads “Counted N at the warehouse, M expected” with the reason, and the count is logged with who made it.
Three numbers, not one
The back office shows what can be sold, what’s promised to paid orders not yet shipped, and what should be on the warehouse shelf, which is the two together.Promised is summed from the items of orders with status paid, with sets counted as their pieces. Warehouse is stock plus promised.
Sold out on purpose
The owner can hold a product back. It shows as sold out whatever the stock, and its trail doesn’t change.on_hold sets availability to 0 without touching products.stock or writing an event.
When a renewal can’t be packed
If a subscription’s delivery sells out between the charge and the packing, the whole charge is refunded.A renewal whose order fails the stock CHECK after the charge is refunded in full through Stripe.

Where it runs

Afterglow’s own store engine, running in a working build that isn’t public yet.

All capabilities

Revision A, November 25, 2026.