# Bangladesh Tariff & Trade Intelligence Platform (BETA) — public-platform source package

**Copyright © 2026 Mohammed Mahraj ul Alam Samrat, Head of Trade Facilitation & Regulatory
Compliance, TRACE Consulting Ltd. All rights reserved.** See `LICENSE`. BETA release —
under professional review. The frontend, API and printable outputs carry the copyright
notice and governing disclaimer; keep both intact in any deployment.

Technical package for running the platform as a real public website: split static
frontend (the current BETA platform, verified functionally identical to the single-file
edition), PostgreSQL schema with seed data extracted from the platform, a FastAPI
backend (tariff API, duty-calculation service, IPO/SRO lookups, authenticated EN
access, US CBP CROSS server-side proxy), and Docker/nginx deployment.

## 0. What changed in the BETA refresh (2026-07-19)

- TRACE Consulting Ltd. branding: logo in the page header, rewritten footer
  (author, designation, company, prohibition notice), governing disclaimer in the
  footer, BETA badge; all visible version numbers removed.
- "User Guide & Validation" tab removed (consolidated into the interactive User
  Guide overlay); duplicate page-chrome disclaimer strip removed.
- **Tariff Policy Analysis methodological audit implemented (Option C):** module
  renamed *Simplified Tariff & Revenue Sensitivity Analysis*; all TRIST / WITS-SMART
  claims removed from labels, exports, guide and glossary; export renamed
  `Tariff_Scenario_Sensitivity_Results.xlsx` with a ReadMe sheet; the vacuous ERP
  formula replaced by a transparent Corden-style illustrative proxy (data-derived
  input-stage tariff, adjustable input share); custom elasticity and demand-price-basis
  options added; results relabelled as gross statutory border-tax liability with a
  collection-ratio KPI; methodology card and validation guards added. See
  `Tariff_Policy_Analysis_Methodological_Audit_and_Validation.md` (kept with the
  project files) for the full audit and eight-case validation report.

## 1. Repository layout

```
web/                    static frontend (deployable alone on any static host)
  index.html            platform shell (~0.5 MB; was 11.2 MB monolith; BETA branding)
  data/*.js             cacheable data packs: core tariff+REF (4.8 MB), SRO (0.4 MB),
                        IPO (0.15 MB), proofread EN edition (5.3 MB)
db/
  schema.sql            PostgreSQL 15+ DDL (pg_trgm search, users, audit, versioning)
  seed/*.json           clean JSON extracted from the platform (tariff 7,785 lines /
                        4 FYs, SRO 589, IPO 268, EN 1,236 headings + 97 chapters)
api/
  main.py               FastAPI: /api/tariff /api/search /api/calc /api/ipo /api/sro
                        /api/en (JWT-protected) /api/rulings/cross (proxy) /api/auth
  calc.py               duty engine (A–F valuation chain, configurable bases) —
                        verified against the reference example (AV 5,000 → 4,510)
  load_data.py          seeds PostgreSQL from db/seed
docker-compose.yml      db + api + nginx stack
nginx/nginx.conf        static serving, gzip, caching, /api reverse proxy, rate limit
```

## 2. Quick start (full stack)

```bash
export DB_PASSWORD=<strong-password> JWT_SECRET=<random-64-chars>
docker compose up -d --build
docker compose exec api python load_data.py /seed     # first run only
curl http://localhost/api/health                      # {"ok":true,"tariff_lines":7785}
```
Static-only deployment (no backend features): upload `web/` to Cloudflare Pages /
Netlify / any web server — the frontend is fully self-sufficient, as today.

## 3. API summary

| Endpoint | Auth | Purpose |
|---|---|---|
| GET /api/tariff/{code} | – | line, rates (all FYs), SRO refs, import stats |
| GET /api/search?q= | – | trigram search over BCT descriptions |
| POST /api/calc | – (logged) | duty computation; SRO rates applied only with `sro_confirmed:true`; statutory comparison returned |
| GET /api/ipo/{code}?description= | – | description-aware IPO provisions (Para 3(2) applicability: full/confirmed/possible/exempt) |
| GET /api/sro/{hs} | – | concessions/references for a line |
| GET /api/en/{heading} | **JWT** | Explanatory Note text (licensed content — never serve anonymously) |
| GET /api/rulings/cross?term= | – | server-side CROSS search proxy (solves the browser CORS limit); persuasive only |
| POST /api/auth/register · /api/auth/login | – | JWT issuance |

## 4. Production checklist

- TLS: terminate at Cloudflare (recommended) or mount certs in the nginx container.
- Set real `JWT_SECRET`, `DB_PASSWORD`, and `CORS_ORIGINS=https://yourdomain`.
- Backups: `pg_dump` nightly; the seed JSONs are the recovery baseline for content.
- Monitoring: `/api/health`; nginx access logs; `audit_log` / `calc_log` tables.
- Data updates each Finance Act / SRO / IPO change: update `db/seed`, re-run
  `load_data.py`, regenerate `web/data/*.js`, insert a row in `content_version`.
- The Japan / Singapore / India / NBR sources have no public search API — the
  frontend's official-site links (term on clipboard) remain the compliant approach;
  add per-source proxies only with written permission of the site owners.

## 5. Legal / licensing — read before going public

- **WCO Explanatory Notes are WCO-copyrighted.** In this package the EN pack is
  still present in `web/data/en_proof.js` (frontend) *and* behind JWT in the API.
  For a public site EITHER remove `en_proof.js` from `web/` and load EN via the
  authenticated API for licensed users only, OR obtain a WCO licence. Do not ship
  the EN pack anonymously to the open internet.
- IPO layer derives from an unofficial English translation with an abridged
  Appendix-1 Part A; rate data carries the platform's verification caveats. Keep the
  visible disclaimers ("decision-support only", "description prevails — Para 3(2)",
  "verify against the Bengali Gazette / official assessment") in any public build.
- The platform is not an official NBR/Government source; state this on the site.
