# guolau/landscape-learnr architecture

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

- Interactive diagram: https://gitdiagram.com/guolau/landscape-learnr
- Repository: https://github.com/guolau/landscape-learnr

## Overview

##### Main Components

a) Frontend Layer:
- Vue.js SPA components (in resources/js)
- Core pages (Home, Settings, Auth)
- Snippet management interface
- Tag management system
- Form components
- Inertia.js bridge (connecting frontend to backend)

b) Backend Layer:
- Laravel Controllers (Auth, Snippet, Tag, Settings)
- Services layer (SnippetService)
- Models layer (User, Snippet, Tag, Image, etc.)
- Policy handlers for authorization
- API routes and middleware

c) Database Layer:
- MySQL/PostgreSQL database
- Key tables: users, snippets, tags, images, settings
- Relationship tables (snippet_tag)

d) Storage System:
- File storage for images
- Cache storage
- Session storage

##### Component Relationships

**User Interface → Inertia.js → Laravel Controllers → Services → Models → Database**
- ↕
- Storage

##### Specific Implementation Details

a) Frontend Architecture:
- Vue.js components hierarchy
- Form handling components
- Page components structure
- Layout system

b) Backend Architecture:
- MVC pattern implementation
- Service layer pattern
- Policy-based authorization
- Request validation layer

##### Key Interactions to Highlight

a) Snippet Management Flow:
**Vue Form → SnippetController → SnippetService → Models → Database**
- ↕
- Image Storage

b) Tag Management Flow:
**Tag Components → TagController → Models → Database**

##### Technical Stack Indicators

- Laravel (Backend Framework)
- Vue.js (Frontend Framework)
- Inertia.js (Frontend-Backend Bridge)
- Database System
- Tailwind CSS (Styling)

##### Specific Architecture Notes

- Separation between admin and regular user flows
- Where the EnsureUserIsAdmin middleware is applied
- Demonstrate the relationship between snippets and tags
- How images and street view links attach to snippets

This system design should reflect the application's focus on providing quick reference information for GeoGuessr players while showing the technical implementation that makes this possible.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        VueApp["Vue.js SPA"]:::frontend
        Pages["Core Pages"]:::frontend
        SnippetUI["Snippet Management UI"]:::frontend
        TagUI["Tag Management UI"]:::frontend
        Settings["Settings Interface"]:::frontend
        AuthPages["Authentication Pages"]:::frontend
        FormComps["Form Components"]:::frontend
        Layout["Layout System"]:::frontend
    end

    subgraph Bridge
        Inertia["Inertia.js Bridge"]:::bridge
    end

    subgraph Backend
        subgraph Controllers
            SnipCtrl["Snippet Controller"]:::controller
            TagCtrl["Tag Controller"]:::controller
            SetCtrl["Settings Controller"]:::controller
            AuthCtrl["Auth Controller"]:::controller
        end

        subgraph Services
            SnipServ["Snippet Service"]:::service
        end

        subgraph Models
            SnipModel["Snippet Model"]:::model
            TagModel["Tag Model"]:::model
            UserModel["User Model"]:::model
            ImgModel["Image Model"]:::model
            SetModel["Settings Model"]:::model
        end

        subgraph Authorization
            AdminMW["Admin Middleware"]:::auth
            SnipPolicy["Snippet Policy"]:::auth
            TagPolicy["Tag Policy"]:::auth
        end
    end

    subgraph Storage
        FileStore["File Storage"]:::storage
        Cache["Cache Storage"]:::storage
        Session["Session Storage"]:::storage
    end

    subgraph Database
        Users[(Users)]:::db
        Snippets[(Snippets)]:::db
        Tags[(Tags)]:::db
        Images[(Images)]:::db
        Settings[(Settings)]:::db
    end

    %% Frontend Relationships
    VueApp --> Pages
    VueApp --> FormComps
    VueApp --> Layout
    Pages --> SnippetUI
    Pages --> TagUI
    Pages --> Settings
    Pages --> AuthPages

    %% Bridge Connections
    Pages --> Inertia
    Inertia --> Controllers

    %% Controller Relationships
    SnipCtrl --> SnipServ
    SnipCtrl --> AdminMW
    TagCtrl --> AdminMW
    SetCtrl --> AdminMW

    %% Service Relationships
    SnipServ --> SnipModel
    SnipServ --> FileStore

    %% Model Relationships
    SnipModel --> Snippets
    TagModel --> Tags
    UserModel --> Users
    ImgModel --> Images
    SetModel --> Settings

    %% Storage Relationships
    FileStore --> Images
    
    %% Click Events
    click VueApp "https://github.com/guolau/landscape-learnr/blob/main/resources/js/app.js"
    click Pages "https://github.com/guolau/landscape-learnr/tree/main/resources/js/pages/"
    click SnippetUI "https://github.com/guolau/landscape-learnr/tree/main/resources/js/pages/snippets/"
    click TagUI "https://github.com/guolau/landscape-learnr/tree/main/resources/js/pages/tags/"
    click Settings "https://github.com/guolau/landscape-learnr/blob/main/resources/js/pages/Settings.vue"
    click AuthPages "https://github.com/guolau/landscape-learnr/tree/main/resources/js/pages/auth/"
    click FormComps "https://github.com/guolau/landscape-learnr/tree/main/resources/js/components/form/"
    click Layout "https://github.com/guolau/landscape-learnr/blob/main/resources/js/layouts/Base.vue"
    click SnipCtrl "https://github.com/guolau/landscape-learnr/blob/main/app/Http/Controllers/SnippetController.php"
    click TagCtrl "https://github.com/guolau/landscape-learnr/blob/main/app/Http/Controllers/TagController.php"
    click SetCtrl "https://github.com/guolau/landscape-learnr/blob/main/app/Http/Controllers/SettingController.php"
    click AuthCtrl "https://github.com/guolau/landscape-learnr/blob/main/app/Http/Controllers/Auth/AuthenticatedSessionController.php"
    click SnipServ "https://github.com/guolau/landscape-learnr/blob/main/app/Services/SnippetService.php"
    click SnipModel "https://github.com/guolau/landscape-learnr/blob/main/app/Models/Snippet.php"
    click TagModel "https://github.com/guolau/landscape-learnr/blob/main/app/Models/Tag.php"
    click UserModel "https://github.com/guolau/landscape-learnr/blob/main/app/Models/User.php"
    click ImgModel "https://github.com/guolau/landscape-learnr/blob/main/app/Models/Image.php"
    click SetModel "https://github.com/guolau/landscape-learnr/blob/main/app/Models/Setting.php"
    click AdminMW "https://github.com/guolau/landscape-learnr/blob/main/app/Http/Middleware/EnsureUserIsAdmin.php"
    click SnipPolicy "https://github.com/guolau/landscape-learnr/blob/main/app/Policies/SnippetPolicy.php"
    click TagPolicy "https://github.com/guolau/landscape-learnr/blob/main/app/Policies/TagPolicy.php"
    click Inertia "https://github.com/guolau/landscape-learnr/blob/main/app/Http/Middleware/HandleInertiaRequests.php"
    click FileStore "https://github.com/guolau/landscape-learnr/blob/main/config/filesystems.php"
    click Cache "https://github.com/guolau/landscape-learnr/tree/main/storage/framework/cache/"
    click Session "https://github.com/guolau/landscape-learnr/tree/main/storage/framework/sessions/"

    %% Styling
    classDef frontend fill:#2196F3,color:white
    classDef bridge fill:#FF9800,color:white
    classDef controller fill:#4CAF50,color:white
    classDef service fill:#009688,color:white
    classDef model fill:#00BCD4,color:white
    classDef auth fill:#9C27B0,color:white
    classDef storage fill:#FF5722,color:white
    classDef db fill:#FFC107,color:black
```
