# lucasdoreac/investindo-2 architecture

> Architecture diagram of the GitHub repository lucasdoreac/investindo-2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lucasdoreac/investindo-2
- Repository: https://github.com/lucasdoreac/investindo-2

## Overview

##### Project type and purpose
- This is a React Native mobile application (built with Expo and TypeScript) whose purpose is to teach beginner investors about finance via:
- Interactive eBook content (markdown/JSON chapters).
- A glossary of terms.
- A profile questionnaire.
- Four financial simulators (compound interest, investment comparator, laddering strategy, portfolio builder).

##### File structure
- Top-level:
- app/ – file-based routing (Expo Router) with nested (tabs) and calculadora screens.
- components/ – reusable UI components and themed wrappers.
- assets/content/ – markdown and JSON content for chapters and examples.
- constants/, hooks/, scripts/ – theme constants, custom hooks, build scripts.
- __tests__/ – unit tests for each simulator.
- config: package.json, babel.config.js, tsconfig.json, eslint.config.js, jest/.

##### README for additional insights
- Core libraries: React Native, Expo, React Navigation (via Expo Router), mathjs (calculations), react-native-chart-kit (charts).
- No external backend – all content and computation live on the client.

a. Main components:
1. Mobile Device (iOS/Android)
2. Expo App Container
3. Navigation Layer (Tabs Navigator & Stack Navigator)
4. Feature Modules:
– Biblioteca Module (loads markdown/JSON from assets via EbookContent)
– Glossário Module (loads glossary entries)
– Perfil Module (questionnaire + saves profile to AsyncStorage)
– Simuladores Module:
- Juros Compostos
- Comparador de Investimentos
- Escada de Vencimentos
- Montador de Carteira
5. Shared Components & Services:
– UI Components (Collapsible, ParallaxScrollView, ThemedText/View, ExternalLink, IconSymbol)
– Calculation Engine (mathjs wrapper)
6. Data Sources:
– Local Assets (assets/content/*.md, .json; assets/images; fonts)
– AsyncStorage (user profile persistence)
7. Third-Party Libraries:
– Expo Router / React Navigation
– react-native-chart-kit
– mathjs

b. Relationships and data flows:
- User taps a tab → Navigation Layer routes to the appropriate Screen.
- Screen invokes shared services:
- Content Screens → read from assets folder via filesystem API (bundled).
- Simulator Screens → call calculation engine → return numerical results.
- Results passed to UI Components (charts, collapsible panels).
- Perfil Module stores/reads profile data in AsyncStorage.
- All screens themed via Theme & ColorScheme hooks.

c. Architectural patterns / design principles:
- Feature-based modularization: each major feature (biblioteca, simuladores, perfil, glossario) lives in its own screen subtree.
- Separation of concerns: UI components vs. business logic (calculations) vs. asset/content management.
- File-based routing courtesy of Expo Router for clear navigation mapping.
- Theming abstraction via custom hooks.

d. Key technologies/frameworks:
- Expo (app container, build/deploy)
- Expo Router / React Navigation (navigation)
- React Native + TypeScript (UI)
- mathjs (computation)
- react-native-chart-kit (visualization)
- AsyncStorage (persistence)

##### Detailed breakdown
- Expo App Container (top-level rectangle).
- Inside that, a “Navigation Layer” rectangle splitting into five branches (Tabs).
- Step 3: For each tab:
- Biblioteca → EbookContent & EnhancedEbookContent → Assets (chapters JSON/MD).
- Explore → (future/empty or search interface if any).
- Glossario → loads glossary terms via Content service.
- Perfil → Questionnaire flow → AsyncStorage.
- Simuladores → Stack or nested navigator → four calculator screens.
- Step 4: Show the Calculation Engine service (mathjs) connected to each simulator.
- Step 5: Show UI Components library consumed by all screens.
- Step 6: Show hook layer (useThemeColor, useColorScheme) feeding into UI Components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile Device"
        direction TB
        ExpoApp["Expo App Container"]:::container

        subgraph "Navigation Layer"
            direction TB
            Nav["Tabs & Stack Navigator"]:::navigation

            BibliotecaScreen["Biblioteca"]:::screen
            ExploreScreen["Explore"]:::screen
            GlossarioScreen["Glossário"]:::screen
            PerfilScreen["Perfil"]:::screen
            SimuladoresTab["Simuladores"]:::screen
        end

        ExpoApp --> Nav
        Nav --> BibliotecaScreen
        Nav --> ExploreScreen
        Nav --> GlossarioScreen
        Nav --> PerfilScreen
        Nav --> SimuladoresTab

        subgraph "Biblioteca Module"
            direction TB
            BibliotecaScreen --> EbookContent["EbookContent"]:::service
            BibliotecaScreen --> EnhancedEbookContent["EnhancedEbookContent"]:::service
            EbookContent --> AssetsContent["Assets Content"]:::data
            EnhancedEbookContent --> AssetsContent
        end

        subgraph "Explore Module"
            direction TB
            ExploreScreen --> FutureSearch["Future/Search Interface"]:::module
        end

        subgraph "Glossário Module"
            direction TB
            GlossarioScreen --> GlossarioContent["Glossário Content Loader"]:::service
            GlossarioContent --> AssetsContent
        end

        subgraph "Perfil Module"
            direction TB
            PerfilScreen --> Questionnaire["Questionnaire Flow"]:::module
            Questionnaire --> AsyncStorage["AsyncStorage"]:::data
        end

        subgraph "Simuladores Module"
            direction TB
            SimuladoresTab --> JurosCompostos["Juros Compostos"]:::screen
            SimuladoresTab --> ComparadorInvest["Comparador de Investimentos"]:::screen
            SimuladoresTab --> EscadaVenc["Escada de Vencimentos"]:::screen
            SimuladoresTab --> MontadorCarteira["Montador de Carteira"]:::screen

            JurosCompostos --> CalculationEngine["Calculation Engine"]:::service
            ComparadorInvest --> CalculationEngine
            EscadaVenc --> CalculationEngine
            MontadorCarteira --> CalculationEngine

            JurosCompostos --> ChartKit["react-native-chart-kit"]:::thirdparty
            ComparadorInvest --> ChartKit
            EscadaVenc --> ChartKit
            MontadorCarteira --> ChartKit
        end

        subgraph "Shared UI & Hooks"
            direction TB
            UIComponents["UI Components Library"]:::ui
            ThemeHooks["useThemeColor / useColorScheme"]:::hook
        end

        subgraph "Third-Party Libraries"
            direction TB
            ExpoRouter["Expo Router / React Navigation"]:::thirdparty
            MathJS["mathjs"]:::thirdparty
        end

    end

    %% Connections across modules
    Nav --> ExpoRouter
    CalculationEngine --> MathJS
    UIComponents --> BibliotecaScreen
    UIComponents --> ExploreScreen
    UIComponents --> GlossarioScreen
    UIComponents --> PerfilScreen
    UIComponents --> SimuladoresTab
    ThemeHooks --> UIComponents

    %% Click Events
    click Nav "https://github.com/lucasdoreac/investindo-2/blob/main/app/_layout.tsx"
    click Nav "https://github.com/lucasdoreac/investindo-2/blob/main/app/(tabs)/_layout.tsx"
    click BibliotecaScreen "https://github.com/lucasdoreac/investindo-2/blob/main/app/(tabs)/biblioteca.tsx"
    click EbookContent "https://github.com/lucasdoreac/investindo-2/blob/main/components/EbookContent.tsx"
    click EnhancedEbookContent "https://github.com/lucasdoreac/investindo-2/blob/main/components/EnhancedEbookContent.tsx"
    click AssetsContent "https://github.com/lucasdoreac/investindo-2/tree/main/assets/content/"
    click ExploreScreen "https://github.com/lucasdoreac/investindo-2/blob/main/app/(tabs)/explore.tsx"
    click GlossarioScreen "https://github.com/lucasdoreac/investindo-2/blob/main/app/(tabs)/glossario.tsx"
    click PerfilScreen "https://github.com/lucasdoreac/investindo-2/blob/main/app/(tabs)/perfil.tsx"
    click SimuladoresTab "https://github.com/lucasdoreac/investindo-2/blob/main/app/(tabs)/simuladores.tsx"
    click JurosCompostos "https://github.com/lucasdoreac/investindo-2/blob/main/app/calculadora/juros-compostos.tsx"
    click ComparadorInvest "https://github.com/lucasdoreac/investindo-2/blob/main/app/calculadora/comparador.tsx"
    click EscadaVenc "https://github.com/lucasdoreac/investindo-2/blob/main/app/calculadora/escada-vencimentos.tsx"
    click MontadorCarteira "https://github.com/lucasdoreac/investindo-2/blob/main/app/calculadora/montador-carteira.tsx"
    click UIComponents "https://github.com/lucasdoreac/investindo-2/tree/main/components/"
    click ThemeHooks "https://github.com/lucasdoreac/investindo-2/blob/main/hooks/useThemeColor.ts"
    click ThemeHooks "https://github.com/lucasdoreac/investindo-2/blob/main/hooks/useColorScheme.ts"
    click CalculationEngine "https://github.com/lucasdoreac/investindo-2/tree/main/__tests__/calculadoras/"
    click ExpoRouter "https://github.com/lucasdoreac/investindo-2/blob/main/package.json"
    click MathJS "https://github.com/lucasdoreac/investindo-2/blob/main/package.json"

    %% Styles
    classDef container fill:#f9f,stroke:#333,stroke-width:1px
    classDef navigation fill:#bbf,stroke:#333,stroke-width:1px
    classDef screen fill:#afa,stroke:#333,stroke-width:1px
    classDef service fill:#ffb,stroke:#333,stroke-width:1px
    classDef data fill:#fea,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef module fill:#ddf,stroke:#333,stroke-width:1px
    classDef ui fill:#bfb,stroke:#333,stroke-width:1px
    classDef hook fill:#fbf,stroke:#333,stroke-width:1px
    classDef thirdparty fill:#ffd,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
