# mjunhaochen/sswp-toogoodtogo architecture

> Architecture diagram of the GitHub repository mjunhaochen/sswp-toogoodtogo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mjunhaochen/sswp-toogoodtogo
- Repository: https://github.com/mjunhaochen/sswp-toogoodtogo

## Overview

TooGoodToGo is a server-side surplus-food package marketplace. Students browse packages and reserve one for pickup; canteen employees create, update, view, and delete packages. The MVC portal delegates package rules and views to the domain service, while a separate reservation API writes reservations through repositories. GraphQL offers an additional package/product query surface. The README documents student and employee capabilities; unsampled GraphQL mutation and controller details are represented only where their paths are supported by the tree.

Main entry points: [`AvansTooGoodToGo/Controllers/PackageController.cs`](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGo/Controllers/PackageController.cs) (Package workflows), [`Infrastructure/PackageEFRepository.cs`](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/PackageEFRepository.cs) (Package repository), [`Core.DomainServices/Services.Impl/PackageServiceBasic.cs`](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Core.DomainServices/Services.Impl/PackageServiceBasic.cs) (Package service), [`AvansTooGoodToGoWebApi/Controllers/PackageController.cs`](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGoWebApi/Controllers/PackageController.cs) (Reservation API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Web Portal"]
  node_mvc["MVC application<br/>[Program.cs]"]
  node_account["Accounts"]
  node_package_ui["Package workflows"]
  node_reserve_api["Reservation API"]
  node_api_host["API application<br/>[Program.cs]"]
  node_graphql_host["GraphQL application<br/>[Program.cs]"]
  node_graphql_query["GraphQL queries<br/>[Query.cs]"]
  node_graphql_mutation["GraphQL mutations<br/>[Mutation.cs]"]
  node_graphql_route["GraphQL route info<br/>[RouteController.cs]"]
  node_identity["ASP.NET Identity"]
end

subgraph group_interfaces["Service Interfaces"]
  node_package_repo["Package repository"]
  node_student_repo["Student repository"]
  node_product_repo["Product repository"]
  node_employee_repo["Employee repository"]
end

subgraph group_domain["Domain Rules"]
  node_package_service["Package service"]
  node_package_entities["Marketplace entities<br/>[Package.cs]"]
end

subgraph group_persistence["Persistence"]
  node_package_db[("Marketplace database")]
  node_identity_db[("Identity database")]
end

node_students(("Students"))
node_employees(("Canteen staff"))

node_students -->|"register or sign in"| node_account
node_students -->|"browse packages"| node_package_ui
node_employees -->|"manage packages"| node_package_ui
node_mvc -->|"hosts routes"| node_package_ui
node_mvc -->|"hosts routes"| node_account
node_account -->|"manages accounts"| node_identity
node_identity -->|"stores identities"| node_identity_db
node_package_ui -->|"requests package operations"| node_package_service
node_package_ui -->|"reads and writes packages"| node_package_repo
node_package_ui -->|"loads products"| node_product_repo
node_package_ui -->|"looks up students"| node_student_repo
node_package_service -->|"reads and changes packages"| node_package_repo
node_package_service -->|"loads selected products"| node_product_repo
node_package_service -->|"looks up staff location"| node_employee_repo
node_package_repo -->|"queries and saves"| node_package_db
node_student_repo -->|"queries"| node_package_db
node_product_repo -->|"queries"| node_package_db
node_employee_repo -->|"queries"| node_package_db
node_api_host -->|"hosts endpoint"| node_reserve_api
node_students -->|"requests reservation"| node_reserve_api
node_reserve_api -->|"loads package and assigns reservation"| node_package_repo
node_reserve_api -->|"looks up student"| node_student_repo
node_graphql_host -->|"serves queries"| node_graphql_query
node_graphql_host -->|"maps controllers"| node_graphql_route
node_graphql_host -->|"registers mutation service"| node_graphql_mutation
node_graphql_query -->|"queries packages"| node_package_repo
node_graphql_query -->|"queries products"| node_product_repo

click node_mvc "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGo/Program.cs"
click node_account "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGo/Controllers/AccountController.cs"
click node_package_ui "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGo/Controllers/PackageController.cs"
click node_reserve_api "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGoWebApi/Controllers/PackageController.cs"
click node_api_host "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGoWebApi/Program.cs"
click node_graphql_host "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/GraphQLServer/Program.cs"
click node_graphql_query "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/GraphQLServer/GraphQL/Query.cs"
click node_graphql_mutation "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/GraphQLServer/GraphQL/Mutation.cs"
click node_graphql_route "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/GraphQLServer/GraphQL/RouteController.cs"
click node_package_service "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Core.DomainServices/Services.Impl/PackageServiceBasic.cs"
click node_package_entities "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Domain/Package.cs"
click node_package_repo "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/PackageEFRepository.cs"
click node_student_repo "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/StudentEFRepository.cs"
click node_product_repo "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/ProductEFRepository.cs"
click node_employee_repo "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/CanteenEmployeeEFRepository.cs"
click node_package_db "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/PackageDbContext.cs"
click node_identity_db "https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/SecurityDbContext.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mvc,node_account,node_package_ui,node_reserve_api,node_api_host,node_graphql_host,node_graphql_query,node_graphql_mutation,node_graphql_route,node_identity toneBlue
class node_package_repo,node_student_repo,node_product_repo,node_employee_repo toneAmber
class node_package_service,node_package_entities toneMint
class node_package_db,node_identity_db toneRose
class node_students,node_employees toneIndigo
```

## Components

### Web Portal

- [MVC application](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGo/Program.cs): `AvansTooGoodToGo/Program.cs`
- [Accounts](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGo/Controllers/AccountController.cs): `AvansTooGoodToGo/Controllers/AccountController.cs`
- [Package workflows](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGo/Controllers/PackageController.cs): `AvansTooGoodToGo/Controllers/PackageController.cs`
- [Reservation API](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGoWebApi/Controllers/PackageController.cs): `AvansTooGoodToGoWebApi/Controllers/PackageController.cs`
- [API application](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/AvansTooGoodToGoWebApi/Program.cs): `AvansTooGoodToGoWebApi/Program.cs`
- [GraphQL application](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/GraphQLServer/Program.cs): `GraphQLServer/Program.cs`
- [GraphQL queries](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/GraphQLServer/GraphQL/Query.cs): `GraphQLServer/GraphQL/Query.cs`
- [GraphQL mutations](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/GraphQLServer/GraphQL/Mutation.cs): `GraphQLServer/GraphQL/Mutation.cs`
- [GraphQL route info](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/GraphQLServer/GraphQL/RouteController.cs): `GraphQLServer/GraphQL/RouteController.cs`
- **ASP.NET Identity**

### Service Interfaces

- [Package repository](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/PackageEFRepository.cs): `Infrastructure/PackageEFRepository.cs`
- [Student repository](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/StudentEFRepository.cs): `Infrastructure/StudentEFRepository.cs`
- [Product repository](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/ProductEFRepository.cs): `Infrastructure/ProductEFRepository.cs`
- [Employee repository](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/CanteenEmployeeEFRepository.cs): `Infrastructure/CanteenEmployeeEFRepository.cs`

### Domain Rules

- [Package service](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Core.DomainServices/Services.Impl/PackageServiceBasic.cs): `Core.DomainServices/Services.Impl/PackageServiceBasic.cs`
- [Marketplace entities](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Domain/Package.cs): `Domain/Package.cs`

### Persistence

- [Marketplace database](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/PackageDbContext.cs): `Infrastructure/PackageDbContext.cs`
- [Identity database](https://github.com/mjunhaochen/sswp-toogoodtogo/blob/main/Infrastructure/SecurityDbContext.cs): `Infrastructure/SecurityDbContext.cs`

### Other components

- **Students**
- **Canteen staff**

## Connections

- Students → Accounts: register or sign in
- Students → Package workflows: browse packages
- Canteen staff → Package workflows: manage packages
- MVC application → Package workflows: hosts routes
- MVC application → Accounts: hosts routes
- Accounts → ASP.NET Identity: manages accounts
- ASP.NET Identity → Identity database: stores identities
- Package workflows → Package service: requests package operations
- Package workflows → Package repository: reads and writes packages
- Package workflows → Product repository: loads products
- Package workflows → Student repository: looks up students
- Package service → Package repository: reads and changes packages
- Package service → Product repository: loads selected products
- Package service → Employee repository: looks up staff location
- Package repository → Marketplace database: queries and saves
- Student repository → Marketplace database: queries
- Product repository → Marketplace database: queries
- Employee repository → Marketplace database: queries
- API application → Reservation API: hosts endpoint
- Students → Reservation API: requests reservation
- Reservation API → Package repository: loads package and assigns reservation
- Reservation API → Student repository: looks up student
- GraphQL application → GraphQL queries: serves queries
- GraphQL application → GraphQL route info: maps controllers
- GraphQL application → GraphQL mutations: registers mutation service
- GraphQL queries → Package repository: queries packages
- GraphQL queries → Product repository: queries products
