# vadymmarkov/fakery architecture

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

- Interactive diagram: https://gitdiagram.com/vadymmarkov/fakery
- Repository: https://github.com/vadymmarkov/fakery

## Overview

##### Project Type & Purpose
- This is a Swift library (framework) used to generate fake data.
- Its primary components are a set of data generators (for names, addresses, companies, etc.) plus supporting modules (configuration, data parsing, localization resources, etc.).
- The library supports multiple locales using JSON files in the Resources/Locales directory.

##### Main Components
- Fakery Core Library
– The primary component that the client instantiates (the Faker class found in Sources/Fakery/Faker.swift).
– It acts as the façade to access various generators.
- Configuration Module
– Represented by Config.swift: This module manages locale selection and configuration settings.
- Data Parsing & Providers
– Under Sources/Fakery/Data, modules like Parser.swift and Provider.swift handle loading and interpreting fake data from locale JSON files.
- Generators
– There’s a dedicated subdirectory (Sources/Fakery/Generators) for each category (Address, App, Business, Cat, Commerce, etc.). Each generator is a self-contained component within the library.
- Extensions
– Inside Sources/Fakery/Extensions: These provide helper methods (for array operations, string manipulation, etc.) that supplement the core functionality.
- Resources/Localization
– Located in Sources/Fakery/Resources/Locales: This directory contains the JSON locale files, which are a key part of Fakery’s functionality, as they drive the fake data selection based on locale.
- Testing Suite

##### Relationships and Interactions
- The client code (using the library via CocoaPods or Swift Package Manager) instantiates a Faker object.
- The Faker object then refers to the Configuration module to set the chosen locale.
- Based on that locale setting, the Data Parser loads the relevant JSON file from the Resources/Locales directory.
- The various Generators obtain necessary localized data via the Data Provider or directly through the Parser.
- Extensions provide support functions for data manipulation that all generators might use.
- Unit tests (located in Tests) are run against these modules to ensure that every generator works as expected.

##### Architectural Patterns and Design Principles
- Modularity: The library is clearly divided into modules (Generators, Data, Config, Extensions), making it easy to extend, test, and maintain.
- Separation of Concerns: Each generator deals only with one type or category of fake data.
- Dependency Inversion: The Faker class (as a façade) abstracts the complexity from the end user.
- Extensibility: The project’s design allows new generators or locales to be added without disrupting the existing architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        A["Client Application"]:::client
    end

    subgraph "Fakery Core Library"
        B["Faker Facade"]:::core
        C["Config Module"]:::core
        D["Data Parser"]:::core
        E["Data Provider"]:::core
        F["Extensions"]:::core
    end

    subgraph "Generators Module"
        G["Generators (e.g., Address, App, etc.)"]:::generator
    end

    subgraph "Localization Resources"
        H["Localization Resources (JSON Files)"]:::resource
    end

    subgraph "Quality Assurance"
        I["Testing Suite"]:::test
    end

    A -->|"instantiates"| B
    B -->|"calls"| C
    C -->|"selects locale"| D
    D -->|"loads data from"| H
    D -->|"parses data via"| E
    E -->|"supplies data to"| G
    G -->|"utilizes"| F

    I -.-> B
    I -.-> C
    I -.-> D
    I -.-> E
    I -.-> G

    click B "https://github.com/vadymmarkov/fakery/blob/master/Sources/Fakery/Faker.swift"
    click C "https://github.com/vadymmarkov/fakery/blob/master/Sources/Fakery/Config.swift"
    click D "https://github.com/vadymmarkov/fakery/blob/master/Sources/Fakery/Data/Parser.swift"
    click E "https://github.com/vadymmarkov/fakery/blob/master/Sources/Fakery/Data/Provider.swift"
    click G "https://github.com/vadymmarkov/fakery/tree/master/Sources/Fakery/Generators"
    click F "https://github.com/vadymmarkov/fakery/tree/master/Sources/Fakery/Extensions"
    click H "https://github.com/vadymmarkov/fakery/tree/master/Sources/Fakery/Resources/Locales"
    click I "https://github.com/vadymmarkov/fakery/tree/master/Tests"

    classDef client fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef core fill:#e6ffe6,stroke:#333,stroke-width:2px;
    classDef generator fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef resource fill:#ffd699,stroke:#333,stroke-width:2px;
    classDef test fill:#ffcccc,stroke:#333,stroke-width:2px;
```
