# kubra-kzlk/mtg-project architecture

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

- Interactive diagram: https://gitdiagram.com/kubra-kzlk/mtg-project
- Repository: https://github.com/kubra-kzlk/mtg-project

## Overview

##### Main Components Identification
The project appears to be a full-stack Node.js/TypeScript web application with the following key components:

A. Frontend Layer:
- Views (EJS templating)
- Static Assets (CSS, JavaScript, Images)
- Client-side JavaScript

B. Backend Layer:
- Express.js Server (TypeScript)
- Routing System
- Authentication/Security Middleware
- Database Interface

C. Database Layer:
- Session Management
- Data Storage (likely for cards and decks)

##### Client Layer (Top)
- Sub-components:
- EJS Views
- Static Assets
- Client-side JavaScript

##### Application Layer (Middle)
- Sub-systems:
- Router Management
- Authentication/Security
- Business Logic
- Template Engine

##### Data Layer (Bottom)
- Database Systems
- Session Storage
- Data Models (Users, Decks, Cards)

Use these specific visual elements:

- Components: Use rectangles with rounded corners
- Blue: Frontend components
- Green: Backend/Server components
- Yellow: Database/Storage components
- Red: Security/Authentication components

##### Client → Server
- HTTP/HTTPS requests through routes
- Authentication flows
- Card/Deck operations

##### Server → Database
- Data persistence
- Session management
- User authentication

##### Detailed Component Breakdown

Specific elements based on the file structure:

A. Routes Layer:
- mainRouter
- cardInfoRouter
- deckRouter
- drawRouter
- loginRouter
- registerRouter

B. Middleware Layer:
- Security middleware
- Session handling

C. Data Models:
- User interface
- Deck interface
- MTG Cards interface

D. Views Layer:
- Main views
- Card info views
- Deck management views
- Authentication views

##### External dependencies
- Node.js runtime
- Express.js framework
- Database system
- Authentication services

##### Technical Details

Technical specifications for:
- TypeScript configuration
- Development container setup
- Environment variables
- GitHub workflow integration

Remember to:
- Use consistent styling
- Related components
- Clear boundaries between layers
- Version information
- Document any external service integrations

This will provide a comprehensive view of the MTG web application's architecture while maintaining clarity and usefulness for development team members.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Browser/Client"]:::client
        Views["Views Layer"]:::frontend
        StaticAssets["Static Assets"]:::frontend
        ClientJS["Client-side JavaScript"]:::frontend
    end

    subgraph Server
        AppEntry["Application Entry"]:::server
        Router["Router System"]:::server
        Security["Security/Middleware"]:::security
        BusinessLogic["Business Logic"]:::server
        TemplateEngine["Template Engine"]:::server
    end

    subgraph Data
        DB["Database"]:::database
        SessionMgmt["Session Management"]:::database
        DataModels["Data Models"]:::database
    end

    %% Client Layer Details
    Views --> |Contains| ViewComponents["View Components"]:::frontend
    StaticAssets --> |Contains| CSS["CSS Files"]:::frontend
    StaticAssets --> |Contains| Images["Images"]:::frontend
    ClientJS --> |Contains| DeckMgmt["Deck Management"]:::frontend
    ClientJS --> |Contains| RegStyle["Registration Styling"]:::frontend

    %% Server Layer Details
    Router --> |Routes| MainRouter["Main Router"]:::server
    Router --> |Routes| CardRouter["Card Info Router"]:::server
    Router --> |Routes| DeckRouter["Deck Router"]:::server
    Router --> |Routes| AuthRouter["Auth Routes"]:::server

    %% Data Layer Details
    DataModels --> |Model| UserModel["User Model"]:::database
    DataModels --> |Model| DeckModel["Deck Model"]:::database
    DataModels --> |Model| CardModel["MTG Cards Model"]:::database

    %% Relationships
    Browser --> |HTTP/HTTPS| Router
    Router --> |Processes| BusinessLogic
    BusinessLogic --> |Uses| Security
    BusinessLogic --> |Queries| DB
    BusinessLogic --> |Manages| SessionMgmt
    BusinessLogic --> |Validates| DataModels
    TemplateEngine --> |Renders| Views

    %% Click Events
    click Views "https://github.com/kubra-kzlk/MTG-project/tree/main/views"
    click ViewComponents "https://github.com/kubra-kzlk/MTG-project/tree/main/views/partials"
    click CSS "https://github.com/kubra-kzlk/MTG-project/tree/main/public/css"
    click Images "https://github.com/kubra-kzlk/MTG-project/tree/main/public/assets/images"
    click ClientJS "https://github.com/kubra-kzlk/MTG-project/tree/main/public/js"
    click DeckMgmt "https://github.com/kubra-kzlk/MTG-project/blob/main/public/js/decklist.js"
    click RegStyle "https://github.com/kubra-kzlk/MTG-project/blob/main/public/js/styling-register.js"
    click MainRouter "https://github.com/kubra-kzlk/MTG-project/blob/main/routes/mainRouter.ts"
    click CardRouter "https://github.com/kubra-kzlk/MTG-project/blob/main/routes/cardInfoRouter.ts"
    click DeckRouter "https://github.com/kubra-kzlk/MTG-project/blob/main/routes/deckRouter.ts"
    click AuthRouter "https://github.com/kubra-kzlk/MTG-project/blob/main/routes/loginRouter.ts"
    click DB "https://github.com/kubra-kzlk/MTG-project/blob/main/public/db/database.ts"
    click SessionMgmt "https://github.com/kubra-kzlk/MTG-project/blob/main/public/db/session.ts"
    click Security "https://github.com/kubra-kzlk/MTG-project/blob/main/public/middleware/secureMiddleware.ts"
    click UserModel "https://github.com/kubra-kzlk/MTG-project/blob/main/public/interfaces/user.ts"
    click DeckModel "https://github.com/kubra-kzlk/MTG-project/blob/main/public/interfaces/deck.ts"
    click CardModel "https://github.com/kubra-kzlk/MTG-project/blob/main/public/interfaces/mgtcards.ts"
    click AppEntry "https://github.com/kubra-kzlk/MTG-project/blob/main/index.ts"

    %% Styling
    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef frontend fill:#69c,stroke:#333,stroke-width:2px
    classDef server fill:#9c6,stroke:#333,stroke-width:2px
    classDef security fill:#f66,stroke:#333,stroke-width:2px
    classDef database fill:#fc3,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        Client_["Client"]:::client
        Frontend_["Frontend"]:::frontend
        Server_["Server"]:::server
        Security_["Security"]:::security
        Database_["Database"]:::database
    end
```
