Arinex F&B
Dokumentasi database PostgreSQL lengkap untuk analisa, pembelajaran, maintenance, development backend, frontend/PWA, analytics, forecasting dan reusable client template.
1. Overview Project
Project ini merupakan fondasi Arinex Core untuk membangun software ERP yang dapat digunakan kembali untuk berbagai klien.
Tujuannya bukan membuat aplikasi sekali pakai untuk satu kedai, melainkan membuat core system yang dapat dijual dan dikustomisasi berulang.
bdbfbmmf_arinex_prototype_kedai_fnb
Nama konseptual:
arinex_Template_fnb
2. Setup Database
2.1 Membuat database
Pada shared hosting/cPanel, nama database biasanya mendapatkan prefix.
2.2 Masalah phpPgAdmin yang ditemukan
Akibatnya:
2.3 Test SQL editor
2.4 Standar migration
3. Architecture
Source of truth
- PostgreSQL = data utama.
- Flask = business logic.
- Frontend = presentation.
- Python = analytics/forecast.
4. Modules Database 01–15
| No. | Module | Fungsi |
|---|---|---|
| 01 | Organization | Company, branch, warehouse, storage location. |
| 02 | User & Access | Users, roles, permissions, employee, branch access. |
| 03 | Product Master | Produk, kategori, brand, unit, barcode. |
| 04 | Supplier | Supplier, contact, supplier products. |
| 05 | Inventory | Balance, lots, movement ledger. |
| 06 | Purchasing | PR → Approval → PO → GR. |
| 07 | Recipe / HPP | Recipe, production, ingredient cost. |
| 08 | Repack | ORI → RAW, conversion. |
| 09 | POS | Sales, payment, shift, return. |
| 10 | Control | Stock opname, expense, approval, audit. |
| 11 | Analytics | Summary, demand, forecast. |
| 12 | Pricing | Price list, promotion, voucher. |
| 13 | Finance | Accounting, journal, cash/bank. |
| 14 | ERP Control | Document number, reference, events, locks. |
| 15 | Core Template | Tenant, branding, feature modules, subscription. |
5. Table Catalog
Organization
| Table | Fungsi | Parent / Relasi |
|---|---|---|
companies
|
Root client/company. | Root. |
branches
|
Outlet. | companies. |
warehouses
|
Gudang. | branches. |
storage_locations
|
Rak/lokasi. | warehouses. |
User & Access
| Table | Fungsi |
|---|---|
users
|
Akun login. |
roles
|
Role. |
permissions
|
Hak akses. |
user_roles
|
User → role. |
role_permissions
|
Role → permission. |
user_branches
|
User → branch. |
departments
|
Departemen. |
positions
|
Jabatan. |
employees
|
Data employee. |
login_logs
|
Riwayat login. |
Product Master
| Table | Fungsi |
|---|---|
categories
|
Kategori produk. |
brands
|
Brand. |
units
|
Satuan. |
products
|
SKU, barcode, nama, harga, stock rule. |
product_units
|
Konversi unit. |
product_barcodes
|
Barcode. |
Supplier
| Table | Fungsi |
|---|---|
suppliers
|
Master supplier. |
supplier_contacts
|
Kontak supplier. |
supplier_products
|
Harga, MOQ, lead time. |
Inventory
| Table | Fungsi |
|---|---|
inventory_balances
|
Saldo stok terkini. |
inventory_lots
|
Batch, expiry, cost. |
inventory_movements
|
Ledger stok. |
Purchasing
| Table | Fungsi |
|---|---|
purchase_requisitions
|
Permintaan pembelian. |
purchase_requisition_items
|
Detail PR. |
purchase_orders
|
PO supplier. |
purchase_order_items
|
Detail PO. |
goods_receipts
|
Penerimaan barang. |
goods_receipt_items
|
Detail penerimaan. |
F&B
| Table | Fungsi |
|---|---|
recipes
|
Recipe version. |
recipe_items
|
Komposisi bahan. |
production_orders
|
Production batch. |
production_items
|
Detail konsumsi bahan. |
repack_orders
|
Header repack. |
repack_components
|
Input repack. |
repack_outputs
|
Output repack. |
repack_conversion_rules
|
Aturan konversi. |
POS
| Table | Fungsi |
|---|---|
payment_methods
|
Cash, QRIS, Transfer, Card, Voucher. |
customers
|
Customer/member. |
cashier_shifts
|
Shift kasir. |
cash_movements
|
Cash in/out. |
sales
|
Header transaksi. |
sale_items
|
Detail transaksi. |
sale_payments
|
Pembayaran. |
sale_returns
|
Retur. |
sale_return_items
|
Detail retur. |
customer_point_transactions
|
Point ledger. |
Control & Audit
| Table | Fungsi |
|---|---|
stock_opnames
|
Stock opname. |
stock_opname_items
|
Physical count. |
expense_categories
|
Kategori expense. |
expenses
|
Pengeluaran. |
approval_requests
|
Approval header. |
approval_steps
|
Approval level. |
audit_logs
|
Audit. |
system_notifications
|
Notifikasi. |
Analytics
| Table | Fungsi |
|---|---|
sales_daily_summary
|
Summary penjualan harian. |
product_demand_history
|
Demand history. |
forecast_models
|
Metadata model. |
forecast_results
|
Forecast. |
purchase_recommendations
|
Smart purchasing. |
store_daily_summary
|
KPI store. |
Pricing
| Table | Fungsi |
|---|---|
price_lists
|
Master price list. |
price_list_items
|
Harga produk. |
product_price_history
|
Histori harga. |
promotions
|
Promo. |
promotion_products
|
Produk promo. |
promotion_rules
|
Rule promo. |
vouchers
|
Voucher. |
voucher_transactions
|
Pemakaian voucher. |
promotion_transactions
|
Pemakaian promo. |
Finance
| Table | Fungsi |
|---|---|
accounting_periods
|
Periode accounting. |
chart_of_accounts
|
COA. |
journal_entries
|
Header jurnal. |
journal_entry_lines
|
Debit/kredit. |
cash_accounts
|
Kas/bank/e-wallet. |
cash_account_transactions
|
Cash/bank ledger. |
ERP Control
| Table | Fungsi |
|---|---|
document_number_configs
|
Nomor dokumen. |
document_number_logs
|
History nomor. |
system_settings
|
System settings. |
transaction_references
|
Relasi dokumen. |
erp_transaction_locks
|
Anti duplicate process. |
transaction_events
|
Event system. |
Core Template
| Table | Fungsi |
|---|---|
tenant_profiles
|
Profil client. |
tenant_branding
|
Branding client. |
feature_modules
|
Daftar fitur. |
company_modules
|
Feature flags. |
business_settings
|
Setting bisnis. |
tax_configs
|
Pajak. |
service_charge_configs
|
Service charge. |
receipt_configs
|
Printer/receipt. |
pos_configs
|
POS settings. |
service_plans
|
Plan layanan. |
company_subscriptions
|
Subscription client. |
6. RBAC
OWNER
Owner mempunyai akses penuh sesuai seluruh permission.
STAFF
Staff mengakses POS, Store Information, inventory operasional, purchasing tertentu, report dan analytics sesuai permission.
KASIR
Kasir difokuskan ke transaksi POS, shift dan cash movement.
7. Inventory Engine
inventory_balances
Menyimpan posisi stok saat ini berdasarkan product, warehouse dan location.
inventory_movements
Menyimpan histori setiap pergerakan. Inilah ledger stok.
Aturan utama
products.current_stock
sebagai source of truth.
Contoh histori
8. Purchasing
PR
Purchase Requisition adalah permintaan internal.
PO
Purchase Order adalah order ke supplier. PO tidak otomatis menambah stok.
Goods Receipt
Goods Receipt menjadi titik saat barang benar-benar diterima dan inventory dapat diposting.
Partial Receipt
9. F&B Recipe, HPP, Production & Repack
Contoh Recipe
100 Latte terjual
Repack
10. POS, Payment & Shift
Alur POS
Split payment
Return
11. Finance & Accounting
| Kode | Akun | Type | Normal |
|---|---|---|---|
| 1101 | Kas | ASSET | DEBIT |
| 1102 | Bank | ASSET | DEBIT |
| 1103 | QRIS / E-Wallet | ASSET | DEBIT |
| 1201 | Persediaan | ASSET | DEBIT |
| 2101 | Hutang Supplier | LIABILITY | CREDIT |
| 3101 | Modal | EQUITY | CREDIT |
| 4101 | Penjualan | REVENUE | CREDIT |
| 5101 | HPP | COGS | DEBIT |
| 6101+ | Expense | EXPENSE | DEBIT |
Contoh jurnal
12. Analytics & Forecasting
Input engine
- Sales history.
- Inventory balance.
- Inventory movement.
- Supplier lead time.
- MOQ.
- Promotion.
- Recipe.
- Operational calendar.
Baseline forecast
Purchase recommendation
13. Pricing, Promotion & Voucher
Price List
Promotion
Voucher
Voucher harus menyimpan:
- Code.
- Discount.
- Minimum transaction.
- Maximum discount.
- Usage limit.
- Validity period.
14. Approval, Audit & ERP Control
Approval
Audit
Audit log menyimpan:
- User.
- Action.
- Module.
- Reference.
- Old Data.
- New Data.
- IP.
- Timestamp.
Transaction reference
Transaction event
15. Arinex Core — Reusable Client Template
Yang dibuat sekali
- Authentication.
- RBAC.
- POS.
- Inventory.
- Purchasing.
- Recipe.
- Finance.
- Approval.
- Audit.
- Analytics.
- Forecasting.
Yang berubah per client
- Logo.
- Nama usaha.
- Warna.
- Theme.
- Menu.
- Feature module.
- Tax.
- Service charge.
- Receipt.
- Master data.
16. SQL Standard
CREATE TABLE
Foreign Key
Unique
Check Constraint
Index
Seed aman diulang
17. Error Handling & Troubleshooting
Error: syntax error at or near "CREATE"
Penyebab: editor phpPgAdmin membungkus multiple statement.
Error: No rows found
Belum tentu error.
Contoh view:
Jika belum ada recipe, hasilnya memang dapat kosong.
Error: relation does not exist
Error: Foreign Key
Pastikan parent row sudah ada.
Error: Duplicate Key
Error: Permission denied
Error: Flask 500
18. Maintenance
Backup
Restore
VACUUM
Database size
19. Security
- Password menggunakan hashing.
- Database credential menggunakan environment variables.
- Backend melakukan permission checking.
- SQL menggunakan parameterized query.
- Tenant isolation wajib diuji.
- Audit log tidak boleh mudah dimanipulasi.
- Production database user menggunakan privilege minimum yang diperlukan.
SQL Injection
20. Transaction Engine
21. Document Numbering
Contoh:
Histori nomor disimpan pada:
document_number_logs
22. Backend Flask Blueprint
Target folder
Prinsip service
- Route tipis.
- Business logic di service.
- Database access melalui repository/helper.
- Transaction dikontrol service.
- Permission selalu di backend.
23. Frontend / PWA
Client configuration
24. Development Flow A-Z
25. Testing Strategy
Database
- Duplicate SKU ditolak.
- Duplicate barcode ditolak.
- Invalid foreign key ditolak.
- Constraint diuji.
- Index diuji melalui query.
POS
Purchasing
26. Backup & Recovery
Backup
Restore
27. Production Checklist
| Area | Checklist |
|---|---|
| Database | Backup, restore, FK, unique, indexes. |
| Security | Secret aman, password hash, RBAC backend. |
| POS | Atomic transaction, rollback. |
| Inventory | Movement dan balance konsisten. |
| Purchasing | PR → Approval → PO → GR. |
| Accounting | Debit = Credit. |
| Tenant | Client isolation. |
| PWA | Offline & sync testing. |
| Forecast | Recommendation tidak langsung posting tanpa approval. |
28. SQL Maintenance Commands
Database
User
Schema
All Tables
Views
Columns
Foreign Keys
29. Final Blueprint
30. Roadmap
| Tahap | Pekerjaan | Tujuan |
|---|---|---|
| 1 | Schema Verification | Pastikan database aktual sesuai blueprint. |
| 2 | Flask Core | Auth, RBAC, tenant. |
| 3 | Master API | Product, supplier, customer. |
| 4 | Inventory Service | Movement/balance. |
| 5 | Purchasing Service | PR/PO/GR. |
| 6 | POS Service | Sales/payment/shift. |
| 7 | Accounting | Auto journal. |
| 8 | Frontend/PWA | Reusable UI. |
| 9 | Analytics | Dashboard KPI. |
| 10 | Forecasting | Demand prediction. |
| 11 | Purchase Recommendation | Smart procurement. |
| 12 | Deployment Template | Instalasi client baru. |
31. Status Project
| Area | Status |
|---|---|
| Organization | Selesai |
| User / Role / Permission | Selesai |
| Product | Selesai |
| Supplier | Selesai |
| Inventory | Selesai |
| Purchasing | Selesai |
| Recipe / HPP | Selesai |
| Repack | Selesai |
| POS | Selesai |
| Analytics | Selesai |
| Finance | Selesai |
| ERP Control | Selesai |
| Core Template | Selesai |
| Flask Backend | Berikutnya |
| Frontend / PWA | Berikutnya |
| Python Forecasting | Berikutnya |