# theoch3n/travellog-dotnet architecture

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

- Interactive diagram: https://gitdiagram.com/theoch3n/travellog-dotnet
- Repository: https://github.com/theoch3n/travellog-dotnet

## Overview

##### Project Type and Purpose
- This is a full-stack solution with:
– A server-rendered admin UI (TravelLog MVC app)
– A RESTful backend API (TravelLogAPI)
– Shared data storage (SQL Server via EF Core)
– Real-time chat (SignalR)
– External integrations (Gmail API for email, ECPay for payments)

##### Top-Level Components
- Admin Browser Client
- TravelLog (MVC app)
- TravelLogAPI (Web API app)
- SQL Server Database
- External Services:
– Gmail API
– ECPay Gateway
- (Optional) TemplateEngineHost – VS template cache host

##### Layers Within Each App
– Presentation Layer
- MVC Views + Razor Pages (TravelLog)
- API Controllers + SignalR Hubs (TravelLogAPI)
– Application/Business Layer
- Controllers orchestrate services
- Services folder in API handles business logic (e.g., GoogleAuthHelper, GmailServiceHelper, EcpayController)
– Data Access Layer
- Entity Framework Core (DbContext, Models, Migrations)

##### Relationships & Data Flows
- Browser → HTTP(S) → TravelLog MVC Controllers → EF Core → SQL Server
- Browser → HTTP(S) → TravelLogAPI Controllers (JWT auth) → Services → EF Core → SQL Server
- TravelLogAPI Hubs (SignalR) ← WebSocket → Browser for chat
- TravelLogAPI → Gmail API (SMTP/REST) for sending emails
- TravelLogAPI → ECPay Gateway (REST) for payment processing
- Both apps read/write the same database schema

##### Architectural Patterns
- Layered MVC for TravelLog UI
- RESTful API + JWT authentication for TravelLogAPI
- Shared domain models duplicated across projects (Models folder in each)
- SignalR Hub for real-time features
- TemplateEngineHost for VS item templates (side-component)

##### Technologies
- ASP.NET Core 8.0
- Entity Framework Core
- SQL Server 2019
- JWT for auth (TravelLogAPI)
- Gmail API & OAuth2 credentials
- ECPay integration
- SignalR for chat
- Static assets loader (wwwroot in TravelLog)

##### Final Checklist
– Components clearly named: Browser, TravelLog MVC, TravelLogAPI, DB, Gmail API, ECPay Gateway, SignalR Hub
– Layers depicted within each component
– Notes on protocols and authentication flows

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients and Hosts
    Browser["Admin Browser Client"]:::client
    TemplateEngineHost["TemplateEngineHost (VS Template Cache)"]:::client

    %% Internal Components
    subgraph "TravelLog MVC App" 
        direction TB
        MVC_Entry["Program.cs"]:::internal
        MVC_Services["Presentation Layer"]:::internal
        MVC_Data["Data Access Layer"]:::internal

        subgraph "Presentation Layer"
            direction TB
            MVC_Controllers["Controllers"]:::internal
            MVC_Views["Views/Razor Pages"]:::internal
            MVC_Static["wwwroot (Static Assets)"]:::internal
        end

        subgraph "Data Access Layer"
            direction TB
            MVC_Models["DbContext & Models"]:::internal
            MVC_Migrations["Sql Scripts/Migrations"]:::internal
        end
    end

    subgraph "TravelLogAPI Web API"
        direction TB
        API_Entry["Program.cs & Startup.cs"]:::internal
        API_Presentation["API Controllers & SignalR Hubs"]:::internal
        API_Business["Business Layer (Services & Helpers)"]:::internal
        API_Data["Data Access Layer"]:::internal

        subgraph "API Controllers & SignalR Hubs"
            direction TB
            API_Controllers["Controllers"]:::internal
            API_Hub["ChatHub (SignalR)"]:::internal
        end

        subgraph "Business Layer"
            direction TB
            GmailProvider["GmailApiProvider & Helpers"]:::internal
            EcpayController["EcpayController"]:::internal
            OAuthHelpers["FixedPortLocalServerCodeReceiver"]:::internal
        end

        subgraph "Data Access Layer"
            direction TB
            API_Models["DbContext & Models"]:::internal
        end
    end

    %% Database and External
    SQL["SQL Server Database"]:::db
    GmailAPI["Gmail API"]:::external
    ECPay["ECPay Gateway"]:::external

    %% Connections
    Browser -->|"HTTPS"| MVC_Controllers
    MVC_Controllers -->|"EF Core"| SQL
    MVC_Static --> Browser
    Browser -->|"HTTPS/API"| API_Controllers
    API_Controllers -->|"EF Core"| SQL
    Browser -->|"WebSocket/SignalR"| API_Hub
    API_Hub -->|"WebSocket/SignalR"| Browser
    API_Business -->|"SMTP/REST"| GmailAPI
    API_Business -->|"REST"| ECPay
    TemplateEngineHost -.-> TemplateEngineHost

    %% Click Events
    click TemplateEngineHost "https://github.com/theoch3n/travellog-dotnet/tree/main/TemplateEngineHost/"
    click MVC_Entry "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLog/Program.cs"
    click MVC_Controllers "https://github.com/theoch3n/travellog-dotnet/tree/main/TravelLog/Controllers/"
    click MVC_Views "https://github.com/theoch3n/travellog-dotnet/tree/main/TravelLog/Views/"
    click MVC_Static "https://github.com/theoch3n/travellog-dotnet/tree/main/TravelLog/wwwroot/"
    click MVC_Models "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLog/Models/TravelLogContext.cs"
    click MVC_Migrations "https://github.com/theoch3n/travellog-dotnet/tree/main/TravelLog/Sql/"
    click API_Entry "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLogAPI/Program.cs"
    click API_Entry "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLogAPI/Startup.cs"
    click API_Controllers "https://github.com/theoch3n/travellog-dotnet/tree/main/TravelLogAPI/Controllers/"
    click API_Hub "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLogAPI/Hubs/ChatHub.cs"
    click GmailProvider "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLogAPI/Services/GmailApiProvider.cs"
    click GmailProvider "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLogAPI/Services/GmailServiceHelper.cs"
    click GmailProvider "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLogAPI/Services/GoogleAuthHelpercs.cs"
    click EcpayController "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLogAPI/Controllers/EcpayController.cs"
    click OAuthHelpers "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLogAPI/Services/FixedPortLocalServerCodeReceiver.cs"
    click API_Models "https://github.com/theoch3n/travellog-dotnet/blob/main/TravelLogAPI/Models/TravelLogContext.cs"

    %% Styles
    classDef client fill:#cccccc,stroke:#333,stroke-width:1px
    classDef internal fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef db fill:#98FB98,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
```
