# jasontsai123/oauthdevelopmentpractice architecture

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

- Interactive diagram: https://gitdiagram.com/jasontsai123/oauthdevelopmentpractice
- Repository: https://github.com/jasontsai123/oauthdevelopmentpractice

## Overview

##### Project type and purpose
- This is a full-stack ASP.NET Core MVC web application that implements OAuth 2.0 user flows for LINE Login and LINE Notify.
- It provides:
- User authentication via LINE Login
- Subscription, notification, and unsubscription via LINE Notify
- An admin UI to send broadcast messages
- Persistence with EF Core using an in-memory SQLite database (with scaffolding via Migrations).

##### File structure
- Top-level:
- WebSite/ – the main MVC app
– Controllers/ – HTTP endpoints for Login, Logout, Home, Admin, LineNotify
– Models/ – view models & DTOs (ErrorViewModel, SendNotifyMessage, etc.)
– Repositories/ – encapsulate calls to external LINE APIs and data-access for subscribers
– Database/ – EF Core DbContext (MemberContext.cs)
– Migrations/ – EF Core model snapshot and migration files
– Views/ – Razor views for UI
– wwwroot/ – static assets (CSS, JS, images, Bootstrap, jQuery)
– appsettings.json & launchSettings.json – configuration
– Dockerfile & .dockerignore – containerization
- WebSiteTest/ – unit tests for the subscriber repository
- identifier.sqlite – local SQLite DB file

##### README for additional insights
- Describes OAuth flows for both LINE Notify and LINE Login:
- GET /oauth/authorize → callback → POST /oauth/token → API calls
- Key external dependencies: notify-bot.line.me and access.line.me endpoints
- Highlights that Notify and Login are implemented as independent “platform” modules.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client (Browser)"
        Views["Razor Views"]:::frontend
        Static["Static Assets"]:::frontend
    end

    subgraph "WebApp (Docker Container)"
        subgraph "Presentation Layer"
            HomeC["HomeController"]:::component
            LoginC["LoginController"]:::component
            LogoutC["LogoutController"]:::component
            NotifyC["LineNotifyController"]:::component
            AdminC["AdminController"]:::component
        end

        subgraph "Models"
            ErrorVM["ErrorViewModel"]:::component
            SubscriberVM["LineNotifySubscriberViewModel"]:::component
            SendMSG["SendNotifyMessage"]:::component
        end

        subgraph "Settings"
            LoginSet["LineLoginSetting"]:::component
            NotifySet["LineNotifySetting"]:::component
        end

        subgraph "Data Layer"
            DbC["MemberContext (DbContext)"]:::database
            Migrations["EF Migrations"]:::database
        end

        subgraph "Repositories"
            subgraph "LINE Login API"
                ILoginApi["ILineLoginApi"]:::component
                LoginApi["LineLoginApi"]:::component
                TokenRes["LineOAuth2TokenResult"]:::component
                ProfileRes["LineProfileResult"]:::component
            end
            subgraph "LINE Notify API"
                INotifyApi["ILineNotifyApi"]:::component
                NotifyApi["LineNotifyApi"]:::component
                Authorize["LineNotifyAuthorize"]:::component
                TokenN["LineNotifyOauthToken"]:::component
                Param["NotifyParameter"]:::component
                Result["NotifyResult"]:::component
                OauthParam["OauthTokenParameter"]:::component
                RevokeR["RevokeResult"]:::component
            end
            subgraph "Subscriber Repo"
                ISubRepo["ILineNotifySubscriberRepository"]:::component
                Subscriber["LineNotifySubscriber"]:::component
                SubRepo["LineNotifySubscriberRepository"]:::component
            end
        end

        Configuration["appsettings.json & launchSettings.json"]:::component
        Dockerfile["Dockerfile"]:::component
    end

    subgraph "External Services"
        LINELogin["LINE Login API"]:::external
        LINENotify["LINE Notify API"]:::external
    end

    subgraph "Tests"
        TestRepo["LineNotifySubscriberRepositoryTest"]:::test
    end

    Views -->|HTTP| HomeC
    Views -->|HTTP| LoginC
    Views -->|HTTP| LogoutC
    Views -->|HTTP| NotifyC
    Views -->|HTTP| AdminC
    Static -->|assets| HomeC

    HomeC -->|uses| DbC
    LoginC -->|calls| ILoginApi
    LoginC -->|reads| DbC
    LogoutC -->|calls| ILoginApi
    NotifyC -->|calls| INotifyApi
    NotifyC -->|uses| SubRepo
    AdminC -->|calls| NotifyApi

    SubRepo -->|CRUD| DbC
    ILoginApi -->|OAuth Flow| LINELogin
    INotifyApi -->|Notify Flow| LINENotify

    TestRepo -->|tests| SubRepo

    click Views "https://github.com/jasontsai123/oauthdevelopmentpractice/tree/main/WebSite/WebSite/Views"
    click Static "https://github.com/jasontsai123/oauthdevelopmentpractice/tree/main/WebSite/WebSite/wwwroot"
    click HomeC "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Controllers/HomeController.cs"
    click LoginC "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Controllers/LoginController.cs"
    click LogoutC "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Controllers/LogoutController.cs"
    click NotifyC "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Controllers/LineNotifyController.cs"
    click AdminC "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Controllers/AdminController.cs"
    click ErrorVM "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Models/ErrorViewModel.cs"
    click SubscriberVM "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Models/LineNotifySubscriberViewModel.cs"
    click SendMSG "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Models/SendNotifyMessage.cs"
    click LoginSet "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Setting/LineLoginSetting.cs"
    click NotifySet "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Setting/LineNotifySetting.cs"
    click DbC "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Database/MemberContext.cs"
    click Migrations "https://github.com/jasontsai123/oauthdevelopmentpractice/tree/main/WebSite/WebSite/Migrations"
    click ILoginApi "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineLogin/ILineLoginApi.cs"
    click LoginApi "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineLogin/LineLoginApi.cs"
    click TokenRes "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineLogin/LineOAuth2TokenResult.cs"
    click ProfileRes "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineLogin/LineProfileResult.cs"
    click INotifyApi "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotify/ILineNotifyApi.cs"
    click NotifyApi "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotify/LineNotifyApi.cs"
    click Authorize "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotify/LineNotifyAuthorize.cs"
    click TokenN "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotify/LineNotifyOauthToken.cs"
    click Param "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotify/NotifyParameter.cs"
    click Result "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotify/NotifyResult.cs"
    click OauthParam "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotify/OauthTokenParameter.cs"
    click RevokeR "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotify/RevokeResult.cs"
    click ISubRepo "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotifySubscriber/ILineNotifySubscriberRepository.cs"
    click Subscriber "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotifySubscriber/LineNotifySubscriber.cs"
    click SubRepo "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/Repositories/LineNotifySubscriber/LineNotifySubscriberRepository.cs"
    click Configuration "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSite/appsettings.json"
    click Dockerfile "https://github.com/jasontsai123/oauthdevelopmentpractice/tree/main/WebSite/WebSite/Dockerfile"
    click TestRepo "https://github.com/jasontsai123/oauthdevelopmentpractice/blob/main/WebSite/WebSiteTest/Repositories/LineNotifySubscriber/LineNotifySubscriberRepositoryTest.cs"

    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef component fill:#E8F0FE,stroke:#1A73E8,color:#1A73E8
    classDef database fill:#FFF4E5,stroke:#FBBC05,color:#BF360C
    classDef external fill:#E6F4EA,stroke:#34A853,color:#34A853
    classDef test fill:#F0F0F0,stroke:#9E9E9E,color:#616161
```
