# kanaji2002/toraponapp architecture

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

- Interactive diagram: https://gitdiagram.com/kanaji2002/toraponapp
- Repository: https://github.com/kanaji2002/toraponapp

## Overview

##### Project type & purpose
- Type: Native Android mobile application (tablet-optimized).
- Purpose: Offline/online tourist guide for 栗林公園, displaying current location, points of interest (POIs), and rich multi-language content stored as JSON assets.

##### File structure & infer architecture
- app/
– src/main/java/com/example/myapplication/componentsPage1 → “Map” feature
– componentsPage2 → “Spot list” & “Spot detail” feature
– componentsPage5 → (presumably another feature like settings or “Toilet filter”)
– utils/LocationUtils.kt & MapUtils.kt → business-logic helpers
– assets/spot*_folder/*.json → data layer (hard-coded POI metadata)
– AndroidManifest.xml, activity_map.xml → platform entrypoints
- Build config: Gradle Kotlin DSL (build.gradle.kts), ProGuard rules, tests (androidTest / unitTest).

##### README for additional context
- No remote backend; all POI data is local JSON.
- Uses device GPS for “現在地” via Android Location APIs.
- Likely integrates Google Maps or MapView (given MapUtils and activity_map.xml).
- Navigation between features via Jetpack Compose “AppNavHost.kt” in each component package.

##### Main components
a. Presentation Layer (blue)
- Android OS / Framework
- MainActivity.kt → hosts Compose
- AppNavHost.kt (in each feature) → Navigation Component
- Composable screens (page1.kt, ScreenList.kt, ScreenDetail.kt)
- UI Theme (ui/theme)
b. Domain/Business Logic (green)
- LocationUtils.kt → wraps LocationManager
- MapUtils.kt → marker creation, coordinate mapping
c. Data Layer (yellow)
- assets/*.json → POI metadata, multilingual strings
- Local parsing service (e.g., kotlinx.serialization in code)
d. Infrastructure & External Services (gray/cloud)
- Google Maps SDK (MapView or Compose Maps)
- Android Location Service (GPS)
- Device Storage (assets folder)

##### Relationships & data flows
1. User taps Map feature → MainActivity → AppNavHost → MapScreen
2. MapScreen invokes LocationUtils → Android Location Service → returns GPS coords
3. MapScreen calls MapUtils to transform JSON POI data → Map SDK → renders markers
4. User taps marker → Compose event → ScreenDetail via Navigation → JSON data parsed again or cached
5. Styling applied via ui/theme
6. All data reads from local assets; no network calls

##### Architectural patterns & design principles
- Feature-based modularization: each page under componentsPageX
- Unidirectional data flow: Presentation → Domain → Data
- Single Activity with Compose Navigation
- Separation of Concerns: UI vs. business helpers vs. raw data

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        MainActivity["MainActivity.kt"]:::presentation
        MapModule["componentsPage1"]:::presentation
        MapNavHost["AppNavHost.kt"]:::presentation
        MapScreen["page1.kt (Map Screen)"]:::presentation
        SpotModule["componentsPage2"]:::presentation
        SpotNavHost["AppNavHost.kt"]:::presentation
        SpotListScreen["ScreenList.kt"]:::presentation
        SpotDetailScreen["ScreenDetail.kt"]:::presentation
        Comp5Module["componentsPage5"]:::presentation
        Comp5NavHost["AppNavHost.kt"]:::presentation
        Comp5ScreenList["ScreenList.kt"]:::presentation
        UITheme["ui/theme"]:::presentation
        ColorDef["Color.kt"]:::presentation
        ThemeSetup["Theme.kt"]:::presentation
        TypeDef["Type.kt"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        LocationUtils["LocationUtils.kt"]:::domain
        MapUtils["MapUtils.kt"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        JSONAssets["assets/spot*_folder (JSON)"]:::data
        FrameAssets["assets/FrameImg"]:::data
    end

    %% Infrastructure Layer
    subgraph "Infrastructure & External"
        direction TB
        AndroidManifest["AndroidManifest.xml"]:::infra
        ActivityMapLayout["activity_map.xml"]:::infra
        GoogleMapsSDK["Google Maps SDK"]:::infra
        AndroidLocationService["Android Location Service (GPS)"]:::infra
    end

    %% Flows
    MainActivity -->|"init NavHost"| MapNavHost
    MapNavHost -->|"navigate to MapScreen"| MapScreen
    MapScreen -->|"getLastKnownLocation()"| LocationUtils
    LocationUtils -->|"fetch coords"| AndroidLocationService
    MapScreen -->|"transform POI data"| MapUtils
    MapUtils -->|"read JSON"| JSONAssets
    MapUtils -->|"provide markers"| GoogleMapsSDK
    GoogleMapsSDK -->|"render map"| MapScreen

    MapScreen -->|"tap marker"| SpotNavHost
    SpotNavHost -->|"navigate to list"| SpotListScreen
    SpotListScreen -->|"select spot"| SpotDetailScreen
    SpotDetailScreen -->|"parse detail JSON"| JSONAssets

    MainActivity -->|"init NavHost"| Comp5NavHost
    Comp5NavHost -->|"navigate to list"| Comp5ScreenList

    UITheme --> ColorDef
    UITheme --> ThemeSetup
    UITheme --> TypeDef
    MapScreen --> UITheme
    SpotListScreen --> UITheme
    SpotDetailScreen --> UITheme
    Comp5ScreenList --> UITheme

    MainActivity -.-> AndroidManifest
    MapScreen -.-> ActivityMapLayout

    %% Click Events
    click MainActivity "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/MainActivity.kt"
    click MapModule "https://github.com/kanaji2002/toraponapp/tree/master/app/src/main/java/com/example/myapplication/componentsPage1"
    click MapNavHost "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/componentsPage1/AppNavHost.kt"
    click MapScreen "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/componentsPage1/page1.kt"
    click SpotModule "https://github.com/kanaji2002/toraponapp/tree/master/app/src/main/java/com/example/myapplication/componentsPage2"
    click SpotNavHost "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/componentsPage2/AppNavHost.kt"
    click SpotListScreen "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/componentsPage2/ScreenList.kt"
    click SpotDetailScreen "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/componentsPage2/ScreenDetail.kt"
    click Comp5Module "https://github.com/kanaji2002/toraponapp/tree/master/app/src/main/java/com/example/myapplication/componentsPage5"
    click Comp5NavHost "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/componentsPage5/AppNavHost.kt"
    click Comp5ScreenList "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/componentsPage5/ScreenList.kt"
    click UITheme "https://github.com/kanaji2002/toraponapp/tree/master/app/src/main/java/com/example/myapplication/ui/theme"
    click ColorDef "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/ui/theme/Color.kt"
    click ThemeSetup "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/ui/theme/Theme.kt"
    click TypeDef "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/ui/theme/Type.kt"
    click LocationUtils "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/utils/LocationUtils.kt"
    click MapUtils "https://github.com/kanaji2002/toraponapp/blob/master/app/src/main/java/com/example/myapplication/componentsPage1/MapUtils.kt"

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#0366D6,stroke-width:1px
    classDef domain fill:#D0F0C0,stroke:#3C763D,stroke-width:1px
    classDef data fill:#FFF4B8,stroke:#8A6D3B,stroke-width:1px
    classDef infra fill:#E8E8E8,stroke:#5A5A5A,stroke-width:1px
```
