# pungrumpy/logixlysia architecture

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

- Interactive diagram: https://gitdiagram.com/pungrumpy/logixlysia
- Repository: https://github.com/pungrumpy/logixlysia

## Overview

##### Project Type and Purpose
- This is an open-source logging library (plugin) named **Logixlysia** for the **ElysiaJS** framework, accompanied by a documentation website built with Next.js (in the `website/` folder).
- The core library lives under `src/`, with submodules for extensions, helpers, interfaces, logger logic, and output transports. There is a comprehensive test suite under `__tests__/`. The `website/` directory is a standalone doc site.

##### Main Components
A. **Consumer Application (ElysiaJS)**
- Your user’s web or API server that installs `logixlysia` as a plugin via `.use(logixlysia(config))`.
B. **Logixlysia Core Library**
1. **Extensions** (`src/extensions`)
- Entry points (`start-server.ts`) to hook into Elysia lifecycle (e.g., show startup message).
2. **Helpers** (`src/helpers`)
3. **Interfaces** (`src/interfaces`)
4. **Logger** (`src/logger`)
- Core logging logic: building log messages, filtering, error handling.
5. **Output** (`src/output`)
- Transports: console, file, rotation management (`rotation-manager.ts`).
6. **Utils** (`src/utils`)
- Shared helpers (e.g., rotation logic).
C. **Configuration**
- User-supplied in the `logixlysia({ config: { … } })` call. Drives: formatting, transports, filters, rotation.
D. **File System**
- Writes rotated logs to disk; cleans up old files.
E. **Testing Suite** (`__tests__`)
- Tests organized by feature: extensions, logger, output, helpers.
F. **Documentation Website** (`website/`)
- Next.js 13 app with MDX-based docs, search API, UI components, layout, styles.

##### Relationships and Interactions
1. **App → Plugin**: Elysia app loads plugin with config.
2. **Plugin (Extensions)** attach to request/response pipelines.
3. On each HTTP request/response:
- **Helpers** gather metadata (method, path, status, timestamp, IP).
- **Logger** formats the message, applies filters.
- **Output** transports receive the formatted log:
- **Console transport** prints to stdout.
- **File transport** writes to disk; rotation manager handles size/time-based rotation and compression.
4. **Tests** invoke library functions in isolation to verify behavior.
5. **Website** is independent: it pulls from `website/content`, MDX components, and delivers docs via Next.js routes.

##### Architectural Patterns and Principles
- **Plugin/Middleware Architecture**: Clean separation between core (logger logic) and integration layer (Elysia extensions).
- **Strategy Pattern** for transports: console vs. file vs. rotation manager all implement a common interface.
- **Single Responsibility**: helpers for utilities, interfaces for types, logger for message construction, output for side-effects.
- **Configuration-Driven** behavior: flexibility via a unified config object.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Applications and External Systems
    ElysiaApp["Elysia Application"]:::external
    DocsWebsite["Documentation Website"]:::docs

    %% Main Plugin Entry
    Plugin["Logixlysia Plugin (src/index.ts)"]:::middleware

    %% Core Library
    subgraph "Logixlysia Core Library"
        Extensions["Extensions"]:::middleware
        Helpers["Helpers"]:::utility
        Interfaces["Interfaces"]:::utility
        Logger["Logger"]:::utility
        Output["Output"]:::utility
        Utils["Shared Utils"]:::utility
    end

    %% Output Transports Detail
    subgraph "Transports"
        ConsoleTransport["Console Transport"]:::utility
        FileTransport["File Transport"]:::utility
        RotationManager["Rotation Manager"]:::utility
        Disk["File System (Disk)"]:::external
    end

    %% Testing Suite
    TestSuite["Testing Suite"]:::tests

    %% Website Subcomponents
    subgraph "Website Components"
        NextJSApp["Next.js App"]:::docs
        MDXContent["MDX Content"]:::docs
        APIRoutes["Search API Routes"]:::docs
    end

    %% Main Flows
    ElysiaApp -->|"uses .use(logixlysia(config))"| Plugin
    Plugin --> Extensions
    Extensions --> Helpers
    Helpers --> Logger
    Logger --> Output
    Output --> ConsoleTransport
    Output --> FileTransport
    FileTransport --> RotationManager
    RotationManager --> Disk

    %% Testing interactions
    TestSuite --> Helpers
    TestSuite --> Logger
    TestSuite --> Output

    %% Documentation flow
    DocsWebsite --> MDXContent
    DocsWebsite --> NextJSApp
    NextJSApp --> APIRoutes

    %% Click Events
    click Plugin "https://github.com/pungrumpy/logixlysia/blob/main/src/index.ts"
    click Extensions "https://github.com/pungrumpy/logixlysia/tree/main/src/extensions"
    click Helpers "https://github.com/pungrumpy/logixlysia/tree/main/src/helpers"
    click Interfaces "https://github.com/pungrumpy/logixlysia/blob/main/src/interfaces/index.ts"
    click Logger "https://github.com/pungrumpy/logixlysia/tree/main/src/logger"
    click Output "https://github.com/pungrumpy/logixlysia/tree/main/src/output"
    click Utils "https://github.com/pungrumpy/logixlysia/blob/main/src/utils/rotation.ts"
    click TestSuite "https://github.com/pungrumpy/logixlysia/tree/main/__tests__"
    click DocsWebsite "https://github.com/pungrumpy/logixlysia/tree/main/website/"
    click NextJSApp "https://github.com/pungrumpy/logixlysia/tree/main/website/app"
    click MDXContent "https://github.com/pungrumpy/logixlysia/tree/main/website/content"
    click APIRoutes "https://github.com/pungrumpy/logixlysia/blob/main/website/app/api/search/route.ts"

    %% Styles
    classDef middleware fill:#D0E8FF,stroke:#005BBB,color:#000;
    classDef utility fill:#E6F4EA,stroke:#1E8449,color:#000;
    classDef external fill:#F2F2F2,stroke:#888888,color:#000;
    classDef tests fill:#FFF4E5,stroke:#D35400,color:#000;
    classDef docs fill:#F5E6FF,stroke:#8E44AD,color:#000;
```
