# datnguyennnx/point architecture

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

- Interactive diagram: https://gitdiagram.com/datnguyennnx/point
- Repository: https://github.com/datnguyennnx/point

## Overview

##### Project Type & Purpose
- The Point project is a local-first productivity toolkit – a client-side, privacy-focused web application built with modern web technologies.
- It comprises several productivity “tools” (Morse Code Translator, Todo Management, and Trip Planning) that operate entirely locally with offline functionality and local data storage (PgLite).

##### Analyzing the File Structure
- The file tree shows a clear separation of concerns:
- The src directory contains the application’s primary Svelte code, pages (routes), and components.
- Inside src/lib/app there are feature-specific subdirectories (morse, todos, trip) – each with its own components, utilities, and, where applicable, services.
- The src/lib/components holds common, reusable UI components built with shadcn-svelte.
- The database is abstracted under src/lib/database, handling local data persistence with Pglite.
- There are also top-level configuration files for design (like Vite configuration, Svelte config), linting, and testing.

##### Key Components
a. Frontend/UI Layer
- Svelte-based application with components organized by feature (Morse, Todos, Trip) and a shared UI library.
- Routes and layouts in the src/routes folder facilitate page navigation.
b. Feature-specific Modules
- Each productivity tool (Morse Translator, Todo Manager, Trip Planner) should be represented as a distinct module.
- Their internal component structure (e.g., components, utils, services) where applicable.
c. Local Data Storage
- PgLite (as referenced in the README) and include the database component from src/lib/database.
d. Supporting Modules
- Common UI Components: Illustrate the reusable UI elements (buttons, dialogs, file components, etc.) that support the various features.
- Utilities and Hooks: Capture the essential hooks and helper functions that facilitate responsiveness and device detection (e.g., is-mobile).

##### Relationships & Data Flow
- For example, the Todos module emits user actions (adding, filtering tasks) that trigger database writes/reads and update the UI.
- Similarly, the Trip planner has services (geocoding, rate-limiter, logger) that feed data into interactive components (Map, TextEditor) – represent the service dependency and data exchange.

##### Highlighting Architectural Patterns & Principles
- “local-first” design principle that enforces offline functionality; illustrate that all data is stored locally with PgLite.
- Separation of UI presentation (components) from business logic (services and utilities).

## Diagram (Mermaid)

```mermaid
graph TD
    A["User Interaction"]:::frontend

    subgraph "Frontend/UI Layer"
        UI1["Routes & Layouts"]:::frontend
        UI2["Svelte Components"]:::frontend
    end

    A --> UI1
    A --> UI2

    subgraph "Feature Modules"
        subgraph "Morse Module"
            Mdir["Morse Module (Dir)"]:::feature
            Mcomp["Morse Components"]:::feature
            Mutils["Morse Utils"]:::feature
            Mconst["Morse Constants"]:::feature
            Mdir --> Mcomp
            Mdir --> Mutils
            Mdir --> Mconst
        end

        subgraph "Todo Module"
            Tdir["Todo Module (Dir)"]:::feature
            Tcomp["Todo Components"]:::feature
            Tutils["Todo Utils"]:::feature
            Tdir --> Tcomp
            Tdir --> Tutils
        end

        subgraph "Trip Module"
            TRdir["Trip Module (Dir)"]:::feature
            TRcomp["Trip Components"]:::feature
            TRserv["Trip Services"]:::service
            TRplug["Trip Plugins"]:::feature
            TRutils["Trip Utils"]:::feature
            TRtypes["Trip Types"]:::feature
            TRdir --> TRcomp
            TRdir --> TRserv
            TRdir --> TRplug
            TRdir --> TRutils
            TRdir --> TRtypes
            TRserv -->|"Service_Call"| TRcomp
        end
    end

    UI1 -->|"User_Action"| Mdir
    UI1 -->|"User_Action"| Tdir
    UI1 -->|"User_Action"| TRdir

    Mcomp -->|"Data_Update"| D
    Tcomp -->|"Data_Update"| D
    TRcomp -->|"Data_Update"| D

    D["PgLite Database"]:::database

    UI2 -->|"UI_Support"| CUI
    CUI["Common UI Components"]:::common

    subgraph "Utilities & Hooks"
        Uglobal["Global Utils"]:::util
        Uhooks["Hooks"]:::util
    end

    UI2 -->|"Utility_Call"| Uglobal
    UI2 -->|"Utility_Call"| Uhooks

    click UI1 "https://github.com/datnguyennnx/point/tree/master/src/routes"
    click UI2 "https://github.com/datnguyennnx/point/blob/master/src/app.html"
    click Mdir "https://github.com/datnguyennnx/point/tree/master/src/lib/app/morse"
    click Mcomp "https://github.com/datnguyennnx/point/tree/master/src/lib/app/morse/components"
    click Mutils "https://github.com/datnguyennnx/point/blob/master/src/lib/app/morse/utils/morse.ts"
    click Mconst "https://github.com/datnguyennnx/point/blob/master/src/lib/app/morse/constants/morse.ts"
    click Tdir "https://github.com/datnguyennnx/point/tree/master/src/lib/app/todos"
    click Tcomp "https://github.com/datnguyennnx/point/tree/master/src/lib/app/todos/components"
    click Tutils "https://github.com/datnguyennnx/point/blob/master/src/lib/app/todos/utils/date.ts"
    click TRdir "https://github.com/datnguyennnx/point/tree/master/src/lib/app/trip"
    click TRcomp "https://github.com/datnguyennnx/point/tree/master/src/lib/app/trip/components"
    click TRserv "https://github.com/datnguyennnx/point/tree/master/src/lib/app/trip/services"
    click TRplug "https://github.com/datnguyennnx/point/blob/master/src/lib/app/trip/plugins/mention-plugin.ts"
    click TRutils "https://github.com/datnguyennnx/point/blob/master/src/lib/app/trip/utils/debounce.ts"
    click TRtypes "https://github.com/datnguyennnx/point/blob/master/src/lib/app/trip/types/types.ts"
    click D "https://github.com/datnguyennnx/point/tree/master/src/lib/database"
    click CUI "https://github.com/datnguyennnx/point/tree/master/src/lib/components"
    click Uglobal "https://github.com/datnguyennnx/point/blob/master/src/lib/utils.ts"
    click Uhooks "https://github.com/datnguyennnx/point/blob/master/src/lib/hooks/is-mobile.svelte.ts"

    classDef frontend fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef feature fill:#fce4ec,stroke:#880e4f,stroke-width:2px;
    classDef database fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px;
    classDef common fill:#f3e5f5,stroke:#4a148c,stroke-width:2px;
    classDef util fill:#fff3e0,stroke:#e65100,stroke-width:2px;
    classDef service fill:#e1f5fe,stroke:#01579b,stroke-width:2px;
```
