Data Model (Turso)
Data Model (Turso)
Barcode tables
barcodes (+ whitelist_barcodes, whitelists)
Company tables
boycott_companies, alternative_companies, boycott_levels
Category tables
company_categories, product_categories
Region tables
geographic_regions (+ junctions)
Relations
companies ↔ categories, alt ↔ regions, barcode ↔ company
Reports
boycott_reports, alternative_reports (+ junctions)
Scope: this document describes the Turso (libSQL) schema used by v3. Directus collection interfaces live in src/lib/dbs/directus/schema.ts.
This section lists the key tables and their relationships. Names reflect src/lib/dbs/schema/schema.ts.
Barcode Tables
barcodes: cached external enrichment results (barcode, product_name, brand_name, scan_count)whitelist_barcodes: curated barcode-to-whitelist mappingswhitelists: whitelist entries with parent_company_name for company matching
Common barcode columns
barcode(unique),product_name,brand_nameis_official(boolean),scan_countcreated_at,updated_at
Company Tables
boycott_companies: name, proof, level, is_bds, parent_company (FK → boycott_companies.id), countries, vote_countalternative_companies: name, countries, vote_countboycott_levels: label, description (lookup for boycott severity; FK fromboycott_companies.level)
Relations
- Barcodes → BoycottCompanies (optional)
- Barcodes → AlternativeCompanies (optional)
- BoycottCompanies ↔ AlternativeCompanies (many-to-many)
- Companies ↔ CompanyCategories (many-to-many)
- AlternativeCompanies ↔ GeographicRegions (many-to-many)
- Country filters support two inputs: ISO alpha-2 codes (
country=DE) or MCC/MNC pairs (code_type=mcc|mncand numeric country code). MCC/MNC values are translated to ISO codes viagetISOCountryCodebefore querying.
Category Tables
company_categories: canonical category list shared across companies and reports.product_categories: Google product-category taxonomy slices mapped (optionally) back tocompany_categories.- Junctions:
boycott_companies_company_categoriesalternative_companies_company_categoriesboycott_reports_company_categoriesalternative_reports_company_categories
Region Tables
geographic_regions: normalized region list (mirrors the Directus “regions” field).- Junctions:
alternative_companies_geographic_regionsboycott_reports_geographic_regionsalternative_reports_geographic_regions
Lookup Tables
reward_point_menu: action-to-points mappings for gamification.
Mermaid (Conceptual)
Directus Interfaces
- Used for syncing:
company,alternative_company,level,category,upc_barcode,whitelist,whitelist_barcode. - Definitions:
src/lib/dbs/directus/schema.ts.
DTO & Mapper References
- Boycott companies:
src/dto/company.dto.ts,src/mappers/company.mapper.ts - Alternative companies: same as above (shared DTO file)
Code references
- Schema:
src/lib/dbs/schema/schema.ts - Directus interfaces:
src/lib/dbs/directus/schema.ts