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
51 changes: 32 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ http://it2810-03.idi.ntnu.no/project2/

## Core features

- **Plant Match:** Shows plants one at a time. Click ✿ to like a plant or ✖ to skip it.
- **Preferences:** Choose what kind of plants you want, for example indoor, outdoor, flowering, pet friendly or succulent. Your preferences are remembered between visits.
- **My Matches:** A list of all the plants you have matched with or have added as matches. Can also delet plants from my matches.
- **Explore Plants:** Search athe plant collection and filter by watering needs, sunlight, location (indoor/outdoor) and edibility. Sort the plants by; alphabetical order, watering and care. Can also add plants to my matches from here.
- **Plant details:** Each plant card shows an image, the scientific name, a description and care information (watering, sunlight and care level).
- **Profile:** Your preferences, description, name and plant avtar is saved.
- **Plant Match:** Shows random plants one at a time. 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, but the preferences do not change which plants are shown.
- **My Matches:** A list of all the plants you have liked in Plant Match or added from Explore Plants. You can also remove plants from the list.
- **Explore Plants:** Search the plant collection by 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 results are split into pages. You can also add plants to My Matches from here.
- **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, and your matched plants are shown here.
- **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:** has a light and a dark theme.
- **Plant Owner Test:** TODO exlusive picture
- **Plant Card** read about the plant and its prefernaces. Add the plant to my matches and remove it from my matches
- **Theme:** The app has a light and a dark theme.

## Tech stack

Expand Down Expand Up @@ -80,7 +79,27 @@ npm run dev

This starts both the backend (http://localhost:3001) and the frontend. Open http://localhost:5173/project2/ in your browser. The frontend forwards `/graphql` requests to the backend, so both must be running.

See [backend/README.md](backend/README.md) for more details about the backend setup (in Norwegian).
## 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:

```text
Browser ──> Apache (port 80, /project2) serves the built frontend
──> Backend (port 3001, /graphql) run by pm2, Node.js
└──> MongoDB (127.0.0.1:27017) only reachable from the VM
```

### Backend

The backend runs with pm2, which keeps it running in the background and restarts it if it crashes or the VM reboots. The backend reads `MONGODB_URI=mongodb://localhost:27017`, `DB_NAME=iloveplants` and `PORT=3001` from `backend/.env` on the VM (see `.env.example`). If the backend stops, see [How to start the backend if it stops](../T03-Project-2/docs/architecture.md) .


### Frontend
The frontend runs on the VM by using Apache serves. It was copied to the folder Apache serves for `/project2`. The build reads `VITE_GRAPHQL_URL` from [frontend/.env.production](frontend/.env.production), so the deployed app sends its requests to the backend on port 3001 on the VM.

### 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)).

## Testing

Expand All @@ -90,7 +109,6 @@ The application is tested on three levels:
- **Backend:** The database connection and the GraphQL server are tested with **Vitest** against a real MongoDB that runs in memory (**mongodb-memory-server**). The tests never use the database on the VM, so they do not need the VPN or the SSH tunnel. MongoDB is downloaded once the first time the backend tests run.
- **End-to-end:** Longer user journeys and the GraphQL API are tested with **Playwright**, against the real backend and a built frontend with a separate in-memory test database. The tests run on both desktop and mobile, and check all pages against WCAG 2.1 AA with **axe**.


See [tests.md](docs/tests.md) for what the test files cover, the e2e setup, the scenarios and what the tests found.

### Run the tests
Expand Down Expand Up @@ -121,7 +139,7 @@ The coverage table is printed in the terminal. A detailed report is saved in `fr

| Part | Statements | Branches | Functions | Lines |
| -------- | ---------- | -------- | --------- | ------- |
| Frontend | 96.7 % | 94.73 % | 92.92 % | 98.33 % |
| Frontend | 96.7 % | 94.82 % | 92.92 % | 98.33 % |
| Backend | 100 % | 100 % | 100 % | 100 % |

- Frontend test coverage:
Expand All @@ -132,17 +150,12 @@ The coverage table is printed in the terminal. A detailed report is saved in `fr

<img src="docs/media/coverageBackend.png" alt="Test coverage for the backend" width="500">


### 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 and tests for both the backend and the frontend, and runs the Playwright e2e and API tests. If an e2e test fails, the HTML report with traces can be downloaded from the workflow run.

## Quality and design

See [quality.md](docs/quality.md) for Lighthouse results, testing, accessibility, design choices, sustainable web development
and work practices.
See [quality.md](docs/quality.md) for Lighthouse results, testing, accessibility, design choices, sustainable web development and work practices.

## Known issues

If you type and switch pages within half a second after updating your profile, the last few letters are not saved, because the debounce didn't have time to send.

Information on plant card does not translate to Norwegian.
Binary file modified backend/.DS_Store
Binary file not shown.
79 changes: 0 additions & 79 deletions backend/README.md

This file was deleted.

Loading
Loading