Skip to content

notnami/TermProject3110

Repository files navigation

Snack Finder

Snack Finder is a web application that helps users with dietary restrictions find snacks that fit their needs. Users can search for snacks, filter by allergens, view full ingredient lists, and save their favorite snacks. The project uses ASP.NET Core MVC and pulls additional snack data from the OpenFoodFacts API.

Table of Contents

  • Features
  • Getting Started
  • Installation and Running Locally
  • Architecture and Project Structure
  • API Endpoints
  • User Stories
  • Story Flows
  • Future Work
  • Contributing
  • License

Features

  • Browse snacks from both OpenFoodFacts and snacks added by users.
  • Filter snacks by allergens such as gluten, peanuts, or dairy.
  • Search for snacks by name or keyword.
  • View full ingredient lists and allergen information for each snack.
  • Create an account, log in, and save snacks to a favorites list.
  • Favorites stay saved across sessions once the user logs in.

Getting Started

To run the project locally, use one of the following commands:

dotnet run --no-build --urls=http://localhost:5171

dotnet run --no-build --urls=http://localhost:5170

After running the command, open your browser and go to this URL.

Installation and Running Locally

  1. Clone the project:

git clone https://github.com/notnami/TermProject3110.git

cd TermProject3110

  1. Make sure you have a compatible version of .NET installed.

  2. If you want to seed your own snack data, set up the database with Entity Framework Core. You can either import a CSV of snacks and ingredients or fetch sample data from the OpenFoodFacts API.

  3. Run the application using one of the startup commands listed above.

Architecture and Project Structure

This project is built using ASP.NET Core MVC with an additional REST API layer.

Controllers/ MVC and API controllers for snacks, favorites, and accounts Services/ Business logic and data access Data/ Database context and Entity Framework configuration Models/ Data models such as Snack, User, and Favorite ViewModels/ Data passed to views Views/ Razor views for search, details, favorites, login, etc. wwwroot/ Static files including CSS and JavaScript Program.cs Entry point for the application

The MVC controllers generate the main pages of the site. The separate API layer handles JSON responses for filtering, searching, and managing favorites, which can be used with AJAX or fetch requests.

API Endpoints

GET /api/snacks?allergen=
Returns snacks that do not contain the specified allergen.

GET /api/snacks/{id}
Returns full ingredient and allergen information for a single snack.

POST /api/favorites
Adds a snack to the current user's favorites list.

DELETE /api/favorites/{id}
Removes a snack from the user's favorites.

User Stories

  1. Users can search for snacks by name or keyword.
  2. Users can filter snacks by allergen to avoid specific ingredients.
  3. Users can view complete ingredient lists and allergen details.
  4. Logged in users can save snacks to a favorites list.
  5. Users can register and log in to access their saved snacks.

Story Flows

Search Snacks

The user types a keyword such as "granola" into the search bar. Matching snacks appear along with their allergen information. Clicking a snack opens its details page.

Filter by Allergen

The user selects one or more allergens to exclude. The snack list updates based on the selected filters. The user can clear all filters at any time.

View Snack Details

Clicking on a snack opens a detail page that lists ingredients and highlights allergens. If some information is missing, a message appears along with a link to the product on OpenFoodFacts.

Save to Favorites

If the user is logged in, clicking "Save to Favorites" adds the snack to their saved list. If they are not logged in, they are prompted to log in first. The favorites page shows all saved snacks and allows removal.

Register or Log In

Users can create an account or sign in with an existing one. Once logged in, favorites are saved to their account and persist across sessions. Logging out ends the session.

Future Work

  • Seed a more complete snack database using CSV files or more extensive API imports.
  • Improve client side interactivity with AJAX based filtering and searching.
  • Enhance the design with Bootstrap or Tailwind and improve accessibility.
  • Add optional features such as nutrition information, user submitted snacks, pagination, and better error handling.

Contributing

If you want to contribute:

  1. Fork the repository.
  2. Create a feature branch.
  3. Commit your changes.
  4. Push the branch and submit a pull request.

AI Disclosure

During this assignment I used Google AI, to help me better understand certain packages that I was installing to be used in my projects. I also used chatgpt for two main reasons, one was when I ran into trouble with my project taking long times to load and I wanted to figure out why. Turns out I had installed some very large packages that my program was not using which was increasing load times and I also had two “termproject.db” in my project. This helped me to get my project finally running, I also used it to help me with any potential spelling errors and formatting of my ReadMe.md doc.

About

Project for CSCI 3110: Snack Finder

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published