erDiagram users { bigint id PK character_varying name character_varying email UK timestamp email_verified_at character_varying password character_varying remember_token timestamp created_at timestamp updated_at text two_factor_secret text two_factor_recovery_codes timestamp two_factor_confirmed_at } password_reset_tokens { character_varying email PK character_varying token timestamp created_at } sessions { character_varying id PK bigint user_id character_varying ip_address text user_agent text payload integer last_activity } cache { character_varying key PK text value bigint expiration } cache_locks { character_varying key PK character_varying owner bigint expiration } jobs { bigint id PK character_varying queue text payload smallint attempts integer reserved_at integer available_at integer created_at } job_batches { character_varying id PK character_varying name integer total_jobs integer pending_jobs integer failed_jobs text failed_job_ids text options integer cancelled_at integer created_at integer finished_at } failed_jobs { bigint id PK character_varying uuid UK character_varying connection character_varying queue text payload text exception timestamp failed_at } passkeys { bigint id PK bigint user_id FK character_varying name character_varying credential_id UK json credential timestamp last_used_at timestamp created_at timestamp updated_at } sectors { bigint id PK character_varying name character_varying slug UK character_varying short_description text description character_varying icon integer sort_order boolean is_active timestamp published_at timestamp created_at timestamp updated_at timestamp deleted_at } opportunities { bigint id PK bigint sector_id FK character_varying reference UK character_varying title character_varying slug UK character_varying summary text description character_varying province character_varying district character_varying promoter_name character_varying promoter_type smallint maturity_level character_varying maturity_label numeric estimated_investment_amount character_varying estimated_investment_currency character_varying financing_modality text expected_impact character_varying status boolean is_featured timestamp published_at timestamp last_validated_at timestamp created_at timestamp updated_at timestamp deleted_at } interest_requests { bigint id PK bigint opportunity_id FK character_varying reference UK character_varying full_name character_varying email character_varying phone character_varying investor_type character_varying country character_varying sector_interest character_varying opportunity_reference character_varying investment_range text message boolean privacy_consent timestamp consented_at character_varying status character_varying source_page inet ip_address text user_agent json metadata timestamp reviewed_at bigint reviewed_by FK timestamp created_at timestamp updated_at timestamp deleted_at } organizations { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at text name text organization_type } memberships { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at bigint user_id FK uuid organization_id FK text role } consents { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at bigint user_id FK text subject_ref text purpose text status timestamptz granted_at timestamptz withdrawn_at } documents { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at text file_name text media_type text storage_key UK char sha256 text status } geo_locations { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at text name text location_type uuid parent_id FK text code } geo_geometries { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid geo_location_id FK text geometry_type geometry geom jsonb properties } projects { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at text code text name text status text description numeric budget_amount char budget_currency date start_date date end_date jsonb metadata } project_locations { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid project_id FK uuid geo_location_id FK text role } economic_clusters { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at text code text name text sector text status jsonb metadata } value_chains { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid cluster_id FK text code text name text stage } value_chain_links { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid from_value_chain_id FK uuid to_value_chain_id FK text link_type } cluster_projects { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid cluster_id FK uuid project_id FK text role } anchor_project_links { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid anchor_project_id FK uuid cluster_id FK text rationale } complementary_project_links { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid anchor_project_id FK uuid complementary_project_id FK text relation_type } development_corridors { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at text code text name text status text description } corridor_locations { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid corridor_id FK uuid geo_location_id FK integer sequence_no } corridor_projects { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid corridor_id FK uuid project_id FK } corridor_clusters { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid corridor_id FK uuid cluster_id FK } investors { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid organization_id FK text legal_name text investor_type text status } contacts { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at text full_name text email text phone } investor_contacts { uuid investor_id PK,FK uuid contact_id PK,FK boolean is_primary timestamptz created_at timestamptz updated_at } leads { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid investor_id FK bigint owner_user_id FK text title text status numeric estimated_amount char currency } crm_opportunities { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid lead_id FK uuid project_id FK bigint owner_user_id FK text stage numeric amount char currency numeric probability } activities { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid investor_id FK uuid opportunity_id FK bigint actor_user_id FK text activity_type timestamptz occurred_at text summary } tasks { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at bigint assignee_user_id FK uuid opportunity_id FK text title text status timestamptz due_at } investor_journeys { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid investor_id FK uuid opportunity_id FK text status timestamptz started_at } journey_steps { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid journey_id FK text step_code integer sequence_no text status } submissions { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid journey_step_id FK bigint submitted_by FK text status jsonb payload timestamptz submitted_at } aftercare_plans { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid investor_id FK uuid project_id FK bigint owner_user_id FK text status date review_date } constraints { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid aftercare_plan_id FK text category text description text severity text status } escalations { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid constraint_id FK bigint escalated_by FK text level text status timestamptz escalated_at } skills { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at text code text name } occupations { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at text code text name } training_needs { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid project_id FK uuid occupation_id FK uuid skill_id FK integer quantity text priority } training_providers { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid organization_id FK text name text status } courses { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid provider_id FK text code text title text status } education_opportunities { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid course_id FK uuid geo_location_id FK date start_date date end_date integer capacity text status } project_documents { uuid project_id PK,FK uuid document_id PK,FK timestamptz created_at } investor_documents { uuid investor_id PK,FK uuid document_id PK,FK timestamptz created_at } journey_documents { uuid journey_id PK,FK uuid document_id PK,FK timestamptz created_at } aftercare_documents { uuid aftercare_plan_id PK,FK uuid document_id PK,FK timestamptz created_at } education_documents { uuid education_opportunity_id PK,FK uuid document_id PK,FK timestamptz created_at } audit_events { uuid id PK text source_system text external_id text data_classification uuid correlation_id timestamptz created_at bigint actor_user_id FK text entity_type uuid entity_id text action timestamptz occurred_at jsonb before_data jsonb after_data } outbox_events { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at text aggregate_type uuid aggregate_id text event_type jsonb payload text status timestamptz available_at timestamptz published_at } inbox_events { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at text message_id UK text event_type jsonb payload text status timestamptz received_at timestamptz processed_at } sync_runs { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at text integration_name text direction text status timestamptz started_at timestamptz ended_at jsonb totals } reconciliation_issues { uuid id PK text source_system text external_id integer version_no text data_classification uuid correlation_id timestamptz created_at timestamptz updated_at timestamptz deleted_at uuid sync_run_id FK text entity_type text external_id_ref text issue_type text severity text status jsonb details } users || --o{ passkeys : user_id sectors || --o{ opportunities : sector_id opportunities |o --o{ interest_requests : opportunity_id users |o --o{ interest_requests : reviewed_by users || --o{ memberships : user_id organizations || --o{ memberships : organization_id users |o --o{ consents : user_id geo_locations |o --o{ geo_locations : parent_id geo_locations || --o{ geo_geometries : geo_location_id projects || --o{ project_locations : project_id geo_locations || --o{ project_locations : geo_location_id economic_clusters || --o{ value_chains : cluster_id value_chains || --o{ value_chain_links : from_value_chain_id value_chains || --o{ value_chain_links : to_value_chain_id economic_clusters || --o{ cluster_projects : cluster_id projects || --o{ cluster_projects : project_id projects || --o{ anchor_project_links : anchor_project_id economic_clusters || --o{ anchor_project_links : cluster_id projects || --o{ complementary_project_links : anchor_project_id projects || --o{ complementary_project_links : complementary_project_id development_corridors || --o{ corridor_locations : corridor_id geo_locations || --o{ corridor_locations : geo_location_id development_corridors || --o{ corridor_projects : corridor_id projects || --o{ corridor_projects : project_id development_corridors || --o{ corridor_clusters : corridor_id economic_clusters || --o{ corridor_clusters : cluster_id organizations |o --o{ investors : organization_id investors || --o{ investor_contacts : investor_id contacts || --o{ investor_contacts : contact_id investors |o --o{ leads : investor_id users |o --o{ leads : owner_user_id leads |o --o{ crm_opportunities : lead_id projects |o --o{ crm_opportunities : project_id users |o --o{ crm_opportunities : owner_user_id investors |o --o{ activities : investor_id crm_opportunities |o --o{ activities : opportunity_id users |o --o{ activities : actor_user_id users |o --o{ tasks : assignee_user_id crm_opportunities |o --o{ tasks : opportunity_id investors || --o{ investor_journeys : investor_id crm_opportunities |o --o{ investor_journeys : opportunity_id investor_journeys || --o{ journey_steps : journey_id journey_steps || --o{ submissions : journey_step_id users |o --o{ submissions : submitted_by investors || --o{ aftercare_plans : investor_id projects |o --o{ aftercare_plans : project_id users |o --o{ aftercare_plans : owner_user_id aftercare_plans || --o{ constraints : aftercare_plan_id constraints || --o{ escalations : constraint_id users |o --o{ escalations : escalated_by projects |o --o{ training_needs : project_id occupations |o --o{ training_needs : occupation_id skills |o --o{ training_needs : skill_id organizations |o --o{ training_providers : organization_id training_providers || --o{ courses : provider_id courses || --o{ education_opportunities : course_id geo_locations |o --o{ education_opportunities : geo_location_id projects || --o{ project_documents : project_id documents || --o{ project_documents : document_id investors || --o{ investor_documents : investor_id documents || --o{ investor_documents : document_id investor_journeys || --o{ journey_documents : journey_id documents || --o{ journey_documents : document_id aftercare_plans || --o{ aftercare_documents : aftercare_plan_id documents || --o{ aftercare_documents : document_id education_opportunities || --o{ education_documents : education_opportunity_id documents || --o{ education_documents : document_id users |o --o{ audit_events : actor_user_id sync_runs || --o{ reconciliation_issues : sync_run_id