# melncat/mewtilities architecture

> Architecture diagram of the GitHub repository melncat/mewtilities, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/melncat/mewtilities
- Repository: https://github.com/melncat/mewtilities

## Overview

##### Main Components

a. Frontend Layer:
- Next.js Application (Client-side)
- Pages/Routes (organize by feature modules):
- Admin Panel
- Cat Data Analytics
- Cat Editor
- Item Marketplace
- Offspring Calculator
- Shared Components
- Styles (SCSS modules)

b. Backend Layer:
- Next.js API Routes
- Authentication System (NextAuth.js)
- Data Parsers
- Market Parser
- Cat Parser
- Item Parser
- Recipe Parser
- Shop Parser

c. Database Layer:
- Prisma ORM
- Database (likely PostgreSQL based on Prisma usage)
- Migration System

##### Component Relationships

- Client-Server communication through API routes
- Data flow from parsers to database
- Authentication flow between client, server, and database
- Component dependencies and interactions

##### Specific Implementation Details

Specialized sections for:
- File handling (FilePanel component)
- Cat genetics system
- Market price tracking
- Item management system

##### Key Architectural Patterns to Highlight

- Next.js App Router architecture
- API Route structure
- Database schema migrations
- Authentication flow
- Parser pipeline

**[Frontend Layer]**
- ↕
**[API/Backend Layer]**
- ↕
**[Parser Layer]**
- ↕
**[Database Layer]**

Important Elements to Include:

##### Entry Points
- Web UI endpoints
- API routes
- Admin panel access

##### Security Layer
- Authentication middleware
- Admin authorization
- Protected routes

##### Data Processing
- Parser system for different game data types
- Data transformation pipeline
- Storage procedures

##### External Integrations
- Game data sources
- Authentication providers
- Asset storage

Guidelines for Creation:

##### Error handling and fallback paths

Keep the following aspects in mind:
- This is a utility website with multiple specialized tools
- Heavy focus on data parsing and analysis
- Secure admin functionality
- Complex game mechanics (genetics, marketplace, items)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#d0e1f9,stroke:#333
    classDef api fill:#90ee90,stroke:#333
    classDef parser fill:#ffeb99,stroke:#333
    classDef database fill:#e6b3ff,stroke:#333
    classDef auth fill:#ff9999,stroke:#333

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        A[API/Backend]:::api
        P[Parser]:::parser
        D[(Database)]:::database
        AU[Auth]:::auth
    end

    %% Frontend Layer
    subgraph Frontend
        AP[Admin Panel]
        CDA[Cat Data Analytics]
        CE[Cat Editor]
        IM[Item Marketplace]
        OC[Offspring Calculator]
        
        subgraph SharedComponents
            CC[Cat Components]
            IC[Item Components]
            AUI[Auth UI]
        end
    end

    %% Backend Layer
    subgraph Backend
        AR[Auth Routes]
        IAR[Items API]
        CAR[Clothing API]
    end

    %% Parser Layer
    subgraph Parsers
        MP[Market Parser]
        CP[Cat Parser]
        IP[Item Parser]
        RP[Recipe Parser]
        SP[Shop Parser]
    end

    %% Database Layer
    subgraph Database
        PS[(Prisma Schema)]
        DBU[(Database Utils)]
        MIG[(Migrations)]
    end

    %% Auth System
    subgraph AuthSystem
        AC[Auth Config]
        AI[Auth Implementation]
        AA[Auth Actions]
    end

    %% Specialized Systems
    subgraph SpecializedSystems
        FH[File Handler]
        CG[Cat Genetics]
        MA[Market Analysis]
        IMS[Item Management]
    end

    %% Relationships
    Frontend --> Backend
    Backend --> Parsers
    Parsers --> Database
    AuthSystem --> Backend
    Frontend --> AuthSystem
    SpecializedSystems --> Backend

    %% Click Events
    click AP "https://github.com/MelnCat/Mewtilities/blob/main/src/app/admin/panel/AdminPanel.tsx"
    click CDA "https://github.com/MelnCat/Mewtilities/blob/main/src/app/cat-data/page.tsx"
    click CE "https://github.com/MelnCat/Mewtilities/blob/main/src/app/cat-editor/page.tsx"
    click IM "https://github.com/MelnCat/Mewtilities/blob/main/src/app/items/page.tsx"
    click OC "https://github.com/MelnCat/Mewtilities/blob/main/src/app/offspring-calculator/page.tsx"
    click CC "https://github.com/MelnCat/Mewtilities/blob/main/src/app/components/CatImage.tsx"
    click IC "https://github.com/MelnCat/Mewtilities/blob/main/src/app/components/ItemImage.tsx"
    click AUI "https://github.com/MelnCat/Mewtilities/blob/main/src/app/components/SignIn.tsx"
    click AR "https://github.com/MelnCat/Mewtilities/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click IAR "https://github.com/MelnCat/Mewtilities/blob/main/src/app/api/items/route.ts"
    click CAR "https://github.com/MelnCat/Mewtilities/blob/main/src/app/api/clothing/route.ts"
    click MP "https://github.com/MelnCat/Mewtilities/blob/main/src/parser/marketParser.ts"
    click CP "https://github.com/MelnCat/Mewtilities/blob/main/src/parser/catParser.ts"
    click IP "https://github.com/MelnCat/Mewtilities/blob/main/src/parser/itemDatabaseParser.ts"
    click RP "https://github.com/MelnCat/Mewtilities/blob/main/src/parser/recipeDatabaseParser.ts"
    click SP "https://github.com/MelnCat/Mewtilities/blob/main/src/parser/shopParser.ts"
    click PS "https://github.com/MelnCat/Mewtilities/blob/main/prisma/schema.prisma"
    click DBU "https://github.com/MelnCat/Mewtilities/blob/main/src/db/db.ts"
    click MIG "https://github.com/MelnCat/Mewtilities/tree/main/prisma/migrations/"
    click AC "https://github.com/MelnCat/Mewtilities/blob/main/src/auth.config.ts"
    click AI "https://github.com/MelnCat/Mewtilities/blob/main/src/auth.ts"
    click AA "https://github.com/MelnCat/Mewtilities/blob/main/src/actions/auth.ts"
    click FH "https://github.com/MelnCat/Mewtilities/blob/main/src/app/admin/panel/FilePanel.tsx"
    click CG "https://github.com/MelnCat/Mewtilities/blob/main/src/util/gene.ts"
    click MA "https://github.com/MelnCat/Mewtilities/blob/main/src/app/item/[id]/components/PriceGraph.tsx"
    click IMS "https://github.com/MelnCat/Mewtilities/blob/main/src/app/items/components/ItemList.tsx"

    %% Style Applications
    class AP,CDA,CE,IM,OC,CC,IC,AUI frontend
    class AR,IAR,CAR api
    class MP,CP,IP,RP,SP parser
    class PS,DBU,MIG database
    class AC,AI,AA auth
```
