type
concept
created
Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
updated
Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
sources
raw/articles/DISCOVERIES, raw/articles/STATUS
tags
database postgresql credentials redis infrastructure

Database Credentials and Roles

abstract
The marketplace uses PostgreSQL (database: marketplace, user: marketplace) with uuid-ossp extension, Redis DB 1 for caching and Celery brokering, and a read-only morichal_source database containing legacy MorichalAI data.

PostgreSQL

Primary Database

Setting Value
Host localhost
Database marketplace
User marketplace
Extension uuid-ossp (for UUID primary key generation)

This database contains all 13 entity models across 9 Django apps. All tables use UUID4 primary keys via the TimestampedModel base class.

Legacy Source Database

Setting Value
Host localhost
Database morichal_source
Access Read-only
Purpose MorichalAI legacy data for migration

The morichal_source database was restored from downloaded_db.sql and contains the legacy MorichalAI records. The import_morichal management command reads from this database using psycopg 3.3.3 (not psycopg2) and writes to the primary marketplace database.

Database Credentials Location

The actual database password and connection string are stored in:

Redis

Setting Value
Host localhost
Port 6379 (default)
Database 1
Purpose Caching + Celery broker

Redis DB 1 is reserved for the marketplace. It serves dual purposes:

  1. Django cache backend -- caching frequently accessed data (freight rates, mill capabilities)
  2. Celery message broker -- queuing async tasks (ingestion processing, email polling, matching triggers)

Django Settings Pattern

Settings are split across four files in backend/config/settings/:

File Usage
base.py Shared settings (installed apps, middleware, database config)
dev.py Development overrides (DEBUG=True, console email backend)
testing.py Test overrides (faster password hashing, disabled caching)
prod.py Production overrides (security headers, SMTP email)

The active settings module is controlled by DJANGO_SETTINGS_MODULE, defaulting to config.settings.dev.

Entity Model Count

13 models across 9 apps, all with UUID PKs:

Model App Key Fields
CustomUser accounts email, role, is_active
Mill mills name, slug, country, region, paper_types, trust_score
Buyer buyers name, slug, company_type, country, credit_status
BuyerSpec buyers paper_type, gsm_min/max, width_min/max, priority
Product surplus paper_type, gsm, width_mm, mill (FK)
SurplusItem surplus product (FK), quantity_mt, price_per_mt, status (state machine)
VisibilityRule surplus mill (FK), rule_type, scope, scope_value
MatchResult matching surplus_item (FK), buyer (FK), overall_score
ContainerProposal containers buyer (FK), container_type, utilization_pct
Newsletter newsletters buyer (FK), status, trigger
IngestionBatch ingestion mill (FK), status, file_hash
ParserConfig ingestion mill (FK), column_mapping (JSON)
Transaction transactions buyer (FK), mill (FK), surplus_item (FK), payment_status

23 Centralized Enums

All domain enums live in backend/common/enums.py rather than per-app files: PaperType (11 types), QualityGrade, Incoterm (7), OnboardingStatus, FiberType, ProductForm, FluteType, Region (7), CompanyType, CreditStatus, NewsletterFrequency, SurplusSource (8), ContainerType, SurplusItemStatus (7 states), MatchType, MatchStatus, ContainerProposalStatus, IngestionStatus, NewsletterStatus, NewsletterTrigger, PaymentStatus, PaymentMethod, ShippingStatus, VisibilityRuleType, VisibilityScope.

Sources

Related