# sawlachintan/whoismyneta architecture

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

- Interactive diagram: https://gitdiagram.com/sawlachintan/whoismyneta
- Repository: https://github.com/sawlachintan/whoismyneta

## Overview

##### Main Components
- Client (Browser): Represents the end-user’s browser where the SvelteKit-generated UI is rendered.
- SvelteKit Application Server: The core server-side engine that handles routing, SSR (Server-Side Rendering), and serves Svelte components from the src/routes and src/lib directories.
- UI Components: A set of Svelte components (e.g., CandidateCard, Constituency, Header, Map, etc.) found in src/lib/components. Show these as a grouped UI “module” within the SvelteKit app.
- Data Layer: Static data files (JSON and GeoJSON) in the src/lib/data directory that power visualizations and content. Also mention external datasets (from MyNeta, PRS India, and the Lok Sabha shapefile) as integration points.
- Edge Functions (Netlify): Indicate the netlify/edge-functions directory (for example, geolocation.ts) that manages serverless functions at the network edge, perhaps for localized content or authentication purposes.
- Configuration and Deployment: Include representations for configuration files (svelte.config.js, tailwind.config.js, vite.config.js, etc.) and deployment settings (netlify.toml and associated Netlify directories) that govern the build and hosting environment.
- Internationalization: Use components like the messages directory and inlang configuration files indicating support for multiple languages.

##### Relationships and Interactions
- Inside the application, routing logic (under src/routes) loads various Svelte components (in src/lib/components) which in turn may consume static data (from src/lib/data) to render charts, maps, candidate details, etc.

##### Architectural Patterns and Design Principles
- Client-Server (SvelteKit SSR): Emphasize the separation between the client (browser UI) and SvelteKit backend logic.
- Component-Based UI: Highlight the modularity provided by Svelte components under src/lib/components.
- Static vs. Dynamic Content: Show how some content is served dynamically (via SSR/edge functions) while other content (the dataset JSON files) is static.
- Internationalization: Note that translation and localization files are part of the system (messages/ and inlang configuration).

- Clear labels for each of the components (Client Browser, SvelteKit Application, UI Components Group, Data Layer, Edge Functions, Deployment/Configuration).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Components
    Client_Browser["Client Browser"]:::client
    SvelteKit_App["SvelteKit Application Server"]:::server
    UI_Components["UI Components"]:::ui
    Data_Layer["Data Layer (Static Data)"]:::data
    Edge_Functions["Edge Functions (Netlify)"]:::edge

    %% External Data Sources
    External_MyNeta["MyNeta (External)"]:::external
    External_PRS["PRS India (External)"]:::external
    External_LS["Lok Sabha Shapefile (External)"]:::external

    %% Relationships between Main Components
    Client_Browser -->|"requests"| SvelteKit_App
    SvelteKit_App -->|"renders"| UI_Components
    SvelteKit_App -->|"fetches"| Data_Layer
    SvelteKit_App <-->|"edgeCalls"| Edge_Functions
    SvelteKit_App -->|"loadsTranslations"| Msg

    %% External Data relationships (dashed lines)
    Data_Layer ---|"refersTo"| External_MyNeta
    Data_Layer ---|"refersTo"| External_PRS
    Data_Layer ---|"refersTo"| External_LS

    %% Subgraph for Configuration & Deployment
    subgraph "Configuration & Deployment"
        Sconf["svelte.config.js"]:::config
        Tconf["tailwind.config.js"]:::config
        Vconf["vite.config.js"]:::config
        NetlifyToml["netlify.toml"]:::config
        Pkg["package.json/.npmrc"]:::config
    end
    SvelteKit_App -->|"buildConfig"| Sconf

    %% Subgraph for Internationalization
    subgraph "Internationalization"
        Msg["messages"]:::intl
        Inlang["project.inlang"]:::intl
    end

    %% Styles
    classDef client fill:#B3E5FC,stroke:#039BE5,stroke-width:2px;
    classDef server fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef ui fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef data fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef edge fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
    classDef config fill:#FFCC80,stroke:#F57C00,stroke-width:2px;
    classDef intl fill:#B2DFDB,stroke:#00796B,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#D32F2F,stroke-dasharray: 5 5,stroke-width:2px;

    %% Click Events
    click Client_Browser "https://github.com/sawlachintan/whoismyneta/blob/master/src/app.html"
    click SvelteKit_App "https://github.com/sawlachintan/whoismyneta/tree/master/src/routes"
    click UI_Components "https://github.com/sawlachintan/whoismyneta/tree/master/src/lib/components"
    click Data_Layer "https://github.com/sawlachintan/whoismyneta/tree/master/src/lib/data"
    click Edge_Functions "https://github.com/sawlachintan/whoismyneta/tree/master/netlify/edge-functions"
    click Sconf "https://github.com/sawlachintan/whoismyneta/blob/master/svelte.config.js"
    click Tconf "https://github.com/sawlachintan/whoismyneta/blob/master/tailwind.config.js"
    click Vconf "https://github.com/sawlachintan/whoismyneta/blob/master/vite.config.js"
    click NetlifyToml "https://github.com/sawlachintan/whoismyneta/blob/master/netlify.toml"
    click Pkg "https://github.com/sawlachintan/whoismyneta/blob/master/package.json/.npmrc"
    click Msg "https://github.com/sawlachintan/whoismyneta/tree/master/messages"
    click Inlang "https://github.com/sawlachintan/whoismyneta/blob/master/project.inlang"
```
