-
Notifications
You must be signed in to change notification settings - Fork 0
Class Diagrams
Onur edited this page Mar 19, 2025
·
21 revisions
classDiagram
namespace User-Types {
class User {
- username: String
- passwordHash: String
- email: String
- fullName: String
- dateOfBirth: Date
- profilePicture: String
- bio: String
- createdAt: Date
- isActive: Boolean
- userAllergies: List~Allergen~
- customAllergens: List~String~
- shoppingList: List~String~
- inventory: List~String~
- likedPosts: List~String~
- likedRecipes: List~String~
- professionTags: List~String~
- certificates: List~String~
- ownedStores: List~Store~
+ register(username: String, email: String, password: String): Boolean
+ login(username: String, password: String): Boolean
+ logout(): void
+ updateProfile(fullName: String, bio: String, profilePicture: String): void
+ changePassword(oldPassword: String, newPassword: String): Boolean
+ deleteAccount(): Boolean
+ addAllergen(allergen: Allergen): void
+ removeAllergen(allergen: Allergen): void
+ addCustomAllergen(allergen: String): void
+ removeCustomAllergen(allergen: String): void
+ addToShoppingList(item: String): void
+ removeFromShoppingList(item: String): void
+ addToInventory(item: String): void
+ removeFromInventory(item: String): void
+ likePost(postId: String): void
+ unlikePost(postId: String): void
+ likeRecipe(recipeId: String): void
+ unlikeRecipe(recipeId: String): void
+ addProfessionTag(tag: String): void
+ removeProfessionTag(tag: String): void
+ uploadCertificate(certificate: String): void
+ reportUser(userId: String, reason: String): void
+ createStore(name: String, location: String, description: String, imageURL: String): void
+ getStore(storeID: int): Store
+ deleteStore(storeID: int): void
+ assignItemToStore(item: String, storeID: int): void
+ unassignItemFromStore(item: String, storeID: int): void
}
class Moderator {
- moderatorId: String
- assignedSections: List~String~
+ removePost(postId: String): Boolean
+ warnUser(userId: String, reason: String): void
+ banUser(userId: String, duration: Int): Boolean
+ reviewReports(): List~Report~
}
class ModerationHistory {
- historyId: String
- moderatorId: String
- reportedUserId: String
- reportReason: String
- actionTaken: String
- timestamp: Date
}
class Report {
- reportId: String
- postId: String
- reportingUserId: String
- reportedReason: String
- timestamp: Date
}
class Allergen {
<<enumeration>>
Gluten
Lactose
Peanuts
Soy
Shellfish
Eggs
TreeNuts
Sesame
Fish
Sulfites
ArtificialColorants
Preservatives
}
}
namespace Forum-Objects{
%% Forum and Post classes for Affordable & Healthy Eating Hub
class Forum {
- posts : List~Post~
+ addPost(post : Post) : void
+ removePost(post : Post) : void
+ getPosts() : List~Post~
+ filterPostsByTag(tag : String) : List~Post~
+ sortPostsByRating() : List~Post~
}
class Post {
- postId : int
- content : String
- tags : List~String~
- postType : String "e.g., Recipe, Nutrition Tip, Meal Plan"
- creationDate : Date
- likes : List~int~ "User IDs who liked the post"
- comments : List~Comment~
- rating : double "Aggregated rating based on interactions"
+ editTags(newTags : List~String~) : void
+ like(userId : int) : void
+ unlike(userId : int) : void
+ addComment(comment : Comment) : void
+ share() : String
+ report(reason : String) : void
}
class Comment {
- commentId : int
- userId : int
- content : String
- creationDate : Date
}
}
%% User
User <|-- Moderator
User "1" *-- "*" Allergen : has
Moderator "1" *-- "*" ModerationHistory
Moderator "1" *-- "*" Report
Report "1" --> "1" Post
%% Forum
Forum "1" --> "*" Post : contains
Post "1" --> "*" Comment : has
classDiagram
namespace Food-Catalog-Objects {
class FoodEntry {
-String name
-String category
-float servingSize
-float caloriesPerServing
-float proteinContent
-float fatContent
-float carbohydrateContent
-Set~String~ allergens
-Set~String~ dietaryOptions
-float nutritionScore
-String imageUrl
+FoodEntry(String name, String category)
+FoodEntry(String name, String category, float servingSize, float calories, float protein, float fat, float carbs)
+float calculateNutritionScore()
+void updateNutritionalInfo(float calories, float protein, float fat, float carbs)
+void updateServingSize(float servingSize)
+void addAllergen(String allergen)
+void removeAllergen(String allergen)
+void addDietaryOption(String option)
+void removeDietaryOption(String option)
+boolean isDietCompatible(String dietType)
+Set~String~ getAllCompatibleDiets()
+boolean isAllergenFree(String allergen)
+boolean isAllergenFree(Set~String~ allergens)
+Map~String, Object~ getFullDetails()
}
class FoodCatalog {
-List~FoodEntry~ foodItems
-Map categorizedItems
+void addFoodItem(FoodEntry item)
+void removeFoodItem(FoodEntry item)
+List~FoodEntry~ searchByName(String nameQuery)
+List~FoodEntry~ filterByNutritionScore(float minScore)
+List~FoodEntry~ filterByDietaryOption(String option)
+List~FoodEntry~ filterByAllergenFree(Set~String~ allergens)
+List~FoodEntry~ filterByCategory(String category)
+FoodEntry getFoodItemById(String id)
+List~FoodEntry~ getAllFoodItems()
}
}
%% Food Catalog
FoodCatalog "1" o-- "many" FoodEntry : contains >
classDiagram
class User {
- username: String
- passwordHash: String
- email: String
- fullName: String
- dateOfBirth: Date
- profilePicture: String
- bio: String
- createdAt: Date
- isActive: Boolean
- userAllergies: List~Allergen~
- customAllergens: List~String~
- shoppingList: List~String~
- inventory: List~String~
- likedPosts: List~String~
- likedRecipes: List~String~
- professionTags: List~String~
- certificates: List~String~
- ownedStores: List~Store~
+ register(username: String, email: String, password: String): Boolean
+ login(username: String, password: String): Boolean
+ logout(): void
+ updateProfile(fullName: String, bio: String, profilePicture: String): void
+ changePassword(oldPassword: String, newPassword: String): Boolean
+ deleteAccount(): Boolean
+ addAllergen(allergen: Allergen): void
+ removeAllergen(allergen: Allergen): void
+ addCustomAllergen(allergen: String): void
+ removeCustomAllergen(allergen: String): void
+ addToShoppingList(item: String): void
+ removeFromShoppingList(item: String): void
+ addToInventory(item: String): void
+ removeFromInventory(item: String): void
+ likePost(postId: String): void
+ unlikePost(postId: String): void
+ likeRecipe(recipeId: String): void
+ unlikeRecipe(recipeId: String): void
+ addProfessionTag(tag: String): void
+ removeProfessionTag(tag: String): void
+ uploadCertificate(certificate: String): void
+ reportUser(userId: String, reason: String): void
+ createStore(name: String, location: String, description: String, imageURL: String): void
+ getStore(storeID: int): Store
+ deleteStore(storeID: int): void
+ assignItemToStore(item: String, storeID: int): void
+ unassignItemFromStore(item: String, storeID: int): void
}
class Store {
-storeID: Integer
-storeName: String
-storeOwnerID: Integer
-description: String
-location: String
-contactInfo: String
-marketListings: List~MarketListing~
+addListing(listing: MarketListing) void
+removeListing(listingID: Integer) void
+getListings() List~MarketListing~
+getListingByID(listingID: Integer) MarketListing
+searchListings(query String) List~MarketListing~
+updateDescription(description: String) void
+updateContactInfo(contactInfo: String) void
}
class MarketListing {
-marketListingID: String
-foodEntryID: Integer
-storeID: Integer
-price: Double
-stockQuantity: Integer
-description: String
-imageURL: String
-createdAt: Date
-lastModifiedAt: Date
+updateStock(quantity: Integer) void
+updatePrice(price: Double) void
+updateDescription(description: String) void
+updateImage(imageURL: String) void
}
class Market {
-marketListings: List~MarketListing~
+getAllListings() List~MarketListing~
+getListingByID(listingID: Integer) MarketListing
+searchListings(query String) List~MarketListing~
+filterListingsByPrice(maxPrice: Double) List~MarketListing~
+filterListingsByNutritionScore(minScore: float, maxScore: float) List~MarketListing~
+filterListingsByStoreRating(minScore: float, maxScore: float) List~MarketListing~
+filterListingsByDietaryOption(option: Set~DietaryOption~) List~MarketListing~
+filterListingsByAllergens(allergens: Set~Allergen~ ) List~MarketListing~
}
User "1" *-- "*" Store : owns
Store "1" *-- "*" MarketListing : contains
Market ..> MarketListing : dependency
classDiagram
namespace Recipe-Objects{
class RecipeList {
-recipes: List<Recipe>
+RecipeList()
+void addRecipe(Recipe recipe)
+void removeRecipe(Integer recipeID)
+Recipe findRecipe(String name)
+void sortRecipesByPostDate()
+void sortRecipesByCost()
+void sortRecipesByNutritionScore()
+void filterRecipesAllergens(String allergen)
+void filterRecipesDietaryOptions(String dietaryOption)
+void sortRecipesByCostToNutritionScoreRatio()
+void listAllRecipes()
}
class Recipe {
-recipeID: Integer
-postDate: Date
-name: String
-ingredients: List<(FoodEntry,Amount)>
-instructions: List<String>
-servingSize: int
-prepTime: int
-cookTime: int
-totalTime: int
-nutritionScore: float
-totalFatContent: float
-totalProteinContent: float
-totalCarbonhydrateContent: float
-allergens: List<String>
-dietaryOptions: List<String>
-totalCalorie: int
-imageUrl: String
-videoUrl: String
+Recipe(Integer recipeID, String name, List<(FoodEntry,Amount)> ingredients, String instructions, int prepTime, int cookTime, String imageUrl, String videoUrl)
+int calculateTotalTime()
+float calculateCost()
+float calculateCostToNutritionRatio()
+float calculateTotalFatContent()
+float calculateTotalProteinContent()
+float calculateTotalCarbonhydrateContent()
+void changeServingSize()
+List<String> getAllergens()
+List<String> getDietaryOptions()
+void changeMeasurementUnit()
+void removeIngredient()
+void addIngredient()
+void displayRecipe()
}
}
namespace Meal-Plan-Objects{
class MealPlan {
-mealPlanID: Integer
-name: String
-userId: Integer
-budgetAmount: float
-budgetDuration: Frequency
-dietarOptions: DietaryOption[]
-meals: MealSchedule[]
-isPublic: boolean
-isSaved: boolean
+MealPlan(Integer mealPlanID, String name, Integer userID, Frequency budgetDuration)
+void addAllergy(Allergen allergen)
+void removeAllergy(Allergen allergen)
+void addDietaryOption(DietaryOption option)
+void removeDietaryOption(DietaryOption option)
+void generatePlan()
+status saveToCollection()
+void shareAsPost()
+NutritionalSummary calculateNutritionalSummary()
+float calculateTotalCost()
}
class Frequency {
<<enumeration>>
WEEKLY
MONTHLY
}
class WeekDay {
<<enumeration>>
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY
SUNDAY
}
class DietaryOption {
<<enumeration>>
VEGAN
VEGETARIAN
CELIAC
}
class Allergen {
<<enumeration>>
Gluten
Lactose
Peanuts
Soy
Shellfish
Eggs
TreeNuts
Sesame
Fish
Sulfites
ArtificialColorants
Preservatives
}
class Meal {
-mealID : Integer
-name : String
-recipe : Recipe
-cost: float
-nutritionScore : float
+Meal(Integer mealID, String name, Recipe recipe)
+float calculateCost()
+float calulateNutritionScore()
}
class MealSchedule {
-meals : Meal[]
-days : WeekDays[]
+MealSchedule(Meal[] meals, WeekDays[] days)
}
}
%% Recipe
Meal "*" o-- "1" Recipe : references
RecipeList "1" *-- "*" Recipe: contains
%% Meal Plan
MealPlan "1" *-- "*" MealSchedule : contains
MealPlan "1" o-- "*" DietaryOption :
MealPlan "1" o-- "many" Allergen :
MealPlan "1" o-- "1" Frequency :
MealSchedule "*" o-- "*" WeekDay
MealSchedule "*" o-- "*" Meal


-
Use Cases:
- Template
- Scenario 1: Community Sharing
- Scenario 2: For a Dietitian
- Scenario 3: Maintaining a Personal Inventory (as a Producer)
- Scenario 4: Proposing a Product and Adding a Recipe to Weekly Meal Plan
- Scenario 5: Creating a Meal Plan
- Scenario 6: Resetting Password
- Scenario 7: Moderator Actions
- Scenario 8: Searching for and Proposing a New Food Item
- Scenario 9: Budget-Conscious Grocery Shopping
- Scenario 10: Creating a New Store
- Scenario 11: User Profile Management
- Git: In a Nutshell
- Example GitHub Repositories
- System Modeling & UML
- Frontend Tutorial
- Frontend Roadmap
- Frontend Styling Guide
- Docker Summary
- Writing Endpoints
- Yusuf AKIN
- Arda SAYGAN
- Fatih Furkan Bilsel
- Berk GOKTAS
- Berkay BILEN
- Yusuf Anıl YAZICI
- Taha Topaloglu
- Nuri Basar
- Onur Kucuk
- Hasancan Keles
- Mete Damar