# isaacgemal/wikitok architecture

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

- Interactive diagram: https://gitdiagram.com/isaacgemal/wikitok
- Repository: https://github.com/isaacgemal/wikitok

## Overview

##### Project’s Main Components
- UI Layer: The primary “frontend” folder contains your entire user interface.
- Components: From the /src/components folder, include major UI elements such as Article, ArticleList, LanguageSelector, and WikiCard.
- Assets & Styles: Note that CSS files (like heartAnimation.css, Article.css) and assets play a role in the visual presentation.
- State Management & Hooks: In the /src/contexts and /src/hooks directories, you have:
- LikedArticlesContext for state management (e.g., tracking user “likes”).
- useLocalization and useWikiArticles hooks for language support and data fetching.
- Application Shell: The main entry points (App.tsx and main.tsx) that initialize and configure the overall application.
- Build & Configuration Tools: Vite and Bun are used for bundling and running the development server, so include an optional block for build configuration.

##### Relationships and Interactions
- That App.tsx (or the main component) serves as the central hub.
- That the two hooks (useLocalization and useWikiArticles) are invoked within these components to drive behavior such as fetching random articles and changing languages.

##### Architectural Patterns and Design Principles
- Component-Based Architecture: Emphasize modularity by distinguishing between UI presentation (components), state management (contexts), and business logic (custom hooks).
- Separation of Concerns: Illustrate how UI components focus exclusively on rendering while hooks and contexts manage data-fetching and state.
- Progressive Enhancement: Note that the project supports PWA patterns (installable as a standalone app) even though it’s purely frontend.

##### Final Touches
- That all components, their interactions, and external dependencies are clearly annotated.
- Clarity: though the design is relatively simple without a backend, every component’s purpose should be instantly understandable.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Configuration subgraph
    subgraph "Build & Configuration"
        vite["Vite Config"]:::buildConf
        bun["Bun Lock"]:::buildConf
    end

    %% Assets & Styles subgraph
    subgraph "Assets & Styles"
        heart["Heart Animation CSS"]:::asset
        articleStyle["Article CSS"]:::asset
    end

    %% Application Entry and Shell
    main["main.tsx"]:::shell
    app["App.tsx"]:::shell

    %% State & Business Logic subgraph
    subgraph "State & Business Logic"
        liked["LikedArticlesContext"]:::stateLogic
        localization["useLocalization"]:::stateLogic
        wikiArticles["useWikiArticles"]:::stateLogic
    end

    %% UI Components subgraph
    subgraph "UI Components"
        articleList["ArticleList"]:::uiComp
        article["Article"]:::uiComp
        wikiCard["WikiCard"]:::uiComp
        langSelector["LanguageSelector"]:::uiComp
    end

    %% External Service
    wikiAPI["Wikipedia API"]:::external

    %% PWA Support marker
    pwa["PWA Support"]:::pwaStyle

    %% Flow Connections
    vite --> main
    bun --> main
    main --> app
    app --> liked
    liked --> articleList
    liked --> wikiCard
    liked --> langSelector
    liked --> article
    articleList --> wikiArticles
    wikiArticles --> wikiAPI
    langSelector --> localization
    app --> heart
    app --> articleStyle
    app --> pwa

    %% Styles
    classDef uiComp fill:#bbf,stroke:#333,stroke-width:2px;
    classDef stateLogic fill:#bfb,stroke:#333,stroke-width:2px,rx:5,ry:5;
    classDef external fill:#fbb,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
    classDef buildConf fill:#fdd,stroke:#333,stroke-width:2px;
    classDef shell fill:#ddf,stroke:#333,stroke-width:2px;
    classDef asset fill:#ffd,stroke:#333,stroke-width:2px;
    classDef pwaStyle fill:#cff,stroke:#333,stroke-width:2px,stroke-dasharray: 3 3;

    %% Click Events
    click main "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/main.tsx"
    click app "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/App.tsx"
    click liked "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/contexts/LikedArticlesContext.tsx"
    click localization "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/hooks/useLocalization.ts"
    click wikiArticles "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/hooks/useWikiArticles.ts"
    click articleList "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/components/ArticleList.tsx"
    click article "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/components/Article.tsx"
    click wikiCard "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/components/WikiCard.tsx"
    click langSelector "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/components/LanguageSelector.tsx"
    click heart "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/assets/heartAnimation.css"
    click articleStyle "https://github.com/isaacgemal/wikitok/blob/main/frontend/src/styles/Article.css"
    click vite "https://github.com/isaacgemal/wikitok/blob/main/frontend/vite.config.ts"
    click bun "https://github.com/isaacgemal/wikitok/blob/main/frontend/bun.lock"
```
