A self-hosted dashboard for tracking reselling profit & loss across multiple platforms, buying groups, and users, with a companion browser extension for automatic order syncing and cashback rate scraping.
- Dashboard — P&L stats by month, quarter, YTD, and all-time
- Order management — manual entry, bulk CSV import (Amazon & Walmart), Gmail sync, and automatic sync via browser extension
- Multi-user — separate order history and settings per profile
- Buying groups — track payouts per group with full order history
- BuyingGroup.com — live deals browser with cashback spread calculator and payout history
- BFMR — tracker view, active deals with merchant links and cashback rates, and shipment insurance
- Portal rates — automatic CBM (CashbackMonitor) scraping via extension; hover any merchant link to compare all portal rates
- Analytics — revenue, cost, cashback, and profit breakdowns with filtering
- Credit card cashback — auto-calculate cashback per order by card rewards rate
- Address rules — auto-assign orders to buying groups by shipping address pattern
- Blocked addresses — skip personal/home shipments on import
- Deduplication — normalize order numbers (strips non-digits) to prevent duplicate imports
- Order time —
Order.orderedAtis the retailer's own order-placed time, taken from order-confirmation emails on any platform (a direct email's Date, or the original Date in a forwarded block when it carries a time zone; a forward's own time is never used). It is only filled or moved earlier, never later, and is backfilled by the normal email sync. Costco eGift delivery time is kept the same way inOrder.egiftDeliveredAt. - Digest purchase-limit resets — the daily digest's Resell lines (
lib/digestRunner.ts,lib/resetLines.ts) list which limits reset the next LA day: Amazon 7 days afterorderedAt, Walmart order slots 24 hours afterorderedAt(non-Apple items only), Costco gift cards 14 days after eGift delivery. Product names and reset times only, within the queue's 10-line, 200-character, no-private-words limits; orders record no retailer account, so they are not grouped by account. - Browser extension — syncs Amazon, Walmart, Costco, and BigSky Buyers orders; scrapes CashbackMonitor rates; accepts commands from the tracker
- Next.js 16 (App Router, standalone output)
- Prisma 7 with
@prisma/adapter-better-sqlite3 - SQLite via better-sqlite3
- Tailwind CSS v4
- Docker + docker-compose (macvlan)
services:
app:
build: .
networks:
br0:
ipv4_address: ${CONTAINER_IP} # set in .env
volumes:
- /mnt/user/appdata/reselling:/data
- /mnt/user/data/Documents/GC:/data/files
shm_size: "512mb"
environment:
DATABASE_URL: file:/data/resell.db
restart: unless-stopped
networks:
br0:
external: true
name: br0git clone https://github.com/frindle/resell-tracker
cd resell-tracker
echo "CONTAINER_IP=10.0.x.x" > .env # replace with your desired static IP
docker-compose build
docker-compose up -dBrowse the app at http://<CONTAINER_IP>:8088, not :3000. Port 8088 is
the Caddy front door that serves the app and the sidecar's noVNC display
(/vnc/vnc.html) from one origin — the "connect to VNC" links in Settings/Orders
are same-origin relative paths, so they only work when you're already on :8088.
Port 3000 is direct Next.js access with no /vnc route (a :3000/vnc/... link
404s by design).
git pull && docker-compose build && docker-compose up -dThe container runs prisma migrate deploy automatically on startup before starting the server.
Headless sync sidecar (Walmart, Costco, CashbackMonitor, MGCP; Amazon is the browser extension only)
The app service in docker-compose.yml now runs all three services:
- The Next.js application on port 3000
- The headless retailer sync with Chrome under Xvfb and VNC server on port 5900
- The gift-card OCR service (if enabled) on port 8080
The sidecar functionality is now integrated into the main app container, so there's no separate sidecar or giftcard-ocr services in the compose file.
Command types the sidecar can claim:
| Command | What it does | Needs a saved session |
|---|---|---|
SYNC_AMAZON_PAGES |
Amazon order sweep (browser extension only) | extension |
SYNC_AMAZON_ORDER |
Re-scrape specific Amazon orders (payload {orderNumbers}; browser extension only) |
extension |
TRACK_AMAZON |
Amazon tracking lookup (browser extension only) | extension |
SYNC_WALMART |
Full Walmart order sweep | walmart |
SYNC_COSTCO |
Costco online orders + warehouse receipts | costco |
SCRAPE_CBM |
cashbackmonitor.com portal rates → /api/portal-rates/bulk |
none (public site) |
SYNC_BIGSKY is deliberately not here: BigSky already syncs entirely
server-side (/api/bigsky/sync-orders with fetch: true, driven by
lib/autoSync.ts every 6h using the stored bigsky_cookie), so a
browser is not involved on either side. Same for the CardCenter and BFMR
syncs.
Costco caveats worth knowing before you rely on it:
- The
ecom-api.costco.combearer token cannot be minted independently — it is intercepted off Costco's own in-page requests, so a live logged-in Costco session in the sidecar is mandatory and there is no fallback. - Warehouse receipts are fetched actively: a LIST query over the sync
window, then a DETAIL query per
transactionBarcode. The request shapes, thedocumentType/documentSubTypeenum values, and the unusual date format (6/01/2026— single-digit month, zero-padded day) are recorded insidecar/costco-receipts-capture.md, captured from a live session. Read that file before changing the queries. Anything the interceptor happens to capture is merged in on top. - The Costco login queue is opt-in. Set the
costco_sidecar_enabledsetting totrue(Settings page) or the sidecar will not park a Costco login window on the shared VNC display.
Add to .env:
SIDECAR_IP=127.0.0.1 # now always localhost since we're in one container
SIDECAR_TRACKER_USER_ID=1 # the tracker user id this sidecar imports orders as
VNC_PASSWORD=choose-a-real-password # protects the interactive-login VNC sessionOne-time setup per site (required before any sync will run — there is no automated login; Walmart and Costco CAPTCHA-challenge scripted logins regardless of password correctness):
docker-compose up -dto start the container.- Connect a VNC client to
${SIDECAR_IP}:5900usingVNC_PASSWORD(if you didn't set one,docker logs <container>prints a one-time generated password on first start). - In another terminal:
docker exec -it <container> node src/login.js walmart(orcostco). A real Chrome window opens on the VNC display — log in normally, including any 2FA. Once the orders page loads, the script saves the session and exits automatically. - Repeat for the other sites you use.
Sessions are saved to /data/sessions/{walmart,costco}-session.json on
the shared volume and reused headlessly-in-appearance-only (still a real
headed browser, just unattended) for every future sync — no password is
ever stored. If a session expires, the sync fails, logs an entry on
/api-errors, and sends a Pushover alert (if configured) instead of
attempting an automated re-login — repeat step 2-3 to fix it.
Failure screenshots + page HTML land in /data/debug/ for post-mortem
since there's no live DevTools access to an unattended run.
Step plans (signed). The extension's step plans live in config/plans.json
(a byte-for-byte copy of the extension's src/lib/plans.default.json) and are
served with a detached Ed25519 signature at GET /api/extension/plans
({plans, sig}). To change a plan, edit config/plans.json in a pull request:
the Sign plans workflow signs it with the PLANS_SIGNING_KEY secret, commits
config/plans.json.sig to the branch. GitHub holds the pull-request runs that the
bot's commit starts for approval, so the required check stays pending until a
maintainer reruns the held CI run (gh run rerun <id>) or approves it. The
workflow prints that run's id in its summary. The public key is
config/plans.pub (base64 raw key); once it exists, a missing or stale .sig
fails the unit tests. The validator (lib/stepPlan.ts) mirrors the extension's
and the two must change together.
Session-error contract (every site, including bfmr). The corner sync
panel (components/SyncStatusIndicator.tsx) shows a failed command's
result.error in red, and adds the "Login page is already open, connect
to sidecar" noVNC link when isSessionExpiredResult() (lib/syncStatus.ts)
matches. It keys only on the message text, never on the type or site. For
a sidecar handler to trigger it:
PATCH /api/extension/commands/:idwithstatus: 'failed'and a result object whoseerrorcontains<site> session expired or not logged in(whatthrow new SessionExpiredError('<site>')produces in poll.js's catch) orno saved <site> session(poll.js's no-session fast-fail). Any othererrorstring shows as a plain failure.- Site key
bfmris used in:SITES.SYNC_BFMR.site(poll.js),${site}_session_status/_session_checked_atsettings,/data/sessions/bfmr-session.json,SITE_CONFIG.bfmr(loginFlow.js) andALWAYS_SITES(loginQueue.js), which is what actually parks the BFMR login page on the VNC display. The app never enumerates site keys.
Set BLOOM_LEDGER_URL (the same address the books use) to the bloom-ledger base URL. The tracker then pulls each finished month's mock invoice from the ledger's read-only /v1/invoice/months and /v1/invoice/monthly routes: daily after about 06:30 Los Angeles time, and on demand from the Bloom page. The ledger is one person's earnings, so only the tracker owner's account (OWNER_USER_ID, else the first user) pulls it, and the books' Darkbloom tally posts only into the owner's books. One row per month; a re-run only updates a month whose ledger hash changed. Analytics shows reselling, Bloom and a combined total, and /bloom/<YYYY-MM> is a printable invoice. A month counts in a period only when the whole month lies inside it. Net = gross - Darkbloom fees - power - depreciation - lease (the Mac is owned; the lease line is 0 when none is set). The pages and /api/bloom/* have their own gate instead of the sign-in cookie: opened by IP on the LAN there is no login; opened through the domain, a verified Cloudflare Access token is required (CF_ACCESS_TEAM_DOMAIN and CF_ACCESS_AUDS; unset, domain requests are refused). A request is "through the domain" when it carries any Cloudflare header (Cf-Ray, Cf-Connecting-Ip, ...), which Cloudflare always adds. The rest of the app keeps its user picker, optional AUTH_PASSWORD and signed cookie. Unset BLOOM_LEDGER_URL, the feature is off.
Each finished month's invoice also records the Darkbloom payout. Paid comes from deposits: all posted Darkbloom-marked bank deposits, oldest first, are allocated FIFO to the invoices in month order, each up to its payout (gross less the Darkbloom fee); due = payout minus what the month was allocated, and money that arrives before a month's invoice exists waits and is allocated when that invoice appears. Month status: paid, part_paid, due or nothing_due. Requests are attempts, several a month and not tied to a month: they come from the ledger's read-only /v1/withdrawals (a withdrawable drop that earnings minus API draws do not explain; the ledger also reports a status of requested or refunded, a missing or unknown one counts as requested) or from a hand entry (POST /api/bloom/payments with requestedAt as YYYY-MM-DD and requestedCents). Every ledger row is stored by its key; a row later reported refunded gets refundedAt, never matches a deposit, and lets go of one it had matched. A request is matched to an unused deposit posted from the request day to 14 days later whose amount is within the larger of $1 or 1% (closest amount, then earliest), so a retry after a refund matches its own deposit. Request status: sent, pending, flagged (older than 7 days, no deposit, not refunded) or refunded. Two copies of each invoice are stored in BloomInvoiceCopy and never edited: copy 1 when the invoice is first stored (with the due at that moment), copy 2 once the month's due reaches 0 (with the covering deposits, the request each matched, and the last covering deposit's date as the month's sent date). Read them at /bloom/<YYYY-MM> or GET /api/bloom/invoices/<YYYY-MM>?copy=1|2; track everything with GET /api/bloom/payments ({months, requests}). Nothing here calls a Darkbloom write endpoint or moves money. Runs with the daily pull and the Sync button.
npm install
npx prisma generate
npx prisma migrate dev
npm run devOpen http://localhost:3000.
- Navigate to your tracker URL and create the first user account.
- Open Settings and configure your integrations (see table below).
- Install the browser extension (see resell-tracker-extension).
- In the extension options, set your Tracker URL, API Key, and select your user.
All integrations are configured in Settings after first login.
| Section | Fields | Purpose |
|---|---|---|
| BFMR | Email + Password | BuyForMeRetail tracker, deals, and auto-cancel. API key/secret are auto-fetched on save. |
| BuyingGroup.com | Email + Password | Receipt sync and live deals browser |
| CardCenter | Email + Password | Gift card submission and payment sync |
| Gmail | Address + App Password | Order confirmation email parsing |
| Pushover | User Key + App Token | Push notifications for overdue orders |
| Portal Rates | Merchant / Portal / Rate | Manual cashback rate entries (auto-filled by extension) |
| Browser Extension | — | Queue commands and view recent command status |
The main order list with filtering, sorting, and bulk actions.
Filters: Platform (Amazon / Walmart / Other), status, date window, buyer/group, and free-text search.
Sync buttons (top right):
- Sync Amazon / Sync Walmart / Sync Costco — queues a command on the
ExtensionCommandqueue. Whichever worker polls first claims it (within about 60 seconds) and opens the retailer page to scrape new orders. Amazon runs only in the browser extension; Walmart and Costco run on the sidecar. Live status — queued, running, completed, failed, and which worker claimed it — appears in the bottom-right corner while it runs. - Resync Groups — re-runs BuyingGroup.com receipt sync, BFMR payout sync, and CardCenter payment sync server-side (no extension needed).
- Import — manual CSV import for Amazon and Walmart order exports.
Bulk actions (select orders via checkbox):
- Submit tracking numbers to BuyingGroup.com
- Mark selected orders as paid
- Delete selected orders
Live deal browser pulling from BFMR's active deal list.
Sort order:
- Deals with at least one in-stock merchant appear first
- Within that: above-retail deals sorted by highest retail price
- Then below-retail deals sorted by highest retail price, tie-broken by closest to break-even
Merchant links appear below each deal title showing all available buy-from stores. Green border + ✓ = in stock.
Cashback rates: Next to each merchant button you'll see the best portal cashback rate (when scraped). Click cbm↗ to open CashbackMonitor directly, or hover over it to see all portal rates for that merchant in a popup.
↺ rates button — re-fetches portal rates from the database without a full page reload. Use this after the extension finishes a CBM scrape to see the new rates.
Reserve button — opens the reservation panel for that deal, letting you select an item and quantity, then reserve or add a watcher.
Shows all tracked BFMR orders synced from your account. Columns include status, order amounts, shipment details, and insurance value.
Cancel button — available on reserved or purchased items. Calls the BFMR cancel API and marks the order as cancelled in the local DB.
Tracking submission. Two ways, both through one shared core (lib/bfmrSubmitReservation.ts):
- By hand from the order detail page (
POST /api/bfmr/submit-reservation-tracking). - Automatically, as Amazon packages are captured (
lib/bfmrAutoSubmit.ts). Each captured package is checked on its own by the package matcher (lib/bfmrPackageMatch.ts): it is sent only when every item maps to one BFMR reservation, its units fit what is still unsubmitted, and (for a partial box) no quantity was assumed and exactly one open line has units left. A 2-unit box of a 4-unit line goes out now; the next box goes out when it is captured. Anything else is left for hand submission. Locked or cancelled orders, orders with rejected items, reservations missing their BFMR ids, and more than 5 reservations in one run are skipped. - The app setting
bfmr_auto_submitpicks the mode:off,plan(default when unset: logs what it would send, sends nothing), oron. GET /api/bfmr/auto-submit-replayis a read-only check of the matcher against history: per order it shows the rows it would send next to the submissions already recorded by hand, with an agree/disagree verdict.
The companion extension runs in the background and communicates with your tracker.
Setup:
- Install from the GitHub releases page (Chrome: load unpacked from
dist/zip; Firefox: install the.xpi) - Click the extension icon → ⚙ Settings
- Enter your Tracker URL (e.g.
https://reselling.yourdomain.com) - Enter your API Key (find it in tracker Settings → Browser Extension)
- Select your user from the dropdown
What it does automatically:
- Polls your tracker every 60 seconds for queued commands
- Executes sync and scrape commands in the background
- Reports results back to the tracker
Commands (queued from Orders page or Settings):
| Command | Trigger | What happens |
|---|---|---|
| Sync Amazon | Orders page → Sync Amazon | Browser extension opens amazon.com/your-orders, scrapes recent orders, imports new ones |
| Sync Walmart | Orders page → Sync Walmart | Opens walmart.com/orders, scrapes and imports |
| Sync Costco | Orders page → Sync Costco | Opens costco.com account page, scrapes orders and receipts |
| Sync BigSky | Settings → Sync BigSky | Opens bigskybuyers.com, scrapes payout data |
| Refresh CBM Rates | Settings → Refresh CBM Rates | Opens CashbackMonitor for each active BFMR merchant, scrapes portal rates, stores in DB |
Extension popup shows the tracker command poll status (last poll time). All sync commands are now initiated from the tracker portal rather than the popup.
Portal rates are cashback percentages from shopping portals (Rakuten, TopCashback, etc.) scraped from CashbackMonitor.
To refresh rates:
- In Settings → Browser Extension, click Refresh CBM Rates — this queues a
SCRAPE_CBMcommand - The extension opens CashbackMonitor for each active BFMR merchant in background tabs, scrapes rates, and POSTs them to your tracker
- On the BFMR Deals page, click ↺ rates to reload the now-populated rates
Rates appear next to each merchant button on the deals page. Hover cbm↗ to see all portals.
Each buyer/buying group has its own page showing order history, payout totals, and expected vs actual payment tracking.
Resync Groups (Orders page) runs:
- BuyingGroup.com receipt sync — matches scanned receipts to orders
- BFMR full sync — updates statuses and payout amounts, and queues the
sidecar's
SYNC_BFMR(seelib/syncGroups.ts); its progress and any login-needed link show in the corner sync panel - CardCenter payment sync — matches CC payments to gift card submissions
CardCenter → Waitlist lists every unsold gift card (unsold is exactly
ccSubmittedAt IS NULL) with the rate CardCenter is paying for that brand and
denomination right now. Park a card with a target rate and a deadline and it
sells itself the moment the rate reaches the target:
- Run now places the reservations immediately (Preview shows the same plan without submitting anything).
- Run automatically (hourly) is OFF by default and per user — it sells real
gift cards unattended, so it only runs after you switch it on
(
cc_waitlist_auto_enabled). - The deadline is inclusive and is checked before the rate, so a lapsed card is never sold; it is marked EXPIRED and stays on the page.
- Cards that qualify against the same buy order go out as one reservation.
Revenue, cost, cashback, and profit breakdowns. Filter by date window (30d / 90d / 6mo / 1yr / all).
Each order shows two separate facts: whether the carrier delivered the package, and whether the buying group received it. The orders list shows them as two small badges, and the order page shows one line, for example "Delivered Nov 25 (UPS) · Received by BG Nov 26". When every package was delivered 3 or more days ago and the group has not received it, the second badge turns amber ("Not received by BFMR yet (3 days)"). With several packages the order only counts as delivered once all are ("1 of 2 delivered").
- Carrier side: delivery dates come from the browser extension's FedEx and UPS page checks (every order bound for BuyingGroup, BFMR or BigSky, shipped in the last 14 days, a few numbers per run and per day) and from Amazon's and Walmart's own delivered dates. USPS pages are not checked.
- Group side: BuyingGroup is read from the linked commitment (fully filled = received; partly filled is shown as unknown because the units cannot be matched to one order). BFMR only exposes a received flag and status, so no received date is shown. BigSky is read from the scan that carries the order's tracking number.
- BFMR Deals page overhaul:
- Merchant links moved to full-width subrow below deal title
- In-stock deals sort to top; within groups, sorted by highest retail price (above-retail first, then below)
- Added Retail price column alongside Value and vs-Retail
cbm↗link always visible; hover popup shows all portal rates for that merchant- Closest-to-break-even tie-breaker for below-retail deals
- Portal rates (CBM scraping):
- Extension now POSTs rates from the background service worker (bypasses cashbackmonitor.com CSP that blocked content script fetch)
- Extension poll headers include
X-Extension-User-Idso vendor lookup works without a browser session /api/bfmr/vendorsfalls back toX-Extension-User-Idheader when no session cookie present↺ ratesrefresh button added to BFMR Deals page
- Orders page: Added Sync Amazon / Sync Walmart / Sync Costco buttons that queue extension commands directly from the portal
- Settings: Extension command queue table shows last 20 commands with type, status, result, and age; refreshes after queuing
- Extension popup: Removed Amazon/Walmart/Costco/BigSky sync rows — syncs now initiated from the tracker portal
- resolve-link: Skip redirect-following for known retail domains; extract real destination from snaptheprice.com/fatcoupon.com intermediate redirects
- Extension v1.1.36
- BFMR Deals page: pre-fetch deal items in background batches of 5; vendor filter dropdown
- BFMR Deals page: Cancel button on tracker page for reserved/purchased items
- Fix:
/api/portal-rates/bulkupsert with compound unique key(merchant, portal, category) - Fix: CBM content script always sends
CBM_SCRAPE_DONEeven when no rates found - Fix: alarm fires immediately on extension install/startup;
lastPollrecorded at top of poll function - Fix:
SYNC_AMAZON_ORDERcommand deduplication before create - Fix:
bfmr/vendorsuses correct user ID from session - Fix: Amazon order sync throws on error instead of returning
{ok:false}(enables retry logic) - Fix:
patchCommandretries 3× with backoff instead of silently swallowing errors - Extension v1.1.35
- BFMR settings: replace separate API key/secret fields with email+password login (API key/secret auto-fetched and saved on connect)
- Rename
bfmrOrderId→groupReferenceId— generic group reference field used by both BFMR (order ID override) and CardCenter (payment ID) - CardCenter payment sync: match gift cards by
ccGiftCardIdto payment listings and distributebgPaidAmountper order - Add CardCenter to "Resync Groups" button on orders page
- Add per-tracking-number value notation on order detail page (
trackingValuesJSON field) - Hide Gmail integration in settings until parsing is fixed
- Fix first-user setup stuck on "Creating…" (hard redirect after cookie set)
- Simplify login page — adding users moved to Settings → Users
- Add payout history per buying group on the Buyers page
- Add BuyingGroup.com deal payout history (price change timeline)
- Add order deduplication on CSV/email import (normalized order number comparison)
- Add "how far back" selector for Gmail sync
- Auto-assign buying groups from shipping address rules on CSV import
- Fix Docker build — copy pre-built
node_modulesfrom builder stage to avoid recompiling native modules in runner - Exclude
tsconfig.tsbuildinfofrom Docker build context
- Multi-user profiles with session cookie auth
- CSV import for Amazon and Walmart orders
- Gmail IMAP sync for order confirmation emails
- Shipping address rules and blocked address patterns
- Email routing rules for multi-user Gmail setups
- BFMR tracker, deals, and test connection
- BuyingGroup.com receipts and live deals browser
- Analytics page with date range filtering
- Credit card cashback auto-calculation
- Buying groups (buyers) with order assignment