@startuml
title After: Schema-Aware Auth Table Resolution (default public)
skinparam backgroundColor #FAFAFA
skinparam componentStyle rectangle
skinparam defaultFontName Consolas

package "Config" #E8FFF0 {
  component "config.yaml\nmultitenancy.schema_mapping.__schema__\n(default: public)" as cfg
  component "tenant override\ntenants.<id>.schema_mapping.__schema__" as tenantCfg
}

package "Server Runtime" #E8F1FF {
  component "ParsedMultiTenancyConfig\n+ default_auth_schema" as parsed
  component "TenantDatabaseRuntimeConfig\n+ auth_schema" as tenantParsed
  component "build_sqlx_adapter(search_path, auth_schema)" as build
  component "SqlxAdapter\n(auth_schema + table_ref())" as adapter
}

package "SQL Execution" #FFF4E6 {
  component "Auth meta queries\nFROM \"schema\".\"users\"" as meta
  component "Internal queries\nFROM \"schema\".\"ip_profiles\" etc" as internal
}

database "PostgreSQL" as db

cfg --> parsed : resolve default __schema__
tenantCfg --> tenantParsed : optional override
parsed --> tenantParsed : fallback auth schema
tenantParsed --> build : tenant runtime
build --> adapter : from_pool_with_schema(...)
adapter --> meta : schema-qualified table_ref()
adapter --> internal : same table_ref() path
meta --> db
internal --> db

note bottom of adapter
All auth/internal table access goes through
schema-qualified resolution.
If __schema__ is absent, it falls back to public.
end note
@enduml
