# jnaraujo/teste-de-leiturabilidade architecture

> Architecture diagram of the GitHub repository jnaraujo/teste-de-leiturabilidade, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jnaraujo/teste-de-leiturabilidade
- Repository: https://github.com/jnaraujo/teste-de-leiturabilidade

## Overview

##### High-Level Architecture Overview

- Frontend Layer (Next.js App Router structure)
- API Layer (Next.js API routes)
- External Services Integration
- State Management Layer
- Core Business Logic Layer

##### Detailed Component Breakdown

Frontend Layer (Rectangle with nested components):
- Main Layout (`src/app/layout.tsx`)
- Editor Route (`src/app/(editor)`)
- Blog Route (`src/app/(main)/blog`)
- Word Counter Route (`src/app/(main)/contador-de-palavras`)

Core Features Layer (Hexagons):
- Text Analysis Engine (`src/libs/ReadingEase`)
- Reading Time Calculator (`src/utils/ReadingTime`)
- Text Import System (`src/libs/ImportExternalPage`)

State Management (Rounded Rectangle):
- Zustand Stores (`src/store/*`)
- Achievements Store
- Config Store
- Content Store
- Reading Store
- Stats Store

- Google Docs Service
- Notion Service
- Sentry Integration

- User input flow through the editor
- Text analysis processing path
- State updates and persistence
- API calls to external services
- Error reporting to Sentry

##### Implementation Details to Highlight

- Next.js App Router architecture
- Client-side vs Server-side components
- Text analysis algorithm implementation
- State management pattern
- External service integration points

**┌─────────────────────────────────────┐**
- Client Layer (UI/Components)        │
- ┤
- Business Logic Layer (Analysis)     │
- ┤
- State Management                    │
- ┤
- External Services & Integration     │
- ┘

##### Additional Notes

Annotations for:
- Performance optimization points (debouncing, caching)
- Security considerations
- Accessibility features
- Analytics integration points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#e1bee7,stroke:#8e24aa
    classDef core fill:#bbdefb,stroke:#1976d2
    classDef state fill:#ffe0b2,stroke:#f57c00
    classDef external fill:#c8e6c9,stroke:#388e3c
    classDef error fill:#ffcdd2,stroke:#d32f2f
    classDef api fill:#b2dfdb,stroke:#00796b

    %% Frontend Layer
    subgraph Frontend
        Layout["Main Layout"]
        EditorRoute["Editor Route"]
        BlogRoute["Blog Route"]
        WordCounter["Word Counter"]
        UILib["UI Components"]
        Theme["Theme System"]
        Editor["Editor Component"]
        TextHL["Text Analysis Highlighting"]
        Toolbar["Editor Toolbar"]
        BubbleMenu["Bubble Menu"]
    end

    %% Core Business Logic
    subgraph CoreLogic
        TextAnalysis["Text Analysis Engine"]
        ReadingTime["Reading Time Calculator"]
        TextImport["Text Import System"]
    end

    %% State Management
    subgraph StateManagement
        AchievementsStore["Achievements Store"]
        ConfigStore["Config Store"]
        ContentStore["Content Store"]
        ReadingStore["Reading Store"]
        StatsStore["Stats Store"]
    end

    %% External Services
    subgraph ExternalServices
        GoogleDocs["Google Docs Service"]
        Notion["Notion Service"]
        BlogService["Blog Service"]
        Sentry["Sentry Monitoring"]
    end

    %% API Layer
    subgraph APILayer
        BlogAPI["Blog API"]
        ExternalAPI["External Content API"]
    end

    %% Error Handling
    subgraph ErrorHandling
        ErrorBoundary["Global Error Boundary"]
        ErrorPage["Error Page"]
    end

    %% Relationships
    Layout --> EditorRoute
    Layout --> BlogRoute
    Layout --> WordCounter
    Editor --> TextHL
    Editor --> Toolbar
    Editor --> BubbleMenu
    EditorRoute --> Editor
    Editor --> TextAnalysis
    TextAnalysis --> ReadingTime
    Editor --> TextImport
    TextImport --> GoogleDocs
    TextImport --> Notion
    BlogRoute --> BlogService
    BlogService --> BlogAPI
    TextImport --> ExternalAPI
    ErrorBoundary --> Sentry
    ErrorPage --> Sentry

    %% State Management Connections
    Editor --> ContentStore
    TextAnalysis --> ReadingStore
    TextAnalysis --> StatsStore
    Editor --> ConfigStore
    TextAnalysis --> AchievementsStore

    %% Styling Classes
    class Layout,EditorRoute,BlogRoute,WordCounter,UILib,Theme,Editor,TextHL,Toolbar,BubbleMenu frontend
    class TextAnalysis,ReadingTime,TextImport core
    class AchievementsStore,ConfigStore,ContentStore,ReadingStore,StatsStore state
    class GoogleDocs,Notion,BlogService,Sentry external
    class ErrorBoundary,ErrorPage error
    class BlogAPI,ExternalAPI api

    %% Click Events
    click Layout "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/app/layout.tsx"
    click EditorRoute "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/app/(editor)/editor/page.tsx"
    click BlogRoute "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/app/(main)/blog/page.tsx"
    click WordCounter "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/app/(main)/contador-de-palavras/page.tsx"
    click TextAnalysis "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/libs/ReadingEase/index.ts"
    click ReadingTime "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/utils/ReadingTime/readingTime.ts"
    click TextImport "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/libs/ImportExternalPage.tsx"
    click AchievementsStore "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/store/achievementsStore.ts"
    click ConfigStore "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/store/configStore.ts"
    click ContentStore "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/store/contentStore.ts"
    click ReadingStore "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/store/readingStore.ts"
    click StatsStore "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/store/statsStore.ts"
    click GoogleDocs "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/services/GoogleDocsService.ts"
    click Notion "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/services/NotionService.ts"
    click BlogService "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/services/BlogService.tsx"
    click UILib "https://github.com/jnaraujo/teste-de-leiturabilidade/tree/main/src/components/ui"
    click Editor "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/components/Editor/index.tsx"
    click Theme "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/context/ThemeContext.tsx"
    click ErrorBoundary "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/app/global-error.jsx"
    click ErrorPage "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/pages/_error.jsx"
    click BlogAPI "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/pages/api/blog/posts.tsx"
    click ExternalAPI "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/pages/api/external/index.ts"
    click TextHL "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/components/Editor/TextAnalysisHL/textAnalysisHL.ts"
    click Toolbar "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/components/Editor/Toolbar/index.tsx"
    click BubbleMenu "https://github.com/jnaraujo/teste-de-leiturabilidade/blob/main/src/components/Editor/BubbleMenu/index.tsx"
```
