# aneeshram-01/nzwalk architecture

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

- Interactive diagram: https://gitdiagram.com/aneeshram-01/nzwalk
- Repository: https://github.com/aneeshram-01/nzwalk

## Overview

##### Project type and purpose
- NZWalks is a full‑stack .NET application composed of:
a. NZWalk.UI – an ASP.NET Core MVC front‑end that renders views, serves static assets, and handles user interactions in the browser.
b. NZWalk – a .NET Web API back‑end that exposes REST endpoints for Regions, Walks, Images and Authentication.
- Its purpose is to let users register/log in, browse and manage hiking regions and walks, upload images, and persist data in SQL Server.

##### File structure
- Top‑level solution (`NZWalk.sln`) contains two projects:
- NZWalk.UI (MVC)
- NZWalk (Web API)
- NZWalk.UI folders: Controllers, Models/DTOs/ViewModels, Views (Razor), static assets (wwwroot/css, js, lib).
- NZWalk folders: Controllers, Models (Domain & DTO), Data (DbContexts), Mappings (AutoMapper), Repositories (interfaces + SQL/Local implementations), Middlewares, Migrations, CustomActionFilters.
- Configuration: `appsettings.json`, `launchSettings.json`.

##### Detail
- Both databases (app data vs. auth data).
- Call out custom filters and middlewares in the pipeline.
- Static content (CSS/JS) served by the UI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client"
        Browser["Browser"]:::external
    end

    subgraph "NZWalk.UI (Front-End)"
        UIApp["NZWalk.UI"]:::frontend
        subgraph "Controllers"
            HomeCtrl["HomeController"]:::frontend
            UIRegionsCtrl["RegionsController"]:::frontend
        end
        subgraph "Models & DTOs"
            AddRegionVM["AddRegionViewModel"]:::frontend
            ErrorVM["ErrorViewModel"]:::frontend
            RegionDtoUI["RegionDto"]:::frontend
        end
        subgraph "Views"
            IndexView["Home/Index"]:::frontend
            PrivacyView["Home/Privacy"]:::frontend
            RegionsIndexView["Regions/Index"]:::frontend
            AddRegionView["Regions/Add"]:::frontend
            EditRegionView["Regions/Edit"]:::frontend
            LayoutView["Shared/_Layout"]:::frontend
            ValidationScript["Shared/_ValidationScriptsPartial"]:::frontend
        end
        subgraph "Static Assets"
            CSS["site.css"]:::frontend
            JS["site.js"]:::frontend
            Libs["bootstrap, jquery, validation"]:::frontend
        end
    end

    subgraph "NZWalk API (Back-End)"
        APIApp["NZWalk"]:::backend
        subgraph "Middleware Pipeline"
            ExceptionMiddleware["ExceptionHandlerMiddleware"]:::backend
            ValidateFilter["ValidateModelAttribute"]:::backend
        end
        subgraph "Controllers"
            AuthCtrl["AuthController"]:::backend
            APIRegionsCtrl["RegionsController"]:::backend
            WalksCtrl["WalksController"]:::backend
            ImagesCtrl["ImagesController"]:::backend
        end
        AutoMap["AutoMapperProfiles"]:::backend
        subgraph "Repositories"
            IRegionRepo["IRegionRepository"]:::backend
            SQLRegionRepo["SQLRegionRepository"]:::backend
            IImageRepo["IImageRepository"]:::backend
            LocalImageRepo["LocalImageRepository"]:::backend
            ITokenRepo["ITokenRepository"]:::backend
            TokenRepo["TokenRepository"]:::backend
        end
        subgraph "DbContexts"
            AppDb["NZWalkDbContext"]:::persist
            AuthDb["NZWalkAuthDbContext"]:::persist
        end
    end

    subgraph "Persistence"
        SQLServerDB["SQL Server\n(NZWalkDb & NZWalkAuthDb)"]:::persist
        FileStore["Local Image Storage"]:::external
    end

    Browser -->|"HTTP GET/POST"| UIApp
    UIApp -->|Renders Views| IndexView
    UIApp -->|AJAX JSON| APIApp
    APIApp -->|Request| ExceptionMiddleware
    ExceptionMiddleware --> ValidateFilter
    ValidateFilter --> AuthCtrl
    ValidateFilter --> APIRegionsCtrl
    ValidateFilter --> WalksCtrl
    ValidateFilter --> ImagesCtrl
    AuthCtrl --> TokenRepo
    TokenRepo --> AuthDb
    APIRegionsCtrl --> AutoMap
    AutoMap --> SQLRegionRepo
    SQLRegionRepo --> AppDb
    ImagesCtrl --> LocalImageRepo
    LocalImageRepo --> FileStore
    LocalImageRepo --> AppDb
    AppDb --> SQLServerDB
    AuthDb --> SQLServerDB

    click UIApp "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI"
    click HomeCtrl "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Controllers/HomeController.cs"
    click UIRegionsCtrl "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Controllers/RegionsController.cs"
    click AddRegionVM "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Models/AddRegionViewModel.cs"
    click ErrorVM "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Models/ErrorViewModel.cs"
    click RegionDtoUI "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Models/DTOs/RegionDto.cs"
    click IndexView "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Views/Home/Index.cshtml"
    click PrivacyView "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Views/Home/Privacy.cshtml"
    click RegionsIndexView "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Views/Regions/Index.cshtml"
    click AddRegionView "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Views/Regions/Add.cshtml"
    click EditRegionView "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Views/Regions/Edit.cshtml"
    click LayoutView "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Views/Shared/_Layout.cshtml"
    click ValidationScript "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/Views/Shared/_ValidationScriptsPartial.cshtml"
    click CSS "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/wwwroot/css/site.css"
    click JS "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk.UI/wwwroot/js/site.js"
    click Libs "https://github.com/aneeshram-01/nzwalk/tree/master/NZWalk.UI/wwwroot/lib/bootstrap"
    click APIApp "https://github.com/aneeshram-01/nzwalk/tree/master/NZWalk"
    click AuthCtrl "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Controllers/AuthController.cs"
    click APIRegionsCtrl "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Controllers/RegionsController.cs"
    click WalksCtrl "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Controllers/WalksController.cs"
    click ImagesCtrl "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Controllers/ImagesController.cs"
    click ExceptionMiddleware "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Middlewares/ExceptionHandlerMiddleware.cs"
    click ValidateFilter "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/CustomActionFilters/ValidateModelAttribute.cs"
    click AutoMap "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Mappings/AutoMapperProfiles.cs"
    click AppDb "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Data/NZWalkDbContext.cs"
    click AuthDb "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Data/NZWalkAuthDbContext.cs"
    click SQLRegionRepo "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Repositories/SQLRegionRepository.cs"
    click LocalImageRepo "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Repositories/LocalImageRepository.cs"
    click TokenRepo "https://github.com/aneeshram-01/nzwalk/blob/master/NZWalk/Repositories/TokenRepository.cs"

    classDef frontend fill:#AEDFFD,stroke:#333,stroke-width:1px;
    classDef backend fill:#D5FFD6,stroke:#333,stroke-width:1px;
    classDef persist fill:#FFD7A6,stroke:#333,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
