# tomaskukk/lounasta architecture

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

- Interactive diagram: https://gitdiagram.com/tomaskukk/lounasta
- Repository: https://github.com/tomaskukk/lounasta

## Overview

##### Main Components

A. Core Components:
- CLI Interface
- Location Services (Platform-specific)
- API Client
- Menu Filtering System

B. External Dependencies:
- Lounaat.info API
- Platform-specific Location Services
- macOS Native Location API
- IP-based Location Service (fallback)

**User Interface Layer**

**Platform Layer**

**Core Services Layer**

**External Services Layer**

##### Component Details and Relationships

A. User Interface Layer:
- CLI component (cli/cli.go) as the entry point
- It to the main application logic (main.go)

B. Platform Layer:
- Create two parallel tracks for location services:
1. Darwin (macOS) Track:
- Location_provider_darwin with its Objective-C components
- Info.plist configuration
2. Default Track:
- Location_provider_default for IP-based location

C. Core Services Layer:
- Location abstraction (location/location.go)
- API client (api/api.go)
- Utilities (utils/utils.go)

D. External Services Layer:
- Lounaat.info API
- Platform Location Services

##### Key Relationships to Highlight

- How the location provider interface (location_provider/location_provider.go) is implemented by both Darwin and Default providers
- Fallback mechanism from Darwin to Default location provider
- Demonstrate how the API client interacts with the external Lounaat.info service
- How the filtering system (name and food filters) integrates with the main flow

##### Specific Implementation Details

- The platform-specific nature of the location services
- The clean separation between the interface and implementation of location providers
- The filtering pipeline for restaurant and food name filters
- The error handling and fallback mechanisms

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI
        CLI["CLI Interface"]
        Main["Main Application"]
    end

    subgraph Platform
        subgraph Darwin
            DarwinLoc["Darwin Location Provider"]
            ObjC["Objective-C Components"]
            Plist["Info.plist"]
        end

        subgraph Default
            DefaultLoc["Default Location Provider"]
        end
    end

    subgraph Core
        LocationCore["Location Core"]
        LocationProvider["Location Provider Interface"]
        APIClient["API Client"]
        Utils["Utilities"]
    end

    subgraph External
        LounaatAPI["Lounaat.info API"]
        PlatformLocation["Platform Location Services"]
    end

    subgraph Build
        BuildScript["Build Script"]
        InstallScript["Install Script"]
    end

    %% Relationships
    CLI --> Main
    Main --> LocationCore
    Main --> APIClient
    
    LocationCore --> LocationProvider
    LocationProvider --> DarwinLoc
    LocationProvider --> DefaultLoc
    
    DarwinLoc --> ObjC
    ObjC --> Plist
    DarwinLoc --> PlatformLocation
    DefaultLoc -.-> PlatformLocation
    
    APIClient --> LounaatAPI
    Utils --> Main
    
    BuildScript --> InstallScript

    %% Click Events
    click CLI "https://github.com/tomaskukk/lounasta/blob/master/cli/cli.go"
    click Main "https://github.com/tomaskukk/lounasta/blob/master/main.go"
    click LocationCore "https://github.com/tomaskukk/lounasta/blob/master/location/location.go"
    click LocationProvider "https://github.com/tomaskukk/lounasta/blob/master/location/location_provider/location_provider.go"
    click DarwinLoc "https://github.com/tomaskukk/lounasta/blob/master/location/location_provider_darwin/location_provider_darwin.go"
    click ObjC "https://github.com/tomaskukk/lounasta/blob/master/location/location_provider_darwin/location_provider_darwin.m"
    click Plist "https://github.com/tomaskukk/lounasta/blob/master/location/location_provider_darwin/Info.plist"
    click DefaultLoc "https://github.com/tomaskukk/lounasta/blob/master/location/location_provider_default/location_provider_default.go"
    click APIClient "https://github.com/tomaskukk/lounasta/blob/master/api/api.go"
    click Utils "https://github.com/tomaskukk/lounasta/blob/master/utils/utils.go"
    click BuildScript "https://github.com/tomaskukk/lounasta/blob/master/build.sh"
    click InstallScript "https://github.com/tomaskukk/lounasta/blob/master/install.sh"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef external fill:#FFE5CC,stroke:#FF9933
    classDef core fill:#CCE5FF,stroke:#3399FF
    classDef platform fill:#E5FFCC,stroke:#66CC00
    classDef build fill:#E5E5E5,stroke:#666666

    class LounaatAPI,PlatformLocation external
    class LocationCore,LocationProvider,APIClient,Utils core
    class DarwinLoc,DefaultLoc,ObjC,Plist platform
    class BuildScript,InstallScript build

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Platform Components"]:::platform
        L3["External Services"]:::external
        L4["Build Tools"]:::build
    end
```
