# quangphatt/godzillarestaurantaspnetmvc architecture

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

- Interactive diagram: https://gitdiagram.com/quangphatt/godzillarestaurantaspnetmvc
- Repository: https://github.com/quangphatt/godzillarestaurantaspnetmvc

## Overview

##### Main Components
- Frontend (Presentation Layer): Represented by the Views (under GodzillaRestaurant/Views and wwwroot for static assets like CSS, JS, and images). These views are served to the client browsers.
- Controllers (MVC Layer): The controllers such as AccountController, AdminController, BookingController, etc., handle incoming HTTP requests and orchestrate interactions between the view and the business logic.
- Business Logic / Services Layer: Located in the Services folder, these interfaces (e.g., IBookingService, IFoodService) and their implementations handle core processing (like booking, ordering, mailing) and coordinate with the data access layer.
- Data Access Layer (DAL): The DAL folder under GodzillaRestaurant/DataAccessLayer contains repositories like BookingDAL, FoodDAL, and others. They encapsulate database operations.
- Models / Domain Layer: The Models directory provides the data structures (e.g., Booking, Order, Food) that represent the entities in your application.
- Database: The PostgreSQL database is referenced by the connection string in appsettings.json and configured via Entity Framework’s migrations in the Migrations folder.
- External Services: The email functionality (using credentials stored in the .env file) for account registration and password changes is a notable external integration. In addition, hosting on Microsoft Azure also forms a part of the deployment & infrastructure component.

##### Relationships and Interactions
- User requests are received by Controllers which process the request and interact with the Services.
- Services call the Data Access Layer to perform CRUD operations on the PostgreSQL database.
- Data flows from the Database back through DAL and Services to the Controllers, which then pass appropriate data to the Views.
- Static files (CSS, JS, images) and client-side libraries (e.g., Bootstrap, jQuery) are served from the wwwroot folder.
- Administrative functionality (e.g., menu management, bookings, and orders) is handled via specialized controllers (like AdminController) with their dedicated Views.
- The Entity Framework migrations manage the evolution of the database schema over time.

##### Architectural Patterns and Design Principles
- MVC (Model-View-Controller): Clearly separates concerns between front-end UI, business logic, and data handling.
- Repository Pattern: Evident in the DataAccessLayer where data operations are abstracted.
- Dependency Injection: Indicated by the use of service interfaces (IBookingService, IFoodService, etc.) to promote loose coupling.
- Separation of Concerns: Different directories for Controllers, Views, Models, Services, and DAL reinforce this principle.

##### Relevant Technologies and Frameworks
- ASP.NET MVC running on .NET 7.0.
- Entity Framework (with migrations) for ORM and database interactions.
- PostgreSQL as the database backend.
- Frontend frameworks/libraries like Bootstrap, jQuery, and client-side validation libraries.

##### Additional Details to Consider
- For the “Migration” component: Include a small module labeled “Migrations” that feeds into the Database component to show how schema changes are applied.
- Dependency on static content in the wwwroot folder, which feeds into the User Interface.
- How the Controllers are organized by different functionalities (Account, Admin, Booking, Order, etc.), perhaps by grouping or annotations if needed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["User / Browser"]:::user

    %% Presentation Layer
    subgraph "Presentation Layer"
        UI1["Views"]:::presentation
        UI2["Static Assets (wwwroot)"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        Controllers["Controllers (MVC)"]:::controller
        Services["Services / Business Logic"]:::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DAL["Data Access Layer (DAL)"]:::dal
        Models["Models / Domain"]:::model
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["Database (PostgreSQL)"]:::database
        Migrations["Migrations"]:::migrations
    end

    %% External Services & Deployment
    subgraph "External & Deployment"
        Email["Email Integration"]:::external
        DotEnv[".env Configuration"]:::externalConfig
        Azure["Azure Hosting"]:::external
    end

    %% Relationships
    User -->|"HTTP_Request"| UI1
    User -->|"HTTP_Request"| UI2
    UI1 -->|"rendered_by"| Controllers
    UI2 -->|"supplies_assets_to"| Controllers
    Controllers -->|"invokes"| Services
    Services -->|"utilizes"| DAL
    Services -->|"operates_on"| Models
    DAL -->|"maps_entities"| Models
    DAL -->|"performs_C_R_U_D"| DB
    Migrations -->|"updates_schema"| DB
    Controllers -->|"triggers"| Email
    Services -->|"configures_email"| Email
    Email -->|"configured_via"| DotEnv
    Azure -->|"hosts"| UI1
    Azure -->|"hosts"| Controllers
    Azure -->|"hosts"| Services

    %% Click Events
    click UI1 "https://github.com/quangphatt/godzillarestaurantaspnetmvc/tree/main/GodzillaRestaurant/Views"
    click UI2 "https://github.com/quangphatt/godzillarestaurantaspnetmvc/tree/main/GodzillaRestaurant/wwwroot"
    click Controllers "https://github.com/quangphatt/godzillarestaurantaspnetmvc/tree/main/GodzillaRestaurant/Controllers"
    click Services "https://github.com/quangphatt/godzillarestaurantaspnetmvc/tree/main/GodzillaRestaurant/Services"
    click DAL "https://github.com/quangphatt/godzillarestaurantaspnetmvc/tree/main/GodzillaRestaurant/DataAccessLayer"
    click Models "https://github.com/quangphatt/godzillarestaurantaspnetmvc/tree/main/GodzillaRestaurant/Models"
    click Migrations "https://github.com/quangphatt/godzillarestaurantaspnetmvc/tree/main/GodzillaRestaurant/Migrations"
    click Email "https://github.com/quangphatt/godzillarestaurantaspnetmvc/blob/main/GodzillaRestaurant/wwwroot/mail/mail_template.html"
    click DotEnv "https://github.com/quangphatt/godzillarestaurantaspnetmvc/blob/main/GodzillaRestaurant/Data/DotEnv.cs"
    click Azure "https://github.com/quangphatt/godzillarestaurantaspnetmvc/tree/main/GodzillaRestaurant/Properties/ServiceDependencies"

    %% Styles
    classDef user fill:#ffebcd,stroke:#8b4513,stroke-width:2px;
    classDef presentation fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef controller fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef service fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef dal fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef model fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef database fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
    classDef migrations fill:#fcf3cf,stroke:#b7950b,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef externalConfig fill:#f0f0f0,stroke:#6c757d,stroke-width:2px;
```
