# alassa50/urlalaplage architecture

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

- Interactive diagram: https://gitdiagram.com/alassa50/urlalaplage
- Repository: https://github.com/alassa50/urlalaplage

## Overview

##### Project type and purpose
- This is a modular, experimental Node.js API service for URL transformation.
- It demonstrates four URL-shortening techniques (youpi-prefix, compression, in-memory ID mapping, 4-char ID) plus logging and basic benchmarking.

##### File structure
- Top-level files:
- server.js: application entrypoint that wires Express, CORS, logging, routes.
- package.json / lock: dependency definitions.
- src/ directory:
- youpi.js + youpi.rest – modules and test definitions for “youpi” URL decorator.
- compress.js + compress.rest – compression-based URL shortener.
- memory.js + memory.rest – in-memory map based shortener.
- utils/logger.js + utils/mem-db.js – shared logging and a simple in-memory DB.
- data/db.db – a SQLite file used by one of the approaches (if implemented).
- benchmark/benchmark-run.js – run benchmarking with autocannon.

##### README for architectural insights
- The app is a single Express application exposing multiple endpoints.
- It uses middleware (CORS, body-parser, morgan/pino) and may swap storage backends.
- No external microservices—just optional file or in-memory stores.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Consumers
    Client["HTTP Client"]:::external
    Benchmark["Benchmark Tool"]:::external

    %% Express Server and Middleware
    subgraph "Express Server"
        direction TB
        Server["API Gateway / Express Server"]:::api
        Middleware["Middleware (CORS, body-parser, Logging)"]:::infra
        Server --> Middleware

        %% Youpi Module
        YoupiModule["Youpi URL Decorator Module"]:::logic
        YoupiTests["Youpi REST Test Definitions"]:::test
        Middleware --> YoupiModule
        YoupiModule --> YoupiTests

        %% Compression Module
        CompressModule["Compression-based Shortener Module"]:::logic
        CompressTests["Compression REST Test Definitions"]:::test
        Middleware --> CompressModule
        CompressModule --> CompressTests

        %% Memory Module
        MemoryModule["In-Memory ID Mapping Module"]:::logic
        MemoryTests["In-Memory REST Test Definitions"]:::test
        Middleware --> MemoryModule
        MemoryModule --> MemoryTests
    end

    %% Utilities / Shared Services
    subgraph "Utilities"
        direction TB
        Logger["Logger Utility"]:::util
        MemDB["Shared In-Memory Data Store"]:::util
    end

    %% Storage Backends
    subgraph "Storage Layer"
        direction TB
        SQLiteDB["Persistent SQLite Storage"]:::data
    end

    %% Connections among modules and utilities/storage
    YoupiModule --> Logger
    CompressModule --> Logger
    MemoryModule --> Logger

    MemoryModule --> MemDB
    CompressModule --> SQLiteDB

    %% External interactions
    Client -->|HTTP Requests| Server
    Benchmark -->|Performance Tests| Server

    %% Click Events
    click Server "https://github.com/alassa50/urlalaplage/blob/main/server.js"
    click YoupiModule "https://github.com/alassa50/urlalaplage/blob/main/src/youpi.js"
    click YoupiTests "https://github.com/alassa50/urlalaplage/blob/main/src/youpi.rest"
    click CompressModule "https://github.com/alassa50/urlalaplage/blob/main/src/compress.js"
    click CompressTests "https://github.com/alassa50/urlalaplage/blob/main/src/compress.rest"
    click MemoryModule "https://github.com/alassa50/urlalaplage/blob/main/src/memory.js"
    click MemoryTests "https://github.com/alassa50/urlalaplage/blob/main/src/memory.rest"
    click MemDB "https://github.com/alassa50/urlalaplage/blob/main/src/utils/mem-db.js"
    click Logger "https://github.com/alassa50/urlalaplage/blob/main/src/utils/logger.js"
    click SQLiteDB "https://github.com/alassa50/urlalaplage/blob/main/data/db.db"
    click Benchmark "https://github.com/alassa50/urlalaplage/blob/main/benchmark/benchmark-run.js"

    %% Styles
    classDef api fill:#D0E8FF,stroke:#0366D6,stroke-width:2px
    classDef infra fill:#E8F0FE,stroke:#91BFFF,stroke-width:1px
    classDef logic fill:#E6F4EA,stroke:#34A853,stroke-width:2px
    classDef data fill:#FFF4E5,stroke:#FB8C00,stroke-width:2px
    classDef util fill:#F0F0F0,stroke:#888888,stroke-width:1px
    classDef external fill:#F3E5F5,stroke:#9C27B0,stroke-width:2px
    classDef test fill:#FCE4EC,stroke:#EC407A,stroke-width:1px
```
