Merge pull request 'Remove unused PLAN.md' (#4) from cursor/remove-plan-md into main

This commit was merged in pull request #4.
This commit is contained in:
2026-10-01 18:27:46 +00:00

252
PLAN.md
View File

@@ -1,252 +0,0 @@
# Product Slip Printing App — Implementation Plan
## 1. Overview
Web app for printing variable data onto pre-printed ink canister labels.
Two users on the same LAN: one enters orders, another prints slips.
**Stack**: Django Ninja + SQLite + Docker (Gunicorn + Nginx)
---
## 2. Excel Analysis
File: `ETICHETTE PER INKS(دون خط 4 تایی).xlsx` — 5 sheets, one per product.
### Products Found
| Sheet | Code | Description | Default Net Weight |
|-------|------|-------------|--------------------|
| ICJ408 | ICJ/408 | DIGITAL INK RED BROWN | 5 kg |
| ICJ407 | ICJ/407 | DIGITAL INK RED BROWN | 5 kg |
| ICJ309 | ICJ/309 | DIGITAL INK CYAN | 10 kg |
| ICJ630 | ICJ/EH630 | DIGITAL INK BLACK | 5 kg |
| ICJ308 | ICJ/308 | DIGITAL INK BLUE | 20 kg |
### A4 Page Layout — 4 Slips per Page (2×2 Grid)
```
┌──────────────────────┬──────────────────────┐
│ SLIP 1 (Cols A-I) │ SLIP 2 (Cols K-S) │
│ Rows 9-39 │ Rows 9-39 │
├──────────────────────┼──────────────────────┤
│ SLIP 3 (Cols A-I) │ SLIP 4 (Cols K-S) │
│ Rows 53-83 │ Rows 53-83 │
└──────────────────────┴──────────────────────┘
```
### What We Print (4 variable fields only)
The physical labels come pre-printed with company info, product code,
description, and all fixed text. We only overprint these values:
| Field | Cell Position (Slip 1) | Example |
|-------|----------------------|---------|
| Batch# | C18 | 1028/26 |
| Date | G18 | 05/05/2026 |
| Net Weight | C20 | 20 |
| Next Control Date | F19 | 05/11/2026 |
Page: A4 portrait, ~1cm margins all sides, paperSize=9.
---
## 3. Architecture
```
LAN
├── Machine A (Data Entry) ──→ http://server/entry
├── Machine B (Printer) ──→ http://server/print
│
└── Server (Docker)
├── nginx:alpine (port 80) ──→ reverse proxy
└── python:3.12-slim (port 8000)
├── Django Ninja (API + Views)
├── Gunicorn (WSGI)
├── WhiteNoise (static files)
└── SQLite (/app/data/db.sqlite3)
```
**Framework Choice: Django Ninja** (over Flask and plain Django)
- Django ORM + built-in migrations + free admin panel
- FastAPI-style Pydantic schemas for clean API validation
- Auto-generated Swagger docs at `/api/docs`
- Less boilerplate than Flask+SQLAlchemy+Marshmallow
---
## 4. Database Schema
```sql
CREATE TABLE products (
id INTEGER PRIMARY KEY AUTOINCREMENT,
code TEXT NOT NULL UNIQUE,
description TEXT NOT NULL,
default_net_weight REAL DEFAULT 5.0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE orders (
id INTEGER PRIMARY KEY AUTOINCREMENT,
product_id INTEGER NOT NULL REFERENCES products(id),
batch_number TEXT NOT NULL,
production_date DATE NOT NULL,
next_control_date DATE NOT NULL,
net_weight REAL NOT NULL,
canister_count INTEGER NOT NULL,
pages_needed INTEGER NOT NULL,
status TEXT DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
printed_at TIMESTAMP NULL
);
```
---
## 5. API Endpoints (Django Ninja)
| Method | Endpoint | Purpose |
|--------|----------|---------|
| GET | `/` | Redirect to `/entry` |
| GET | `/entry` | Data entry panel |
| GET | `/print` | Print queue panel |
| GET | `/calibrate` | Calibration page |
| GET | `/api/products` | List products |
| POST | `/api/products` | Add new product |
| GET | `/api/orders` | List orders (?status=pending) |
| POST | `/api/orders` | Create order |
| PATCH | `/api/orders/{id}` | Update status |
| DELETE | `/api/orders/{id}` | Delete order |
| GET | `/print-page/{id}` | Printable slip page |
| GET | `/api/docs` | Auto Swagger UI |
| GET | `/admin/` | Django admin panel |
---
## 6. Frontend Panels
### Data Entry (`/entry`)
- Product dropdown (from catalog) + "Add New Product"
- Batch # input
- Date picker (default: today)
- Next control date (auto: date + 6 months, editable)
- Net weight (auto from product default, editable)
- Canister count → auto-calculates pages = ceil(count/4)
- Submit → adds to print queue
- Recent orders table with status
### Print Queue (`/print`)
- Pending orders list (auto-refreshes every 10s)
- Print button → opens printable page → browser print dialog
- Mark Done button
- Print history table
### Print Page (`/print-page/{id}`)
- CSS @media print with absolute positioning
- Only prints 4 variable values at exact positions
- Multiple pages if order needs > 1 page (4 slips/page)
### Calibration (`/calibrate`)
- Cross-hair markers at field positions
- Print on blank paper, overlay on pre-printed label to check alignment
---
## 7. i18n (English / Persian LTR)
| Key | English | Persian |
|-----|---------|---------|
| app_title | Product Slip Manager | مدیریت برچسب محصول |
| new_order | New Order | سفارش جدید |
| product | Product | محصول |
| batch_number | Batch # | شماره بچ |
| date | Date | تاریخ |
| next_control | Next Control Date | تاریخ کنترل بعدی |
| net_weight | Net Weight (kg) | وزن خالص (کیلوگرم) |
| canisters | Canisters | تعداد قوطی |
| pages_needed | Pages Needed | تعداد صفحات |
| add_to_queue | Add to Print Queue | افزودن به صف چاپ |
| print_queue | Print Queue | صف چاپ |
| pending | Pending | در انتظار |
| done | Done | انجام شده |
| print | Print | چاپ |
| mark_done | Mark as Done | تایید چاپ |
| cancel | Cancel | لغو |
Persian text direction: LTR (as requested).
---
## 8. UI Design
- **Theme**: Dark navy (#0f172a) with glassmorphism panels
- **Accent**: Blue gradient (#3b82f6 → #60a5fa)
- **Font**: Inter (Google Fonts), JetBrains Mono for data values
- **Effects**: backdrop-filter blur, smooth transitions, pulse on pending badges
- **Status colors**: amber=pending, green=done, red=cancelled
---
## 9. File Structure
```
product-slip/
├── docker-compose.yml ✅ created
├── Dockerfile ✅ created
├── nginx.conf ✅ created
├── requirements.txt ✅ created
├── manage.py ✅ created
├── .gitignore ✅ created
├── config/ ✅ created
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── slips/ ⬜ TODO
│ ├── __init__.py
│ ├── models.py
│ ├── admin.py
│ ├── schemas.py
│ ├── api.py
│ ├── views.py
│ ├── management/
│ │ └── commands/
│ │ └── seed_products.py
│ ├── templates/slips/
│ │ ├── base.html
│ │ ├── entry.html
│ │ ├── print.html
│ │ ├── print_page.html
│ │ └── calibrate.html
│ └── static/slips/
│ ├── css/style.css
│ └── js/
│ ├── i18n.js
│ ├── entry.js
│ └── print.js
└── data/ (Docker volume, gitignored)
```
---
## 10. Docker Stack
```yaml
services:
app: # Django + Gunicorn on port 8000
nginx: # Reverse proxy on port 80
volumes:
db_data: # SQLite persistence
```
Startup: migrate → seed products → gunicorn
---
## 11. Defaults & Assumptions
- Date format: DD/MM/YYYY (European, matching Excel)
- Products: pre-defined dropdown + "Add New" option
- Quantity: user enters canister count, app calculates pages = ceil(n/4)
- Net weight: auto-fills from product, editable per order
- Next control: auto-calculated as date + 6 months, editable