Files
dtf-system/docs/CONTEXT.md
Cauê Faleiros 35e64d77d7
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m20s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 58s
feat: "Arte tratada" flags the orders whose final the team prepared, counted in Números
Dropstar's internal rules (2026-10-26) asked how to tell art that arrived
ready from art the designer had to fix, and Marcus agreed on 2026-10-27 to
mark it automatically, for the designer's productivity.

- an order whose approved final is not the customer's art (not the file the
  system generated from it, not one of their originals, not a correction
  they sent) shows "Arte tratada" on its card and in the order, with who
  approved it
- Números counts the period's treated orders, the share of all orders, and
  how many each person approved
- the Kanban's cancel text: the money stays as the customer's credit, in
  Dropstar's financial control (rule D-15), no longer a refund
- Números' machine table shows the orders waiting in Arte conferida again;
  it still looked for the old print queue

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 10:01:35 -03:00

626 lines
34 KiB
Markdown

# DTF System - Project Context for AI Agents
## Purpose of this document
Read this document before changing code, documentation, architecture, or scope.
It is the current English source of truth for the project. It supersedes older
decisions in `README.md`, `docs/historico/ESPECIFICACAO.md`, `schema.sql`, and the existing
prototype code whenever they conflict.
Update this file whenever the team makes a material product, process, or
architecture decision.
## Project goal
Build a DTF ordering and production-flow system for Dropstar/Altus.
The current process is slow and manual: customers send artwork through
WhatsApp, staff forward files, designers discover problems late, and production
status is not visible outside the factory. The business has substantially more
machine capacity than it currently uses. The goal is to let customers place DTF
orders online, pay, send artwork, and follow production without making
WhatsApp, shared folders, or manual handoffs the bottleneck.
The customer-facing value is speed and clarity. The operations value is a
traceable queue and fewer lost or manually handled orders.
## Current MVP scope
The MVP must be delivered in **at most three weeks**. The target is a working
online system, not factory-machine automation.
### Included
- Dedicated DTF site/subdomain.
- Existing Site DTF commercial rules and product experience.
- Direct, resumable multipart file upload to Cloudflare R2.
- Mercado Pago payment integration with signed and idempotent webhooks.
- Freight quotation and charging at checkout.
- Idempotent Tiny/Olist order integration and order traceability.
- Online Kanban for production status and secure file download.
- Customer status notices: not sent by this system. The client's own n8n sends
WhatsApp messages from Tiny's status changes (decided 2026-10-16); the Kanban
only offers a one-click WhatsApp link for a correction.
- Private object storage, 30-day file retention, backups, and basic security.
- Operator guidance for the factory team.
### Explicitly outside the three-week delivery
- Automatic pre-flight validation. It will be validated after delivery using
real customer files and real printed output, then refined as support work.
- Direct FlexiPRINT integration.
- Factory-side agent, hot folder, internal file server automation, VPN, and
heartbeat monitoring.
- Production-room dashboard, printer/machine telemetry, and advanced reports.
- Automated shipping-label purchase, shipping-label printing, and dispatch
automation. The MVP freight scope is quote selection and charging only.
- Personalized cart behaviour based on past orders, day, or time.
After delivery, the team provides support and evaluates requested changes. Do
not turn post-delivery support into a new committed delivery phase without an
explicit decision.
## Agreed production model
```text
Customer browser
-> Site DTF / API on VPS
-> direct multipart upload to private Cloudflare R2
-> Mercado Pago payment + freight selected at checkout
-> Tiny/Olist order record
-> online Kanban
-> factory operator downloads final file and imports it manually into FlexiPRINT
```
WhatsApp is a notification channel, not the artwork-upload channel. It is used
for payment confirmation, correction requests, production status, and order
completion.
The operator works through the browser. The factory does not need an installed
agent or an internal server for the MVP.
If the factory internet connection fails, only the factory team temporarily
loses access to the Kanban and secure downloads. The public portal, payments,
uploads, R2 objects, queue, and cloud services remain online. Factory work
resumes when local access returns.
## Infrastructure and deployment
- **VPS:** runs the website, API, worker, PostgreSQL, ClamAV, Kanban, and
third-party integrations.
- **Cloudflare R2:** private S3-compatible object storage for original uploads
and final files. It does not run the application, database, worker, or
antivirus.
- **Upload path:** the browser uploads directly to R2 using short-lived,
server-issued presigned multipart URLs. Large files must never be proxied
through the VPS.
- **Deployment:** one Portainer-owned `dtf-cloud` Docker Swarm stack. One Gitea
Actions workflow tests/scans, publishes `latest` plus commit-SHA application
images, and calls the Portainer webhook. Activation remains blocked pending
the production work listed below.
- **Kanban access:** configure `OPERATOR_EMAIL` and `OPERATOR_PASSWORD` as
stack environment variables. If the email is absent, only Kanban login is
blocked; the rest of the stack remains available.
- **Recommended VPS baseline:** 4 vCPU, 16 GB RAM, and 200 GB NVMe. Existing
VPS capacity may be used if it safely meets or exceeds this baseline.
- **Backups:** PostgreSQL backups go to R2. Application secrets are never
committed to Git.
## File retention
The business does not want an unlimited artwork library.
| Artifact | Retention |
|---|---:|
| Incomplete multipart upload | 1 day |
| Rejected or infected upload | 3 days |
| Customer original after approval | Up to 7 days |
| Final print artwork | Maximum 30 days from the first upload |
| Order history and metrics | Kept in the database without keeping the image |
The 30-day retention decision overrides older references to 90 days or
12-month artwork reordering.
## R2 planning cost reference
R2 cost is driven primarily by the average number of gigabytes stored during a
month; read/write operations are expected to be a much smaller cost at the
project's scale. There is no egress charge in the current planning model.
The client-facing roadmap uses the following planning examples, based on
standard R2 storage pricing, the included storage allowance, and an exchange
rate reference of USD 1 = BRL 5.13:
| Average storage | Approx. R2/month | Approx. BRL/month |
|---|---:|---:|
| 100 GB | USD 1.35 | BRL 7 |
| 500 GB | USD 7.35 | BRL 38 |
| 1 TB | USD 14.85 | BRL 76 |
| 3 TB | USD 44.85 | BRL 230 |
These are planning estimates only. Confirm Cloudflare pricing, exchange rates,
taxes, and payment-provider fees before presenting a commercial quote.
## Commercial rules
The rules in `web/index.html` and `app/core/pricing.py` are approved as the
current source of truth. Do **not** redesign, simplify, or change prices,
minimums, rounding, or product modes without explicit approval.
The Site has four product modes, each with one price per metre (Dropstar,
2026-10-23, live in the code since 2026-10-26). It replaced the five-band
ladder by grade, its "a partir de R$ 14,90" and the separate assembly charge
for loose artwork:
| Product | Ready sheet | Loose artwork |
|---|---:|---:|
| DTF textile, 57 cm | R$ 19,90 | R$ 21,90 |
| UV sticker, 28,5 cm | R$ 79,90 | R$ 89,90 |
The grade (nota) is still computed and shown, to the customer, on the Kanban
and in Tiny's item note: it explains the file and no longer changes the price.
Artwork below 96 DPI is still refused, and a resolution warning must still be
acknowledged. The server still recomputes the grade from the files at checkout
(`app/grade_check.py`) and holds for review a cart whose grade the files do not
support, so the grade shown stays honest; the review reason "Nota informada sem
análise da arte" existed only to stop a discount and was removed. One-metre
minimum and ten-centimetre billing rounding. The prices are `PRECO` in
`web/site-config.js` and `PRICES` in `app/core/pricing.py`, and
`tests/test_pricing.py` checks they agree; every price on the Site's pages (top
chip, home example, product cards, product selector, price table) is filled
from `PRECO` through `data-preco`.
Customers buy with a CPF (a person) or a CNPJ (a company), check digits
validated on both sides. The value keeps the `cnpj` key in orders, quotes and
accounts; Tiny gets a CPF contact as `tipoPessoa` F, Mercado Pago the matching
identification type, and only CNPJs are looked up in the company registry.
The browser may display the calculation, but production payment creation must
recalculate and validate all price, quantity, and freight values on
the server. Client-provided totals are never authoritative.
Normal JPG/PNG uploads are individual artwork by default, including when uploaded
from the by-metre panel. They use the existing loose-artwork editor, printed
width, quantity, and live packing canvas; packed height determines metres.
Customers uploading an already assembled film-width image must explicitly select
the ready-sheet option before uploading. PDF and manual-format ready sheets keep
their existing workflow. These models keep their separate prices;
image dimensions alone must never classify a normal artwork as a finished sheet.
A finished sheet someone must open by hand (CDR, AI, PSD, TIFF, or a length the
customer typed) pays the product's price plus `MANUAL_FILE_EXTRA_CENTS` per
metre (2026-10-13, asked at the 7 October meeting to steer customers to PNG).
The production stack sets it to 200, R$ 2,00 a metre (Dropstar, 2026-10-23);
a value set in Portainer overrides it, and it is 0 locally and in CI. The
amount is the client's to set. The Site reads it from `/api/session` and shows
it before checkout (product page, help text, price table);
`app/core/pricing.py` charges it.
## Freight
**Current (2026-10-15):** the cart quotes every carrier configured at once and
lists the options cheapest first, with the delivery time: Jadlog .PACKAGE
(`app/jadlog.py`) and Correios PAC and SEDEX (`app/correios.py`, Dropstar's
contract 9912551407, card 0076691373), plus pickup in Franca. A carrier that
does not answer is left out; the customer's choice is quoted again by the
server at approval. All carriers price the same package (`app/package.py`: a
base weight per box, a weight per metre, the box's sides, metres per box).
Correios is on when `CORREIOS_CODIGO_ACESSO` is set; `python -m
app.correios_probe` checks the contract's token, codes (03298 PAC, 03220
SEDEX by default), prices and times. The history below is kept as recorded.
The original visual freight flow in `web/index.html` was a stub with only pickup
functional. The localhost bridge now supports pickup and backend fake freight
quotes; there is still no real carrier quotation or production checkout.
The customer already uses Correios and other shipping platforms. Before freight
can be completed, obtain:
- The platform(s) that should be used as the source of truth.
- API credentials or delegated access for the selected platform.
- Origin postal code/address.
- Available services and carriers to offer.
- Packaging weight and dimensions by DTF length/package.
- Freight business policy: exact pass-through, subsidy, free-shipping rules,
pickup, or other exceptions.
At checkout, the backend must quote freight from the selected source, store the
chosen service and quoted amount, include the amount in the Mercado Pago
payment, and persist it in the order. Do not create a payment before the freight
amount is final.
## Integrations
### Mercado Pago
Card payments: up to 3 installments **with interest paid by the customer**;
1x has no interest (Wagner, 2026-10-14). Interest is Mercado Pago's: its card
form shows each option with the rate, and the order checks
`transaction_amount` (the price), not the total with interest. Keep "parcelamento
sem juros" off in the Mercado Pago account, or Dropstar pays the interest.
Required before production payment integration, not for the local mock milestone:
- Production credentials.
- Webhook configuration/access.
Webhook processing must verify authenticity and be idempotent. A duplicate or
late delivery must not create a duplicate payment, order, message, or queue
card.
### Tiny/Olist
Tiny/Olist is already available. The implementation must create/update orders
idempotently and use the order number for traceability. Confirm the actual API
endpoints, marker/tag behaviour, and rate limits before production use.
### E-mail
`app/mail.py` (2026-10-13): customers' password recovery (a one-time link,
valid one hour, sent to `/conta/redefinir#token`; only the token's hash is
stored and the message text is erased once sent). Since 2026-10-20 the team
gets no alert e-mails: the Kanban and Tiny are where orders are followed.
Messages are queued in the transaction that caused them and
sent by the worker with retries. `MAIL_ADAPTER` is `off` in production until
the client's SMTP account exists (recovery then offers WhatsApp), `log` on the
local stack, `smtp` with `SMTP_*` and `MAIL_FROM`.
Signup (2026-10-14): with e-mail on, an account is created only after the
6-digit code e-mailed to the address is entered (15 minutes, 5 wrong attempts,
a new code after 60 s, at most 5). The password is hashed at the first step
and the code stored only as a hash. The answer is the same for an address that
already has an account: it gets a "você já tem conta" notice instead of a code.
Changing the account's e-mail works the same way: the code goes to the new
address, the e-mail changes only once it is entered, and the old address is
told. Production sends through the client's Locaweb SMTP (set in the stack).
### WhatsApp
WhatsApp is already available, but the technical provider still needs to be
confirmed (official Meta Cloud API, Z-API, or another provider).
Implement only the required customer events:
1. Payment approved.
2. Artwork correction needed, with a secure link back to the site.
3. Order entered production.
4. Order ready for collection or shipping.
Messages initiated by the business may require approved templates depending on
the provider and conversation state. Use an outbox/job mechanism with retries,
delivery status handling, and idempotency. Do not send artwork through
WhatsApp.
## Factory responsibilities after delivery
The client/factory team is responsible for:
- Opening the Kanban, downloading final files, and importing them manually into
the current FlexiPRINT setup.
- Performing real print tests and reporting mismatches in the final file or
printed result.
- Maintaining PCs, printers, FlexiPRINT licences, printing profiles, internal
folders, and the local factory network.
- Informing the development team about changes to prices, freight, operational
rules, or external platforms that need system changes.
The development team delivers the online system, provides usage guidance, and
supports subsequent corrections or scoped enhancements.
## Three-week roadmap
| Week | Delivery | Result |
|---|---|---|
| 1 | Infrastructure and upload | VPS, domain, database, R2, multipart upload, antivirus, and service foundation. |
| 2 | Payment, freight, and order | Mercado Pago, freight quotation, idempotent Tiny/Olist order creation, final file generation, and main Kanban states. |
| 3 | Kanban and handover | Online Kanban, secure download, WhatsApp status messages, 30-day retention, and operational handover. |
## Known implementation status
### Launch status (2026-10-19)
Live on dropstardtf.com.br (Site) and kanban.dropstardtf.com.br (Kanban), with
Mercado Pago in production, Correios PAC/SEDEX and Jadlog, SMTP e-mail and the
daily R2 backup. The system sends no WhatsApp: the client's n8n does, from
Tiny's situação (middleware in the separate api-tiny-n8n project). Tiny orders
are filled in as the store's own (app/tiny.py: payment, carrier, expected
date), with Dropstar's ids where the app may not list them.
Before go-live: Dropstar's category, seller and tag for Site orders in Tiny; a
supervised test order (`python -m app.tiny_probe pedido ... --confirmar`); the
n8n "isDTFIMP" node skipping orders whose numero_ecommerce starts with "DTF-";
then TINY_STATUS_UPDATES=true and TINY_ADAPTER=tiny, a backup,
`ops.launch_reset`, a real Pix and card payment refunded, and the pilot with
5 to 10 customers. The guides' screenshots are reproducible from
docs/guias/telas/.
### Kanban automatic folder (agreed in the 2026-10-07 meeting)
Dropstar's three folders (asked 2026-10-23, agreed 2026-10-26): the Kanban,
open in Chrome or Edge on a factory computer that reaches the server's
folder, signed in with a profile that sees every order (Gestão), keeps the
orders' files in three folders it creates inside the one chosen in
Integrações ("Pastas dos pedidos"), numbered to sort in the flow's order:
"1. Arte recebida" (the file arrives when the order does), "2. Arte
conferida" (the queue; the file moves there with the card and stays while it
prints and is checked in Revisão) and "3. Finalizado" (when the order is
released, kept 30 days there). They are created as soon as the main folder
is chosen. Correção, a cancellation or a
deletion takes the file out; a replaced final is swapped. Orders already
printing when the folder is chosen are not downloaded. A file someone took
out is fetched again only when its order moves on (`POST
/api/operator/queue/folder`, which also returns the files of orders the
folders hold once they print). Who opens each folder is set in the server's
folder permissions. Firefox cannot write into folders: it only downloads the
files entering Arte conferida.
Integrações (2026-10-20): only the superadmin (us) has the buttons, the
details and the Tiny log there (`integrations` capability, app/core/auth.py).
Admins and gestão see each integration's state and summary; anyone who
produces also gets the folder's row with its buttons.
Machines (2026-10-20, app/machines.py): each order keeps one machine, either
chosen in the order panel or given on arrival: the active machine of its
product with the fewest metres open (rec, tra, imp, cor), preferring
those below their optional limit in metres, else the least loaded anyway (the
Usuários page shows it over the limit). A machine switched off, deleted or no
longer printing the product hands its automatic orders, not yet printing, to
that choice again. Only operators are linked to machines (from the user or
the machine form); a linked operator sees only those machines' orders.
Dropstar's corrections of 2026-10-21 already done: the home example priced as
a ready sheet; opening hours 7h to 18h with "send your art any time"; uploads
up to 1 GB (MAX_UPLOAD_BYTES, scanned whole by ClamAV); a Designer profile
(artwork stages only, every order, no machine, queue or cancelling; MOVES
in app/core/auth.py, the "print" capability for the room's side); Números by date range, per machine (metres finished, metres per hour
in Imprimindo, last finished, now) and orders apart from passages. A machine's
metres are the film printed (item `metres`), never the billed ones, and time
two orders spent in Imprimindo together counts once; a stage's median is per
order, the sum of its passages. Layout version 3 (web/site-packing.js): rows
with exact sizes, 5 mm margins top and bottom and between rows, and across
the width 5 mm or the space left shared out equally (1,5 mm at least); the
shape packing is used only when it saves 1 cm or more. A ready sheet with a
residue (ink under 2 mm on both sides, measured in pixels from the ink map in
web/site-sheet.js) or without transparency (under 1,5 % of transparent
pixels; every JPG) cannot be paid for; the preview circles each dot. PDFs
over 150 MB and CDR/AI/PSD/TIFF are not checked. The generated print PDF ends
in a 1,5 cm footer band below the layout, outside the billed length: "DROPSTAR
· Pedido DTF-<Kanban number> · Item 1/2 · date · billed metres" in black
Helvetica, after Dropstar's logo (app/assets). An original used whole as its
own print file (over 300 MB) has no footer. The print proof (app/proof.py):
an order above 10 m, or one whose customer ticked "quero aprovar uma prova" at
checkout (that one arrives marked Aguardando contato), cannot reach Finalizado
before the print room marks Prova OK; the proof is not billed (up to 30 cm,
at most 3 per order). Dropstar's answers of 2026-10-23: JPG is refused in every
product; a PDF over 150 MB is flagged before payment; any non-square piece is
tried both ways; a mirrored (UV) order is flagged on the card and in the PDF
footer; files are named DTF-<number>-item-<n>, the code the Kanban copies;
manual files cost R$ 2,00 more a metre. Also settled by Dropstar on
2026-10-23: no seller on Tiny orders (Tiny sets it from the contact; the
marcador SITE DTF separates the channel), the DTF terms page approved, the UV
mirror stays, the designer does not move to the print queue, and Aguardando
contato has no deadline of its own. There is no videocall: open points are
settled in writing.
Done on 2026-10-26: the single price per product Dropstar asked for on
2026-10-23 (see Commercial rules), on the Site and the server.
Dropstar's flow of 2026-10-23, in the code since 2026-10-26 (app/runtime.py,
app/core/auth.py): the board is Arte recebida, Arte conferida, Imprimindo,
Correção, Revisão, Finalizado. Fila de impressão left: Arte conferida is the
queue, entered only with every item's final file approved, kept as approved
there (to change one, the order goes back to Arte recebida), with its card
order as the print order and "Baixar" for the room; orders that were in the
queue were moved to Arte conferida with a line in their history. Who moves
what (MOVES): the Designer Arte recebida to Arte conferida, asks for
corrections and brings the new art back to Arte recebida or Arte conferida;
the Operador Arte conferida to Imprimindo to Revisão; only the Revisor (and
the superadmin, for support) Revisão to Finalizado, so nobody releases their
own print; Gestão, the coordination, only pulls back, always with a reason
(rule D-20 of Dropstar's internal rules, 2026-10-26): Correção from any
stage, or a step back; Admin, Dropstar's own login, every other move,
including Correção straight to Revisão. A step back belongs to whoever makes
the move it undoes, and to Admin and Gestão. Tiny: Arte
conferida sets "Preparando envio" and Finalizado "Pronto para envio", for
delivery orders too; nothing for Imprimindo, Correção or Revisão. Prova OK
still comes before Finalizado. The customer's portal shows the same steps.
Still to do (2026-10-26):
- The DTF number in Tiny's `numeroPedidoEcommerce`: sent since 2026-10-26,
next to the purchase order `numeroOrdemCompra` (which the resend check
searches), with no channel unless `TINY_ECOMMERCE_ID` is set; Tiny's v3 API
cannot list channels or take one by name. Confirm at the supervised Tiny
test order: the probe reads the number back and fails if Tiny dropped it.
- Before TINY_STATUS_UPDATES goes on: Finalizado now sets "Pronto para
envio" on delivery orders too, so the client's n8n must not send them the
pickup message it sends on that situação.
- Dropstar creates the Revisor users right after the redeploy that brings the
new flow (the profile exists only from then): until then orders wait in
Revisão, and only the superadmin can release them.
- Done 2026-10-27, from Dropstar's answers on their internal rules: "Arte
tratada", an order whose approved final is not the customer's art (not the
file generated from it, not an original, not a correction they sent), is
flagged on the card and in the order, and Números counts those orders by who
approved the final, for the designer's productivity; a cancelled order's
money stays as the customer's credit in their financial control (D-15, the
Kanban's cancel text says so, nothing on the Site); the Kanban keeps
deleting Finalizado files after 30 days; the footer gets the white spot.
- Still open from the internal rules (docs received 2026-10-26): file type by
its first bytes (D-13), every order's origin and a manual order entry in
the Kanban (D-21, D-35; also how orders paid with credit come in), the
rework register (D-02 to D-04), Aguardando contato time out of the time
figures (D-38), and the folders fetching what passed while the Kanban
computer was off.
- Settled on 2026-10-26: the DTF SITE category (986932924, CATEGORY in app/tiny.py),
the white spot also under the print PDF's footer (nothing to change here),
and the montador's order format (customer, files, product, the batch with
the customer's ERP sale numbers, labels or pickup) with a record of each
batch, both for after launch.
- The three folders, once deployed: Marcus sets the main folder on the
factory computer (Chrome, Integrações > Pastas dos pedidos); check on the
first print whether FlexiPRINT keeps reading the file in Arte conferida
after import (the file only leaves that folder at Finalizado).
- Anchor-customer orders from the montador: after the launch; the team's idea
is that Graphs handles that side and sends the orders to this Kanban.
### Active localhost milestone (2026-09-15)
The current implementation target is localhost before any production connection.
Use `docker-compose.yml`, `.env.example`, and `LOCAL_SETUP.md`. The runtime is in
`app/`; historical `portal/`, `kanban/`, `agente/`, and `schema.sql` are preserved
as references and are not imported or started by Compose.
- One local `dtf-cloud` Compose project runs seven long-lived services: Site and
Kanban web gateways, FastAPI Portal/API, PostgreSQL, MinIO, ClamAV, and a
PostgreSQL outbox/scanning worker. Separate database and storage initialization
jobs provision restricted runtime identities, for nine Compose services total.
- MinIO implements the S3 storage boundary with direct multipart browser uploads,
resumable parts, private objects, and short-lived signed operator downloads.
- Payment, freight, and Tiny/Olist use fake adapters only. No production
credentials or integrations are configured. The API and worker have no external
network route; only local web/storage gateways publish loopback ports.
- The original Site commercial calculation and appearance remain the source of
truth. Its existing browser artwork analysis is retained as prototype advice;
no new automatic pre-flight, server artwork analysis, or print-file generation
is implemented or invoked.
- Since client length and grade could be tampered with and automatic pre-flight
is deferred, a local operator manually confirms those commercial inputs before
checkout. This is a development trust-boundary decision, not a new production
promise. The backend calculates all tiers, discounts, assembly-inclusive rates,
one-metre minimum, ten-centimetre rounding, freight, and final totals. Immutable
approved quotes expire after 24 hours. A customer confirms the server total
on the Site to create one idempotent local paid order.
- Paid orders use `rec`, `tra`, `imp`, `cor`, `rev`, `fin` (`fil` until 2026-10-26), with allowed transitions,
operator authentication, concurrency checks, and durable movement history.
Local mock integration receipts are visible in the Kanban.
- The customer portal at `/portal.html` supports local registration/login,
stronger scrypt password hashing with legacy-hash upgrade, revocable HttpOnly
sessions, owned order history/status, secure active
file downloads, and correction uploads. Registration/login claims the current
guest session's records and, once the account's e-mail is confirmed with a
code, every guest order placed with the account's CPF/CNPJ and e-mail
together, from any browser; never by CPF/CNPJ alone. Signup and e-mail
changes are confirmed by an e-mailed code; password recovery by a link.
- Unfinished carts (including File blobs) recover from IndexedDB for 24 hours in
the same browser, scoped to the guest/account identity. Recovered items can be
removed/replaced or joined by new items; in-place reconstruction of the artwork
editor and cross-device cart synchronization are not implemented. Browser
storage capacity limits apply. Payment clears the saved cart. Logout revokes
the server session and clears local checkout metadata and saved File blobs
across open Site tabs.
- Operators manually upload and approve a complete final-file set, with one or
more files per order item. Queue entry requires active final files for every
item. Corrections invalidate the old set; customers submit corrections through
their portal, and operators reapprove final files. No artwork transformation,
automatic pre-flight, or machine control is performed.
- Every completed upload is quarantined pending a local ClamAV scan. Only `clean`
files can be quoted, commercially approved, paid, downloaded, attached as final
files, or admitted to the print queue. Rejected/error files remain blocked and
expire within three days. The isolated scanner uses signatures bundled in its
pinned image and has no external network route. The multipart transport could
carry 5 GiB, but API and customer admission stop at the effective 128 MiB
scan/release limit by default. Larger files require a new scan/release design.
This malware gate is not print pre-flight or artwork validation.
- A retention worker removes expired object bytes but keeps order/file metadata:
incomplete uploads after a one-hour reservation lease, originals within seven days of manual final
artwork approval, and attached final/correction files within 30 days of the
order's first upload. Storage lifecycle is also a 30-day backstop.
- Structured security events are written to logs and PostgreSQL. The local
`security_status` command summarizes authentication, rate-limit, scan, and
scanner/signature alerts without exposing secrets. Security regression tests,
exact-runtime Python dependency auditing, and Trivy image reports live under
`app/` and `output/security/`; open findings are documented in
`SECURITY_REPORT.md` and are not a production-readiness claim.
- All direct and transitive Python packages are pinned with artifact hashes in
`infra/requirements.lock`; the API image build requires those hashes. The lock
is regenerated in a disposable Python 3.12 container by
`infra/lock_dependencies.sh`. A fresh exact-runtime audit found no known Python
advisories on 2026-09-15; this does not cover OS/container findings.
- `compose.staging.yaml` is a separate, network-disabled readiness gate only. It
validates non-secret staging decisions and rejects placeholders, local endpoints,
fake providers, embedded secret settings, and unsafe secret sources. It does not
deploy the application, contain credentials, or contact any real provider.
- A separate production delivery package now exists under `deploy/`, with
non-root API/web image definitions, a single Portainer Docker Swarm stack,
external secret/volume contracts, health-monitored rolling updates,
commit-SHA rollback images, and one protected Gitea workflow under
`.gitea/workflows/`. The package never contains provider credentials and has
not been deployed. Its fail-closed preflight intentionally rejects the current
source until production adapters, Docker-secret file loading, approved inputs,
restore rehearsal, image scans, and human security approval are complete.
- `python3 -m ops.backup create-and-verify` creates a private, Git-ignored bundle
containing a PostgreSQL dump plus every complete, unexpired object already marked
`clean`. SHA-256 manifests protect both parts. Verification restores the database
under a UUID name and the object bytes under a UUID MinIO prefix, hashes the
restored bytes, then removes only those temporary targets. Active data is never
overwritten; pending, rejected, errored, expired, and purged objects are excluded.
Run this local snapshot while uploads and retention are idle. Scheduling, offsite
copies, and production restore operations remain unfinished.
- Real providers, production authentication hardening, email verification/recovery,
automatic final-file generation, production backup operations, and production
activation remain incomplete. Deployment plumbing exists but cannot pass its
release gate yet. No factory automation or pre-flight is added.
See `docs/historico/IMPLEMENTATION_REPORT.md` for verification, `PRODUCTION_INPUTS.md` for the
decisions and evidence required before staging or production connection, and
`PORTAINER.md` for the production delivery contract.
The client roadmap promises are unchanged, so its PDF source is not regenerated
for this local implementation checkpoint.
### Existing assets
- `web/`: the Site (`index.html`), the Kanban and customer portal pages, and
the scripts behind them. `web/site-*.js` holds the Site's behaviour.
- `docs/historico/`: the original specification, endpoint sketch, task plan and
status report. Background only — they describe a model this system does not
implement.
The prototypes they describe (`portal/`, `kanban/`, `agente/`, the root
`schema.sql` and `.env.exemplo`) were removed on 2026-09-21 once nothing
referenced them; recover from Git history if ever needed.
- `tools/generate_dtf_report.py`: generator for the client-facing roadmap PDF.
- `docs/roadmap-cliente.pdf`: the generated roadmap, as last sent.
- `docs/reuniao-2026-09-09-anotacoes.pdf`:
meeting notes that established the business direction. Treat it as context;
the latest decisions in this document define the active scope.
### Important gaps and stale assumptions
- The original Site had no backend payment, freight quote, order persistence,
authentication, purchase history, or real cart persistence. Local order
persistence, reviewed quotes, mock freight and fake payment now work through
`web/checkout.js`. The local customer portal now provides accounts and
order history; cart recovery is browser-local. Password recovery by e-mail
exists (see E-mail) but waits for the client's SMTP account; account e-mail
verification and cross-device cart editing are still absent.
- Without the local bridge, the original freight fallback remains a stub.
Real freight quotation remains unimplemented in all runtimes.
- The existing the removed prototypes duplicated WhatsApp senders and send
direct text messages. They are not production-ready notification modules.
- Older documentation and code describe a Tiny webhook creating an upload link,
a factory agent, local Kanban, FlexiPRINT automation, 90-day retention, and
12-month artwork reuse. Those are not the current MVP model.
## Documentation synchronization
`context.md` is the compact operating context for agents. The current
client-facing narrative, diagrams, and formatting live in
`docs/roadmap-cliente.pdf`, generated from `tools/generate_dtf_report.py`.
When a decision changes, update both the relevant implementation context here
and the roadmap source when it changes what the client-facing plan promises.
## Change-control rules for agents
- Preserve the current Site DTF commercial rules unless explicitly asked to
change them.
- Do not add factory-side automation, a local agent, hot folders, FlexiPRINT
control, machine dashboards, or a new post-MVP delivery commitment by
inference.
- Do not claim that R2 hosts or executes application services.
- Keep all customer-facing and internal documentation in English only when this
file is the requested artifact; otherwise follow the user's requested
language.
- When a requirement is unclear, distinguish between the MVP, a future
enhancement, and an existing prototype assumption before changing code.