# bstk/okk-url-curto architecture

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

- Interactive diagram: https://gitdiagram.com/bstk/okk-url-curto
- Repository: https://github.com/bstk/okk-url-curto

## Overview

##### Main Components Identification
The system consists of multiple key components that should be represented:

a. Frontend Layer:
- Angular UI Application (okk-url-ui)
- Core components (header, footer)
- Home module with URL shortening interface

b. Backend Layer (Two Implementations):
- Spring Boot API (okk-url-spring)
- Quarkus API (okk-url-quarkus)
Both implementing:
- URL Resource endpoints
- Domain services
- Data repositories
- Cache management
- Exception handling

c. Infrastructure:
- Redis (for production caching)
- PostgreSQL (for production database)
- H2 (for local development)
- Local Cache (for development)

**[Client Browser] → [Angular Frontend (Port 4200)]**
- ↓
- Load Balancer (Optional)
- ↓
- [Backend API (Spring/Quarkus) (Port 8080)]
- ↓
- ┌────────┴────────┐
- ↓                 ↓
- [Redis Cache]    [PostgreSQL/H2]

##### Component Details

Frontend (Blue):
- Angular modules structure
- Main URL shortening interface
- Routing components

Backend (Green):
- Layered architecture:
- API Layer (UrlResource)
- Service Layer (UrlService)
- Data Layer (UrlRepository)
- Infrastructure Layer (Cache, Exception Handling)

Infrastructure (Gray):
- Dual cache strategy (Redis/Local)
- Database options (PostgreSQL/H2)
- Docker container boundaries

##### Environment-Specific Details

- Development environment (H2 + Local Cache)
- Production environment (PostgreSQL + Redis)

##### Additional Elements

Include:
- Component versions and ports
- Docker container boundaries
- Error handling flows
- Cache interaction patterns

##### Technical Details

- HTTP endpoints (/url and /{url_token})
- Status codes (302 vs 301 for redirects)
- Cache implementation details
- Database schema hints
- Security boundaries

Remember to:
- Use consistent styling
- Both development and production configurations
- Caching strategy differences
- Error handling flows
- Base62 encoding and QR code generation processes

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph Frontend["Frontend Layer"]
        UI["Angular UI Application"]:::frontend
        Core["Core Components"]:::frontend
        Home["Home Module"]:::frontend
        URLInterface["URL Interface"]:::frontend
    end

    subgraph Backend["Backend Layer"]
        direction TB
        LB["Load Balancer"]

        subgraph SpringAPI["Spring Boot API"]
            direction TB
            SpringResource["URL Resource"]:::spring
            SpringService["URL Service"]:::spring
            SpringRepo["URL Repository"]:::spring
        end

        subgraph QuarkusAPI["Quarkus API"]
            direction TB
            QuarkusResource["URL Resource"]:::quarkus
            QuarkusService["URL Service"]:::quarkus
            QuarkusRepo["URL Repository"]:::quarkus
        end

        subgraph Encoders["Encoding Services"]
            direction TB
            Base62["Base62 Encoder"]:::encoder
            QRCode["QR Code Generator"]:::encoder
        end

        ExceptionHandler["Global Exception Handler"]:::handler
    end

    subgraph Infrastructure["Infrastructure Layer"]
        direction TB
        subgraph Cache["Cache Layer"]
            Redis["Redis Cache"]:::cache
            LocalCache["Local Cache"]:::cache
        end

        subgraph Database["Database Layer"]
            Postgres["PostgreSQL"]:::db
            H2["H2 Database"]:::db
        end
    end

    %% Relationships
    Browser --> UI
    UI --> Core
    UI --> Home
    Home --> URLInterface
    URLInterface --> LB
    LB --> SpringAPI
    LB --> QuarkusAPI
    
    SpringResource --> SpringService
    SpringService --> SpringRepo
    SpringService --> Base62
    SpringService --> QRCode
    SpringRepo --> Postgres
    SpringRepo --> H2
    
    QuarkusResource --> QuarkusService
    QuarkusService --> QuarkusRepo
    QuarkusService --> Base62
    QuarkusService --> QRCode
    QuarkusRepo --> Postgres
    QuarkusRepo --> H2
    
    SpringService --> Redis
    SpringService --> LocalCache
    QuarkusService --> Redis
    QuarkusService --> LocalCache

    %% Click Events
    click UI "https://github.com/BSTK/okk-url-curto/tree/main/okk-url-ui/src/app"
    click Core "https://github.com/BSTK/okk-url-curto/tree/main/okk-url-ui/src/app/core"
    click Home "https://github.com/BSTK/okk-url-curto/tree/main/okk-url-ui/src/app/modules/home"
    click URLInterface "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-ui/src/app/modules/home/pages/home/home.component.ts"
    click QuarkusResource "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-quarkus/src/main/java/dev/bstk/okkurlcurtoquarkus/api/UrlResource.java"
    click QuarkusService "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-quarkus/src/main/java/dev/bstk/okkurlcurtoquarkus/domain/UrlService.java"
    click QuarkusRepo "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-quarkus/src/main/java/dev/bstk/okkurlcurtoquarkus/domain/data/UrlRepository.java"
    click SpringResource "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-spring/src/main/java/dev/bstk/okkurlcurtospring/okkurlspring/api/UrlResource.java"
    click SpringService "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-spring/src/main/java/dev/bstk/okkurlcurtospring/okkurlspring/domain/UrlService.java"
    click SpringRepo "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-spring/src/main/java/dev/bstk/okkurlcurtospring/okkurlspring/domain/data/UrlRepository.java"
    click Redis "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-quarkus/src/main/java/dev/bstk/okkurlcurtoquarkus/infra/cache/CacheRedis.java"
    click LocalCache "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-quarkus/src/main/java/dev/bstk/okkurlcurtoquarkus/infra/cache/CacheLocal.java"
    click Base62 "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-quarkus/src/main/java/dev/bstk/okkurlcurtoquarkus/domain/encoder/Base62.java"
    click QRCode "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-quarkus/src/main/java/dev/bstk/okkurlcurtoquarkus/domain/encoder/QrCode.java"
    click ExceptionHandler "https://github.com/BSTK/okk-url-curto/blob/main/okk-url-quarkus/src/main/java/dev/bstk/okkurlcurtoquarkus/infra/handlerexception/GlobalExceptionHandler.java"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef spring fill:#6DB33F,stroke:#4F872F,color:white
    classDef quarkus fill:#4695EB,stroke:#27567B,color:white
    classDef encoder fill:#FF9800,stroke:#F57C00,color:white
    classDef cache fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef db fill:#607D8B,stroke:#455A64,color:white
    classDef handler fill:#F44336,stroke:#D32F2F,color:white
```
