Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ http://it2810-03.idi.ntnu.no/project2/

## Core features

- **Plant Match:** The user swipes the card right to match with a plant and left to skip it, or uses the ♥ and ✖ buttons. Plants matching the most preferences come first, otherwise the order is random. This is to make it easier for the user to find plants they are compatible with. When plants are matched on Plant Match or Explore Plants, a badge on My Matches in the sidebar shows how many plants have been matched since the page was last opened, to make it easier to understand where the matches end up.
- **Plant Match:** The start page and the heart of the app. Instead of choosing from a long list, the user decides on one plant at a time by swiping right (♥) to match or left (✖) to skip, which makes finding plants quick and fun. The plants that fit the user's preferences best are shown first, so the user meets the plants they are most compatible with early. A badge on "My Matches" in the sidebar shows how many new matches the user has, so it is clear where the matches end up.

- **My Matches:** Collects the plants the user has liked (♥) on Plant Match and Explore Plants, and lets them search, filter and sort among them, with a count of how many matches they have.
- **My Matches:** One place for all the plants the user likes, whether they were matched on Plant Match or Explore Plants. It works as a personal collection the user can come back to, and search, filter and sort when it grows.

- **Explore Plants:** The page where the user can find specific plants they are searching for without having matched with them. Search, filtering and sorting are possible. The state is kept in the URL, so a view survives a refresh and the user can share the page as a link.
- **Explore Plants:** For users who already know what they are looking for. Instead of matching, they can search, filter and sort the whole catalogue directly. The view is kept in the URL, so it survives a refresh and can be shared as a link.

- **Plant Owner Test:** A short test (four questions) to give the user insight into what kind of plant owner they are. It is meant to help them set one preference each for watering, light and care level, based on the answers and the description of the type. It also gives an avatar that can be used as a profile picture that can only be achieved through the test to communicate the type of plant owner the user is.
- **Plant Owner Test:** For users who do not know their preferences yet. A short test tells them what kind of plant owner they are, and suggests preferences for watering, light and care level based on the answers. The result also gives an avatar that can only be earned through the test, so the user can show their plant owner type as their profile picture.

- **Walkthrough:** A short guide opens on the first visit and explains what the user can do on each page. It can be reopened at any time with the ? button. It is meant to help with any confusion connected to how the application works, and help the user to get started.
- **Walkthrough:** A short guide that opens on the first visit and explains what each page is for, so new users can get started without confusion. It can be reopened at any time with the ? button.

- **Profile:** Lets the user make the app their own, with a name, description, avatar and plant preferences. The profile is also a starting point if the app is made more community-based later.

## Tech stack

Expand Down Expand Up @@ -153,7 +155,7 @@ npm run test:e2e

| Part | Statements | Branches | Functions | Lines |
| -------- | ---------- | -------- | --------- | ------- |
| Frontend | 97.44 % | 93.78 % | 96.83 % | 98.43 % |
| Frontend | 97.45 % | 93.82 % | 96.83 % | 98.43 % |
| Backend | 100 % | 100 % | 100 % | 100 % |

See [tests.md](docs/tests.md) for the test strategy, more ways to run the tests, how to run the tests with coverage and screenshots of the coverage reports, what the test files cover and what the tests found.
Expand Down
6 changes: 3 additions & 3 deletions docs/ai-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The mock-up was mostly used as a reference for us, not as context for the other

### Working across three tools

The three tools were used for different things. Copilot was used in the editor for small suggestions while we wrote code, and it only saw the files that were open. Claude and ChatGPT were used in a chat or in the terminal for bigger tasks, such as explaining a concept, writing tests or refactoring a file.
The three ai-coding tools were used for different things. Copilot was used in the editor for small suggestions while we wrote code, and it only saw the files that were open. Claude and ChatGPT were used in a chat or in the terminal for bigger tasks, such as explaining a concept, writing tests or refactoring a file.

For most of the project we did not have a shared setup for AI. Each of us gave the tools context ourselves, by pasting in the relevant files, the issue we worked on, error messages or parts of the README and the architecture document. We found that the answers got much better when we gave the tool the code it should build on and told it what not to change. Short and specific prompts worked better than asking for a whole feature at once.

Expand Down Expand Up @@ -74,11 +74,11 @@ AI saved us a lot of time on work that is repetitive or follows a known pattern,

### Learning

The biggest risk for us was that AI could do the work we were supposed to learn from. It is easy to accept code that works without understanding why it works, and then you have not learned anything, and you can not explain or fix the code later. It also became clear in the reviews: if the person who made the pull request could not explain the code, the reviewer could not trust it either. We tried to use AI to explain things rather than only to write them, and the rule was that you should be able to explain all code you made a pull request for. We still think we learned less about some parts, such as the configuration of Vite and Vitest, than we would have done without AI, since we mostly used the setup AI suggested.
The biggest risk for us was that AI could do the work we were supposed to learn from. It is easy to accept code that works without understanding why it works, and then you have not learned anything, and you cannot explain or fix the code later. It also became clear in the reviews: if the person who made the pull request could not explain the code, the reviewer could not trust it either. We tried to use AI to explain things rather than only to write them, and the rule was that you should be able to explain all code you made a pull request for. We still think we learned less about some parts, such as the configuration of Vite and Vitest, than we would have done without AI, since we mostly used the setup AI suggested.

### Copyright and data

AI models are trained on code and pictures made by other people, often without them having agreed to it, and it is not always clear who owns what the model makes. For code this was a small problem for us, since most of the code follows common patterns, and all of it was reviewed and changed by us. The pictures are more uncertain. The avatars and the placeholder picture are made with AI, and we can not know how much they are based on the work of real artists. If the app was to be used for real, we would think about using pictures made by a person or with a clear license instead. The plant data and images come from the Perenual API, and not from AI.
AI models are trained on code and pictures made by other people, often without them having agreed to it, and it is not always clear who owns what the model makes. For code this was a small problem for us, since most of the code follows common patterns, and all of it was reviewed and changed by us. The pictures are more uncertain. The avatars and the placeholder picture are made with AI, and we cannot know how much they are based on the work of real artists. If the app was to be published and used publicly, we would think about using pictures made by a person or with a clear license instead. The plant data and images come from the Perenual API, and not from AI.

We also had to think about what we gave the tools. We never pasted secrets, such as the `.env` file or passwords to the VM, into an AI tool, since we do not control what happens with the data afterwards.

Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ The frontend is built with React and TypeScript (Vite).

- **User state:** `UserProvider` (`context/UserContext.tsx`) loads the current user from the backend and makes it available through `useUser()`. The hooks `useProfile`, `usePreferences` and `useMatchedPlants` wrap the user mutations, so pages do not call GraphQL directly for user data. The user queries and mutations themselves live in `graphql/user/` (see [GraphQL operations](#graphql-operations-in-the-frontend)).
- **Error messages:** `ErrorMessageProvider` (`context/ErrorMessageContext.tsx`) wraps the app and makes `showError()` available through `useErrorMessage()`. `useMatchedPlants` uses it to show an error message when adding or removing a match fails.
- **Reusable logic in hooks:** Logic without UI is kept in hooks. `useDebounce` delays updates while the user is typing (used for search and for saving the profile text). `useExploreParams` keeps the Explore search, filters, sort order and page in the URL, and sends the user back to page 1 when the search, a filter or the sort order changes. It uses `useUrlParams`, which reads the page number and updates the URL (with React Router's `useSearchParams`). `useMyMatchesParams` does the same for My Matches, but keeps the search, filters and sort order in `sessionStorage` with `useSessionState`, since the matches belong to the user in this browser and a link to them could not be shared. `usePageCursor` remembers the cursor that leads to the next or previous page on both pages, and only uses it for the exact search, filters and sort order it came from (see [Scalability](#design-choices-made-for-scalability)). `usePreferences` saves the preferences, both on the profile page and after the plant owner test. `useNewMatches` counts the plants matched since My Matches was last opened, which the sidebar shows as a badge on the My Matches link (with a text for screen readers). The matches the user already has when the app opens count as seen, so only the user id has to be kept in the browser. A plant that is removed from the matches is no longer seen, so it counts as new if it is matched again. `useDismissibleTooltip` lets the "i" help texts be hidden with Escape.
- **Reusable logic in hooks:** Logic without UI is kept in hooks. `useDebounce` delays updates while the user is typing (used for search and for saving the profile text). `useExploreParams` keeps the Explore search, filters, sort order and page in the URL, and sends the user back to page 1 when the search, a filter or the sort order changes. It uses `useUrlParams`, which reads the page number and updates the URL (with React Router's `useSearchParams`). `useMyMatchesParams` does the same for My Matches, but keeps the search, filters and sort order in `sessionStorage` with `useSessionState`, since the matches belong to the user in this browser and a link to them could not be shared. `usePageCursor` remembers the cursor that leads to the next or previous page on both pages, and only uses it for the exact search, filters and sort order it came from (see [Scalability](#design-choices-made-for-scalability)). `usePreferences` saves the preferences, both on the profile page and after the plant owner test. `useNewMatches` counts the plants matched since My Matches was last opened, which the sidebar shows as a badge on the My Matches link (with a text for screen readers). On mobile, where the sidebar is hidden, the menu button shows the same count, and says it in its accessible name. The matches the user already has when the app opens count as seen, so only the user id has to be kept in the browser. A plant that is removed from the matches is no longer seen, so it counts as new if it is matched again. `useDismissibleTooltip` lets the "i" help texts be hidden with Escape.
- `usePlantDeck` fetches the Plant Match cards in batches of 8 (`getPlants`), and fetches the next batch when 3 or fewer cards are left. Each request sends the ids of the plants already fetched into the deck and the plants the user has already matched as `excludeIds`, so no plant is shown twice and plants in My Matches are never shown. A plant that is matched on another page while it is in the deck is skipped. The remaining cards are kept in `sessionStorage` while the user visits another page. It sends the saved preferences with each batch, and changing the preferences clears the current deck and fetches a new first batch so the order reflects the new preferences. Stale responses from the previous deck are ignored. When the deck is empty, the user can start it over with the Reload button, and if every plant is matched, the end card says so and links to My Matches instead.
- **Swiping on Plant Match:** `PlantMatchPage` follows the card with Pointer Events, so the same code handles mouse, finger and pen. The match is saved before the card flies off, so it is not lost if the user leaves the page during the animation. The ♥ and ✖ buttons do the same as a swipe.
- **Reusable components:** Shared UI is kept in `components/`. `Pagination` shows previous/next and numbered pages, `PlantSearchForm` is the search field, filters, sort menu and reset button used on both Explore Plants and My Matches (the filters are listed once in `plantFilters.ts`), `FilterSelect` is a labelled dropdown for one filter, and `SortMenu` is a sort button with a menu that can be used with the keyboard. `MatchButton` adds a plant to My Matches (♥) or removes it (✖), `HeartIcon` is the SVG heart used on the match buttons and on Plant Match, `ErrorMessage` shows a short error message, and `LanguageSwitcher` is used both in the sidebar and in the walkthrough. The components take already translated texts, so they can be used on other pages.
Expand Down
Binary file modified docs/media/coverageFrontend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/quality.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The app includes the following accessibility features:

- **Forms and images:** Search, filters and profile inputs have associated labels. Plant images use the plant name as alternative text, and profile and avatar images also include alternative text.

- **Control states:** The sort menu and the mobile menu button expose their expanded state and which element they control. Sort, avatar and preference choices and the profile tabs expose their selected state with `aria-pressed`. The preference chips on the plant cards are a list, and a chip that matches the user's preferences also says so in text that only screen readers read, so the information is not given by color alone. Pagination marks the current page with `aria-current="page"` and announces page changes through an `aria-live="polite"` region. On Explore Plants and My Matches, the number of results or matches is also announced when it changes, including "No results found" when a search gives no plants and "no matches" when the last match is removed. Filter values that would give no plants are disabled options, so screen readers say they are unavailable, and the number of plants is part of the option text. Every page has one `h1` (the page title in the header) and a `main` landmark. The match button on the plant cards shows a heart to add a plant to My Matches and ✖ to remove it, and its accessible name and tooltip say what a click does. The badge with the number of new matches on the My Matches link in the sidebar is hidden from screen readers, which instead read a text such as "2 new matches" as part of the link. If adding or removing a match fails, an error message is shown at the top of the screen in a `role="alert"` region, so screen readers read it at once without moving focus.
- **Control states:** The sort menu and the mobile menu button expose their expanded state and which element they control. Sort, avatar and preference choices and the profile tabs expose their selected state with `aria-pressed`. The preference chips on the plant cards are a list, and a chip that matches the user's preferences also says so in text that only screen readers read, so the information is not given by color alone. Pagination marks the current page with `aria-current="page"` and announces page changes through an `aria-live="polite"` region. On Explore Plants and My Matches, the number of results or matches is also announced when it changes, including "No results found" when a search gives no plants and "no matches" when the last match is removed. Filter values that would give no plants are disabled options, so screen readers say they are unavailable, and the number of plants is part of the option text. Every page has one `h1` (the page title in the header) and a `main` landmark. The match button on the plant cards shows a heart to add a plant to My Matches and ✖ to remove it, and its accessible name and tooltip say what a click does. The badge with the number of new matches on the My Matches link in the sidebar is hidden from screen readers, which instead read a text such as "2 new matches" as part of the link. On mobile, the menu button shows the same badge, and the number is part of its accessible name. If adding or removing a match fails, an error message is shown at the top of the screen in a `role="alert"` region, so screen readers read it at once without moving focus.

- **Plant cards:** The inactive side of a flipped card is hidden from assistive technology with `aria-hidden`, and its information button is removed from the keyboard tab order.

Expand Down Expand Up @@ -127,7 +127,7 @@ We considered sustainability through both our design choices and our approach to

- **Consistent icons:** All icons are inline SVG components in [Icons.tsx](../frontend/src/components/icons/Icons.tsx), [ThemeIcons.tsx](../frontend/src/components/sidebarButtons/ThemeIcons.tsx) and [HeartIcon.tsx](../frontend/src/components/heartIcon/HeartIcon.tsx), drawn on the same 24 × 24 grid. They use `currentColor`, so they follow the text color in both light and dark mode, and they are sized with `font-size`, so they scale with the text around them. They are marked with `aria-hidden` and `focusable="false"`, since the search field and the buttons they are in already have accessible names, so screen readers do not read the icons twice. Because we drew the icons ourselves, there are no third-party licences to credit.

- **Responsive design:** We designed the application for both desktop and mobile screens. The layout adapts to different screen sizes to ensure that the content and navigation remain usable across devices.
- **Responsive design:** We designed the application for both desktop and mobile screens. The layout adapts to different screen sizes to ensure that the content and navigation remain usable across devices. Phones held sideways also get the mobile layout, since their screens are wide but too low for the sidebar.

- **Walkthrough:** The walkthrough was added after user testing showed that new users did not get a clear overview of the app (see [User testing and the walkthrough](#user-testing-and-the-walkthrough)). Each step uses one of the avatars from the profile page, and the Next and Back buttons are pink, so the guide looks like the rest of the app. The steps are kept short, with one page per step, so users can read through them quickly or close the guide and come back to it later.

Expand Down
Loading
Loading