# stevenjknaack/pantrychef architecture

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

- Interactive diagram: https://gitdiagram.com/stevenjknaack/pantrychef
- Repository: https://github.com/stevenjknaack/pantrychef

## Overview

##### Project Type & Purpose
- PantryChef is a full-stack web application designed to help home cooks make use of leftover ingredients by suggesting recipes based on available items.
- The README reveals that the backend is built with Java Spring Boot (using Gradle for builds) and MySQL is used for data management, while the frontend uses React with TypeScript (powered by Vite).
- This application also includes data processing components (data parsers, CSVs, SQL scripts) to support loading and preparing recipe and user data.

##### File Structure & Key Architectural Insights
- Top-level directories include “backend” (Java Spring Boot), “frontend” (React.ts), and “data” (for CSV parsing and SQL scripts).
- The backend follows a layered/MVC structure: configurations, controllers, services, repositories, entities, DTOS, and error handling are clearly separated.
- Presence of dedicated controllers (e.g., AuthenticationController, RecipeController) and corresponding services and repositories.
- There are also filters (e.g., JWTAuthenticationFilter) which indicate security/jwt-based authentication.
- The frontend code is organized into components (for auth and content areas), contexts (for managing logged-in user state), and hooks.
- Dockerfiles in both backend and frontend, along with a docker-compose.yml at the root, imply a containerized deployment architecture.
- GitHub Actions workflows (e.g., gradle.yml, node.js.yml) indicate continuous integration pipelines for both parts.

##### Main Components
a. Frontend:
- React application (components, state/context management) as a distinct module.
- Dependency on API calls to the backend.
- Use of technologies like Vite, TypeScript, and styling frameworks (e.g., CSS modules).

b. Backend:
- Layered structure:
– Controllers: REST API endpoints (Authentication, Recipes, Reviews, etc.)
– Services: Business logic (AuthenticationService, RecipeService, etc.)
– Repositories: Data access layer interfacing with the database.
– Configurations & Filters: Security (JWT Authentication, CORS, SecurityConfig) and application-level settings.
- MVC pattern used in this Java Spring Boot back end.

c. Database:
- That the “data” folder contains SQL scripts and CSV parsers that likely facilitate database setup and loading.

d. External / Infrastructure Components:
- Docker Containers: Group the backend and frontend Dockerfiles as a part of the containerized architecture.
- CI/CD: Represent GitHub Actions as a mechanism for automated builds and tests (node.js.yml & gradle.yml).

##### Relationships & Data Flow
- A data flow from the “data” parsers/scripts into the database (or an initial data loading step).

##### Additional Practical Points
- The overall goal is to present a complete picture, separating as many components as make sense given the distinct folders (backend, frontend, data) and their interdependencies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend Application (React,TypeScript,Vite)"]:::frontend
    end

    %% Backend Layer (MVC)
    subgraph "Backend Layer"
        BC["Controllers (REST_API)"]:::backend
        BS["Services (Business_Logic)"]:::backend
        BR["Repositories (Data_Access)"]:::backend
        BCONF["Configurations (Security,CORS)"]:::backend
        BF["Filters (JWT_Authentication)"]:::backend
        BE["Error_Handling"]:::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["MySQL Database"]:::database
        DP["Data_Processing (CSV_Parsers,SQL_Scripts)"]:::data
    end

    %% Deployment and CI/CD
    subgraph "Deployment & CI/CD"
        DC["Docker (Containerization)"]:::docker
        CI["CI/CD (GitHub_Actions)"]:::cicd
    end

    %% Data Flow / Interactions
    FE -->|"API_Calls"| BC
    BC -->|"Calls"| BS
    BS -->|"Uses"| BR
    BR -->|"CRUD_Operations"| DB
    BF -->|"Intercepts"| BC
    DP -->|"Initial_Data_Load"| DB
    CI -->|"Builds_Tests"| FE
    CI -->|"Builds_Tests"| BC
    DC -->|"Runs"| FE
    DC -->|"Runs"| BC

    %% Click Events for Frontend Module
    click FE "https://github.com/stevenjknaack/pantrychef/tree/main/frontend/"
    click FE "https://github.com/stevenjknaack/pantrychef/blob/main/frontend/index.html"
    click FE "https://github.com/stevenjknaack/pantrychef/blob/main/frontend/src/App.tsx"
    click FE "https://github.com/stevenjknaack/pantrychef/blob/main/frontend/src/main.tsx"
    click FE "https://github.com/stevenjknaack/pantrychef/tree/main/frontend/src/components/"

    %% Click Events for Backend Module
    click BC "https://github.com/stevenjknaack/pantrychef/tree/main/backend/src/main/java/com/pantrychef/backend/controllers/"
    click BS "https://github.com/stevenjknaack/pantrychef/tree/main/backend/src/main/java/com/pantrychef/backend/services/"
    click BR "https://github.com/stevenjknaack/pantrychef/tree/main/backend/src/main/java/com/pantrychef/backend/repositories/"
    click BCONF "https://github.com/stevenjknaack/pantrychef/tree/main/backend/src/main/java/com/pantrychef/backend/configs/"
    click BF "https://github.com/stevenjknaack/pantrychef/blob/main/backend/src/main/java/com/pantrychef/backend/filters/JWTAuthenticationFilter.java"
    click BE "https://github.com/stevenjknaack/pantrychef/tree/main/backend/src/main/java/com/pantrychef/backend/errors/"

    %% Click Events for Data Processing Module
    click DP "https://github.com/stevenjknaack/pantrychef/tree/main/data/"
    click DP "https://github.com/stevenjknaack/pantrychef/tree/main/data/csv_tables/"
    click DP "https://github.com/stevenjknaack/pantrychef/tree/main/data/sql/"
    click DP "https://github.com/stevenjknaack/pantrychef/tree/main/data/parser/"

    %% Click Events for Containerization
    click DC "https://github.com/stevenjknaack/pantrychef/tree/main/backend/Dockerfile"
    click DC "https://github.com/stevenjknaack/pantrychef/tree/main/frontend/Dockerfile"
    click DC "https://github.com/stevenjknaack/pantrychef/blob/main/docker-compose.yml"

    %% Click Events for CI/CD Pipelines
    click CI "https://github.com/stevenjknaack/pantrychef/tree/main/.github/workflows/"
    click CI "https://github.com/stevenjknaack/pantrychef/blob/main/.github/workflows/gradle.yml"
    click CI "https://github.com/stevenjknaack/pantrychef/blob/main/.github/workflows/node.js.yml"

    %% Styles
    classDef frontend fill:#c1f0f6,stroke:#333,stroke-width:2px;
    classDef backend fill:#f4cccc,stroke:#333,stroke-width:2px;
    classDef database fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef data fill:#ead1dc,stroke:#333,stroke-width:2px;
    classDef docker fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef cicd fill:#d9d2e9,stroke:#333,stroke-width:2px;
```
