From 9846985d452ff3153f694610fd2a545cbe966cf7 Mon Sep 17 00:00:00 2001 From: ninaflaaten Date: Fri, 20 Nov 2026 12:56:37 +0100 Subject: [PATCH 1/2] Add table of content to docs in readme --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index b11bccd5..a27f711f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,15 @@ I <3 Plants offers a fun way of finding plants and reading about them! Instead o http://it2810-03.idi.ntnu.no/project2/ +## Documentation + +| Document | Contents | +| --------------------------------------- | ------------------------------------------------------------------------------------------------- | +| [architecture.md](docs/architecture.md) | How the frontend, backend and database fit together, the plant data, data flow and code structure | +| [tests.md](docs/tests.md) | Test strategy, how to run the tests, coverage and what the tests found | +| [quality.md](docs/quality.md) | Work practices, accessibility, sustainable web development and design choices | +| [ai-usage.md](docs/ai-usage.md) | How AI tools were used during development | + ## Core features - **Plant Match:** Shows plants one at a time, best matches for your preferences first. Click ✿ to like a plant or ✖ to skip it. From 68c5028d6ba867c82c098d07aa3c4c9a3c1f9e7a Mon Sep 17 00:00:00 2001 From: ninaflaaten Date: Fri, 20 Nov 2026 13:15:37 +0100 Subject: [PATCH 2/2] Make the Readme more clear and shorten it --- README.md | 36 ++++++++++++++++++++---------------- docs/quality.md | 14 +++++++------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index a27f711f..5fa92af0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ # I <3 Plants -I <3 Plants offers a fun way of finding plants and reading about them! Instead of scrolling through a long catalogue, you set your preferences and get shown one plant at a time. You like the plants you want and skip the ones you don't, and your matches are saved so you can come back to them later. If you already know what you are looking for, you can also search and filter the full plant collection. The app is made to be low-threshold: there is no login, so anyone can start finding plants right away, without creating an account first. +I <3 Plants is a web app for finding plants that suit you and reading about them. + +## Concept + +- **The problem:** A long plant catalogue is hard to get started with if you do not know what you are looking for. +- **The idea:** Instead of scrolling through a long list, you first choose your preferences for water, sun and care. The app then shows you one plant at a time, starting with the plants that match your preferences best. You like or skip each plant, and the ones you like are saved in My Matches so you can come back to them later. +- **Low threshold:** There is no login. A user is created the first time the app is opened, so anyone can start finding plants right away, without creating an account. +- **For those who know what they want:** Users who already know what they are looking for can search and filter the whole collection instead. ## Link to VM @@ -17,16 +24,9 @@ http://it2810-03.idi.ntnu.no/project2/ ## Core features -- **Plant Match:** Shows plants one at a time, best matches for your preferences first. Click ✿ to like a plant or ✖ to skip it. -- **Preferences:** Choose what you want from a plant: how much water it needs (minimum, average, frequent), how much sun it needs (full sun, part shade, filtered shade) and how much care it needs (easy, medium, hard). The preferences are saved in the database. Plant cards highlight the traits that match your preferences, and Plant Match shows the plants that match the most of your preferences first. Changing your preferences starts Plant Match over with a newly ordered deck. Without preferences, the plants come in random order. -- **My Matches:** A list of all the plants you have liked in Plant Match or added from Explore Plants, with the number of matches shown above. Sort them by newest, oldest or name (A–Z or Z–A), and move between pages when there are many. The sort order is remembered for the session, also when you go to another page and back. You can also remove plants from the list. -- **Explore Plants:** Search the plant collection by common or scientific name and filter by watering, sunlight and care level. Sort the plants alphabetically (A–Z or Z–A), by watering or by care level. Search, filtering and sorting run in the backend on the whole collection, and the number of results is shown above the plants. The results are split into pages, and you can jump straight to any page. The search, filters, sorting and current page are stored in the URL, so an Explore view can be refreshed or shared as a link. Add a plant to My Matches with the ✿ button, which then turns into ✖, and click it again to remove it. -- **Plant details:** Each plant card shows an image, the scientific name, a description and care information (watering, sunlight and care level). Flip the card to read more about the plant. -- **Profile:** Your name, description, avatar and preferences are saved in the database. -- **Plant Owner Test:** A short quiz that tells you what kind of plant owner you are. Each result has its own picture, which you can only get through the test, and you can save it as your profile picture. -- **Language:** The app is available in English and Norwegian. -- **Theme:** The app has a light and a dark theme. -- **Page not found:** Unknown addresses show a 404 page with a link back to Plant Match. +- **Plant Match:** Plants matching the most preferences come first, otherwise the order is random. The deck is kept while the user visits other pages, so they can continue where they left off. +- **My Matches:** Collects liked plants from both Plant Match and Explore Plants. The user only stores plant ids, and the list is fetched one page at a time, so responses do not grow with the number of matches. +- **Explore Plants:** Search, filtering, sorting and pagination run in the backend, so the frontend only receives one page at a time, whatever the size of the collection. The state is kept in the URL, so a view survives a refresh and can be shared as a link. ## Tech stack @@ -51,6 +51,8 @@ See [architecture.md](docs/architecture.md) for how the frontend, backend and da - Access to the NTNU network (use the NTNU VPN if you are not on campus) - An NTNU user with access to the VM `it2810-03.idi.ntnu.no` +The local backend uses the database on the VM, which is why you need the NTNU network and a user on the VM. + ### 1. Install dependencies ```bash @@ -59,7 +61,7 @@ cd T03-Project-2 npm run install:all ``` -This installs the dependencies for the repo root, `backend` and `frontend`. +This installs the dependencies for the repo root, `backend` and `frontend`, which each have their own `package.json`. ### 2. Create the backend `.env` file (in the VS Code terminal) @@ -67,10 +69,12 @@ This installs the dependencies for the repo root, `backend` and `frontend`. cp backend/.env.example backend/.env ``` -The default values work as they are. `.env` is ignored by git and must never be committed. +The backend reads the database address, the database name and its port from this file. The default values work as they are. `.env` is ignored by git and must never be committed. ### 3. Open an SSH tunnel to the database (in a separate PC-terminal) +MongoDB on the VM only listens on `127.0.0.1`, so it cannot be reached directly from your machine. The tunnel forwards port 27017 on your machine to the database on the VM, which is why the default `MONGODB_URI` points to `localhost`. + Open a **separate terminal**, replace `` with your username and run the command below. After you enter your password, the command looks like it hangs. That means the tunnel is open. Keep the terminal open while you work, and stop the tunnel with `Ctrl+C` when you are done. @@ -91,7 +95,7 @@ This starts both the backend (http://localhost:3001) and the frontend. Open http ## Deployment on the VM -The deployed app runs on the VM `it2810-03.idi.ntnu.no`. Apache serves the frontend, and the backend and MongoDB run directly on the VM, not in Docker: +The deployed app runs on the VM `it2810-03.idi.ntnu.no`. Apache serves the frontend, and the backend and MongoDB run directly on the VM, not in Docker. Apache is already installed on the course VM and serves the built frontend as static files without extra setup. The app is one backend process and one database, so running them directly on the VM, with pm2 keeping the backend alive, keeps the setup simple without the extra layer Docker would add: ```text Browser ──> Apache (port 80, /project2) serves the built frontend @@ -109,11 +113,11 @@ Apache serves the built frontend on the VM. The build was copied to the folder A ### Database -MongoDB is installed directly on the VM and only listens on `127.0.0.1`, so it cannot be reached from outside the VM. The plant data was loaded once with `npm run seed` in the backend (see [architecture.md](docs/architecture.md#data-source-the-perenual-api)). +MongoDB is installed directly on the VM and only listens on `127.0.0.1`, so it cannot be reached from outside the VM. The plant data was loaded once with `npm run seed` in the backend, so the running app never calls the Perenual API and is not limited by its daily request quota (see [architecture.md](docs/architecture.md#data-source-the-perenual-api)). ## Testing -The application is tested on three levels: component tests for the frontend (Vitest and React Testing Library), backend tests against an in-memory MongoDB (Vitest and mongodb-memory-server), and end-to-end and API tests with Playwright, which also check all pages against WCAG 2.1 AA with axe. None of the tests use the database on the VM, so they need neither the VPN nor the SSH tunnel. +The application is tested on three levels: component tests for the frontend (Vitest and React Testing Library), backend tests against an in-memory MongoDB (Vitest and mongodb-memory-server), and end-to-end and API tests with Playwright, which also check all pages against WCAG 2.1 AA with axe. Each level has its own purpose: the component and backend tests are fast and test one part at a time, also cases that are hard to reach through the UI, while the end-to-end tests check that the parts work together the way a user experiences them. None of the tests use the database on the VM. The backend and e2e tests use an in-memory MongoDB filled with known test data, so every run starts from the same data, the tests never change real user data, and they need neither the VPN nor the SSH tunnel. The tests run in GitHub Actions on every pull request, so a change that breaks a test is caught before it is merged. Run the tests from the repo root: diff --git a/docs/quality.md b/docs/quality.md index d4451193..938e1af5 100644 --- a/docs/quality.md +++ b/docs/quality.md @@ -12,7 +12,7 @@ This document describes how we have worked to ensure the quality of the applicat ### Continuous integration -GitHub Actions ([.github/workflows/ci.yml](../.github/workflows/ci.yml)) runs on every pull request and on every push to `main`. It checks the formatting with Prettier, runs lint, tests and a build for both the backend and the frontend, and runs the end-to-end tests. +GitHub Actions ([.github/workflows/ci.yml](../.github/workflows/ci.yml)) runs on every pull request and on every push to `main`. It checks the formatting with Prettier, runs lint, tests and a build for both the backend and the frontend, and runs the end-to-end tests. This means a pull request that breaks the formatting, lint, a test or the build is caught before it is merged, instead of being found later on `main`. ## Work practices @@ -26,7 +26,7 @@ GitHub Actions ([.github/workflows/ci.yml](../.github/workflows/ci.yml)) runs on Hand-drawn sketch of the profile page with a profile picture and fields for information about the user -- We then used Figma to find inspiration for colours and layout. The mock-up below was used as a reference for the visual style, not as a finished design. +- We then used Figma to find inspiration for colors and layout. The mock-up below was used as a reference for the visual style, not as a finished design. Figma mock-up of a plant app with a green sidebar menu, a search bar, plant cards with photos and a list of care tasks @@ -53,7 +53,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 colour 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 matches" when the last match is removed. Every page has one `h1` (the page title in the header) and a `main` landmark. The match button on the plant cards shows ✿ to add a plant to My Matches and ✖ to remove it, and its accessible name and tooltip say what a click does. 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 matches" when the last match is removed. Every page has one `h1` (the page title in the header) and a `main` landmark. The match button on the plant cards shows ✿ to add a plant to My Matches and ✖ to remove it, and its accessible name and tooltip say what a click does. 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. @@ -61,7 +61,7 @@ The app includes the following accessibility features: - **Testing:** The end-to-end tests check all pages against WCAG 2.1 AA with axe, in both light and dark mode, and the component tests check accessible names, navigation state and sorting states. The axe DevTools extension found no issues, and the deployed app scored 100 for accessibility in Lighthouse. The app has also been tested manually with the keyboard only and at 200 % zoom. See [tests.md](tests.md#accessibility) for the results, including two problems the tests found. -- **Colour contrast:** We checked the contrast between our chosen colours with manual testing, a colour contrast checker, Lighthouse and the end-to-end tests, to make sure that text and interface elements are distinguishable from their backgrounds and meet the WCAG 2.1 accessibility guidelines. The end-to-end tests check every page in both light and dark mode (see [tests.md](tests.md#accessibility)). +- **Color contrast:** We checked the contrast between our chosen colors with manual testing, a color contrast checker, Lighthouse and the end-to-end tests, to make sure that text and interface elements are distinguishable from their backgrounds and meet the WCAG 2.1 accessibility guidelines. The end-to-end tests check every page in both light and dark mode (see [tests.md](tests.md#accessibility)). - **Language support:** The application supports both Norwegian and English, allowing users to choose their preferred language. The accessible names of buttons and landmarks, such as the menu buttons and the sidebar navigation, are translated too, so screen readers read them in the chosen language. @@ -69,7 +69,7 @@ The app includes the following accessibility features: We considered sustainability through both our design choices and our approach to data handling. -- **Limited colour palette:** We use a limited number of colours throughout the application to maintain a consistent design and follow the principle of avoiding unnecessary use of colours. +- **Limited color palette:** We use a limited number of colors throughout the application to maintain a consistent design. All colors are defined once as CSS variables in [index.css](../frontend/src/index.css), and the dark theme only overrides those variables instead of repeating the styles. This keeps the stylesheet small, so less CSS has to be downloaded, and the dark theme needs no extra stylesheet. - **Dark mode:** The application supports both light and dark themes. Dark mode can reduce energy consumption on OLED screens, which are common on phones, because dark pixels use less power there. It also gives users a choice that can be more comfortable in low light. @@ -85,11 +85,11 @@ We considered sustainability through both our design choices and our approach to ## Design choices -- **Colour palette and contrast:** We used a limited colour palette to maintain a consistent visual identity across the application. We also checked the contrast between our chosen colours to help ensure that text and other interface elements remain distinguishable and in line with accessibility requirements. See [Accessibility](#accessibility). +- **Color palette and contrast:** We used a limited color palette to maintain a consistent visual identity across the application. We also checked the contrast between our chosen colors to help ensure that text and other interface elements remain distinguishable and in line with accessibility requirements. See [Accessibility](#accessibility). - **Reusable components:** Shared UI is kept in reusable components, so the pages look and work the same way and changes only need to be made in one place. This makes the application easier to maintain. The Header, Sidebar and plant cards are used across pages, `Pagination`, `SortMenu` and `MatchButton` are shared by Explore Plants and My Matches, and `ErrorMessage` shows error messages on every page. The filters on Explore Plants are defined in one list of `FilterSelect` components, so a new filter only needs one new line. -- **Consistent icons:** All icons are inline SVG components in [Icons.tsx](../frontend/src/components/icons/Icons.tsx) and [ThemeIcons.tsx](../frontend/src/components/sidebarButtons/ThemeIcons.tsx), drawn on the same 24 × 24 grid. They use `currentColor`, so they follow the text colour 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. +- **Consistent icons:** All icons are inline SVG components in [Icons.tsx](../frontend/src/components/icons/Icons.tsx) and [ThemeIcons.tsx](../frontend/src/components/sidebarButtons/ThemeIcons.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.