Skip to content

Flowchart — Módulo: arch

Gerado pelo Archaeologist (Reversa) em 2026-05-11


Fluxo: Inicialização do Banco de Dados

flowchart TD
    A([App inicializa]) --> B[Banco.getInstance]
    B --> C{database já aberto?}
    C -- Sim --> D([Retorna instância existente])
    C -- Não --> E{initializingPromise já existe?}
    E -- Sim --> F([Aguarda Promise em andamento])
    E -- Não --> G[initializingPromise = initialize]
    G --> H[AssetDatabasePreparator.prepare cantaIgreja.db]
    H --> I[op-sqlite moveAssetsDatabase → plataforma correta]
    I --> J[openAsync nome + caminho da plataforma]
    J --> K[MigrationsRepository.runMigrations]
    K --> L{Versão atual < versão da migration?}
    L -- Sim --> M[Executa SQL da migration]
    M --> N[Executa migration function se houver]
    N --> O[PRAGMA user_version = nova versão]
    O --> L
    L -- Não mais pendentes --> P[BibliotecaSugestoesRepertorioRepository.popularSugestoesIniciais]
    P --> Q([Banco pronto])

Fluxo: Estratégia de Plataforma

flowchart TD
    A([createPersistencePlatformStrategy]) --> B{Platform.OS}
    B -- ios --> C[IosPlatformStrategy]
    B -- android --> D[AndroidPlatformStrategy]
    B -- web --> E[WebPlatformStrategy]

    C --> C1[databasePath: IOS_LIBRARY_PATH]
    C --> C2[cachePath: Caches]
    D --> D1[databasePath: undefined padrão op-sqlite]
    D --> D2[cachePath: ../cache/]
    E --> E1[databasePath: undefined IndexedDB abstraction]
    E --> E2[cachePath: virtual]

Fluxo: Attach/Detach de Banco Externo

flowchart TD
    A([attachFromAssets banco alias]) --> B{Platform.OS}
    B -- native --> C[instancia.attach secondaryDbFileName + alias + location]
    B -- web --> D{Validação de segurança do alias}
    D --> E{/^[A-Za-z_][A-Za-z0-9_]*$/ matches?}
    E -- Não --> F([throw Error: alias inválido])
    E -- Sim --> G{Filename /^[A-Za-z0-9._-]+$/ matches?}
    G -- Não --> H([throw Error: filename inválido])
    G -- Sim --> I[ATTACH DATABASE escapado via replace ' por '']
    I --> J([Banco anexado como alias])

Pipeline de Migrations

flowchart LR
    A[PRAGMA user_version] --> B{Versão < 8?}
    B -- Sim --> C[v8: cria repertório + item_repertorio]
    C --> D{< 9?}
    D -- Sim --> E[v9: ADD musica.informacoes]
    E --> F{< 10?}
    F -- Sim --> G[v10: ADD repertorio.slug + data_edicao]
    G --> H{< 11?}
    H -- Sim --> I[v11: ADD musica.rotulos]
    I --> J{< 12?}
    J -- Sim --> K[v12: força re-download crc32]
    K --> L{< 13?}
    L -- Sim --> M[v13: cria sugestao_repertorio]
    M --> N{< 14?}
    N -- Sim --> O[v14: ADD repertorio.metadata]
    O --> P{< 15?}
    P -- Sim --> Q[v15: cria liturgia_cache]
    Q --> R([Versão atual: 15])

Arquitetura em Camadas

flowchart TB
    V([View: React Components]) --> S([Store: Redux + RTK Query])
    S --> Sv([Service: lógica de negócio])
    Sv --> R([Repository: acesso a dados])
    R --> DB[(SQLite — op-sqlite)]
    R --> KV[(MMKV — chave/valor)]
    R --> KC[(Keychain / localStorage)]
    R --> API([API REST — canta.app])

    A([arch/: utilitários transversais]) -.-> V
    A -.-> S
    A -.-> Sv
    A -.-> R