# thebigby10/flavourai architecture

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

- Interactive diagram: https://gitdiagram.com/thebigby10/flavourai
- Repository: https://github.com/thebigby10/flavourai

## Overview

##### Project Type and Purpose
- This is a standalone, AI‐powered terminal application written in Java.
- Purpose: profile user tastes, generate recipes, predict flavour pairings, and chat interactively using AI.

##### File Structure
Top‐level modules under src/ represent logical layers:
– App.java: application entry point and orchestration
– MainMenu (MainMenuUI.java): CLI menu routing
– Chatbot (ChatbotUI.java): interactive chat interface
– AiRecipe (AiRecipe.java, DisplayCategory.java): recipe‐generation module
– TasteProfiling (TasteProfiling.java, AddRecipe.java, RateRecipe.java, ViewProfile.java, Recipe.java): user profiling logic
– UserManager (LoginSystem.java, RegistrationSystem.java, LoginUI.java, UserInfo.java): authentication & user model
– DatabaseManager (DatabaseManager.java): data persistence layer

##### Readme Insights
- Core features: taste profiling, AI recipe generation, pairing prediction, ingredient replacement, chemistry explainer, interactive chat.
- External AI/ML “engine” is implied behind recipe generator and chatbot.
- Data evolves as user rates recipes.

a. Main Components
1) Entry Point: App
2) Presentation Layer (CLI UIs):
- MainMenuUI
- ChatbotUI
- LoginUI
3) Application Layer (Controllers/Services):
- UserManager services (LoginSystem, RegistrationSystem)
- TasteProfiling service
- AiRecipe generator service
- Flavour Pairing & Ingredient Replacement logic (within AiRecipe)
4) Data Layer:
- DatabaseManager (handles CRUD via JDBC or embedded DB)
- Data Models (Recipe, UserInfo)
5) External AI/ML Engine (could be an in‐process library or a REST API)

b. Relationships & Interactions
- App invokes MainMenuUI on startup → user selects action.
- MainMenuUI → calls corresponding service:
– Login/Registration → UserManager → DatabaseManager → DB
– Profile operations → TasteProfiling → DatabaseManager → DB
– Recipe generation → AiRecipe → (calls) AI Engine → DatabaseManager → DB
– Chat → ChatbotUI → Chatbot backend → (calls) AI Engine
- Data flows: UI → Service → Database → Service → UI.
- AI Engine calls are “external service” interactions.

c. Architectural Patterns & Principles
- MVC‐style separation:
– View: CLI UIs
– Controller/Service: business logic modules
– Model: domain objects & persistence
- Single Responsibility: each package handles distinct concern.
- Dependency Injection (if used), or simple factory instantiation in App.

d. Technologies & Frameworks
- Language: Java
- Persistence: JDBC or embedded SQLite/H2 via DatabaseManager
- AI/ML: custom in‐process libraries or external REST‐based ML service
- Build: assumed Maven/Gradle (not shown but typical in Java)

##### Detailed Element Checklist
- App (entry) → MainMenuUI
- MainMenuUI → {LoginUI, ChatbotUI, TasteProfiling, AiRecipe}
- Each UI → its service/controller
- Services → DatabaseManager → Database
- AiRecipe/Chatbot → AI Engine
- Data models (Recipe, UserInfo) tied to Database tables

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entry Point
    App["App"]:::service
    App --> MainMenuUI

    subgraph "Presentation Layer"
        MainMenuUI["MainMenuUI"]:::ui
        ChatbotUI["ChatbotUI"]:::ui
        LoginUI["LoginUI"]:::ui
    end

    subgraph "Application Layer"
        LoginSystem["LoginSystem"]:::service
        RegistrationSystem["RegistrationSystem"]:::service
        TasteProfiling["TasteProfiling"]:::service
        AddRecipe["AddRecipe"]:::service
        RateRecipe["RateRecipe"]:::service
        ViewProfile["ViewProfile"]:::service
        AiRecipe["AiRecipe"]:::service
        DisplayCategory["DisplayCategory"]:::service
    end

    subgraph "Data Layer"
        DatabaseManager["DatabaseManager"]:::dbManager
        Recipe["Recipe"]:::model
        UserInfo["UserInfo"]:::model
        Database[(Database)]:::database
    end

    subgraph "External Services"
        AIEngine{{"AI Engine"}}:::external
    end

    %% Presentation -> Application
    MainMenuUI --> LoginUI
    MainMenuUI --> ChatbotUI
    MainMenuUI --> TasteProfiling
    MainMenuUI --> AiRecipe

    LoginUI --> LoginSystem
    LoginUI --> RegistrationSystem
    ChatbotUI -.->|"async chat"| AIEngine

    %% Application -> Data & External
    LoginSystem --> DatabaseManager
    RegistrationSystem --> DatabaseManager

    TasteProfiling --> AddRecipe
    TasteProfiling --> RateRecipe
    TasteProfiling --> ViewProfile
    TasteProfiling --> DatabaseManager

    AddRecipe --> DatabaseManager
    RateRecipe --> DatabaseManager
    ViewProfile --> DatabaseManager

    AiRecipe --> DisplayCategory
    AiRecipe --> DatabaseManager
    AiRecipe -.->|"async call"| AIEngine

    DisplayCategory --> DatabaseManager

    %% Data Layer flows
    DatabaseManager --> Recipe
    DatabaseManager --> UserInfo
    DatabaseManager --> Database

    %% Click Events
    click App "https://github.com/thebigby10/flavourai/blob/main/src/App.java"
    click MainMenuUI "https://github.com/thebigby10/flavourai/blob/main/src/MainMenu/MainMenuUI.java"
    click ChatbotUI "https://github.com/thebigby10/flavourai/blob/main/src/Chatbot/ChatbotUI.java"
    click LoginUI "https://github.com/thebigby10/flavourai/blob/main/src/UserManager/LoginUI.java"
    click LoginSystem "https://github.com/thebigby10/flavourai/blob/main/src/UserManager/LoginSystem.java"
    click RegistrationSystem "https://github.com/thebigby10/flavourai/blob/main/src/UserManager/RegistrationSystem.java"
    click TasteProfiling "https://github.com/thebigby10/flavourai/blob/main/src/TasteProfiling/TasteProfiling.java"
    click AddRecipe "https://github.com/thebigby10/flavourai/blob/main/src/TasteProfiling/AddRecipe/AddRecipe.java"
    click RateRecipe "https://github.com/thebigby10/flavourai/blob/main/src/TasteProfiling/RateRecipe/RateRecipe.java"
    click ViewProfile "https://github.com/thebigby10/flavourai/blob/main/src/TasteProfiling/ViewProfile/ViewProfile.java"
    click AiRecipe "https://github.com/thebigby10/flavourai/blob/main/src/AiRecipe/AiRecipe.java"
    click DisplayCategory "https://github.com/thebigby10/flavourai/blob/main/src/AiRecipe/BrowseByCategory/DisplayCategory.java"
    click DatabaseManager "https://github.com/thebigby10/flavourai/blob/main/src/DatabaseManager/DatabaseManager.java"
    click Recipe "https://github.com/thebigby10/flavourai/blob/main/src/TasteProfiling/Recipe.java"
    click UserInfo "https://github.com/thebigby10/flavourai/blob/main/src/UserManager/UserInfo.java"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#90EE90,stroke:#333,stroke-width:1px
    classDef dbManager fill:#FFA500,stroke:#333,stroke-width:1px
    classDef database fill:#FF8C00,stroke:#333,stroke-width:1px
    classDef model fill:#FFD700,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
