Skip to content

Commit

Permalink
Merge pull request #513 from NYPL/SFR-2031/document-local-setup
Browse files Browse the repository at this point in the history
SFR-2031: Update local development instructions in README
  • Loading branch information
jackiequach authored Aug 1, 2024
2 parents f48976d + fa06ce7 commit a608757
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 39 deletions.
12 changes: 10 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ API_URL=http://drb-api-qa.nypl.org
# https://github.com/NYPL-Simplified/web-reader#cors-proxy
NEXT_PUBLIC_PROXY_URL=http://localhost:3001/?requestUrl=


# OPTIONAL LOCAL VARIABLES

# READER VERSION
NEXT_PUBLIC_READER_VERSION="v2"

# Airtable API Key
# The airtable key is only needed in development if the developer needs to send data via the feedback form.

NEXT_PUBLIC_AIRTABLE_API_KEY=[insert key here]
NEXT_PUBLIC_ADOBE_ANALYTICS=[insert AA url here]

# ADOBE ANALYTICS
NEXT_PUBLIC_ADOBE_ANALYTICS=[insert AA url here]

# NEW RELIC
NEW_RELIC_APP_NAME=[insert name here]
NEW_RELIC_LICENSE_KEY=[insert key here]
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Implement "Read Online" for UP items
- SFR-2032: Update local API url
- SFR-2076: Fix DRB PW Regression Tests
- Update README with instructions to run app locally

## [0.18.1]

Expand Down
61 changes: 43 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
## NYPL ResearchNow

### ResearchNow Search & Retrieval Application
# Digital Research Books Frontend

[![GitHub version](https://badge.fury.io/gh/NYPL%2Fsfr-bookfinder-front-end.svg)](https://badge.fury.io/gh/NYPL%2Fsfr-bookfinder-front-end)

Digital Research Books' front end application based on NYPL's React Design System.
Digital Research Books' front end application based on NYPL's Reservoir Design System.

Provides a "Welcome page" entry point with heading, search box, and tagline. Connects to an ElasticSearch index via an API endpoint (https://digital-research-books-api.nypl.org).
Simple searches can be entered in the form and an index response is displayed back to the user.
Expand All @@ -15,40 +13,67 @@ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next

### Contributing: Local Development

Clone the repo and run `npm install`.
#### Getting Started

##### Prerequisites

- Install Node.js v18 or later
- To view pdfs locally through the webreader, you will need to set up a local proxy. If you used environment variables from `.env.sample` you should be able to pull the [web-reader](https://github.com/NYPL-Simplified/web-reader) repo, install it, and run `npm run cors-proxy`. See the web-reader repo for more [instructions](https://github.com/NYPL-Simplified/web-reader#cors-proxy)

Create a `.env` file and add the `APP_ENV` and `API_URL`. See `.env.sample` for an example.
1. Install the required packages

Run `npm run dev` to start the local server at `localhost:3000`
```
npm install
```

2. Create a `.env` file and add required environment variables. See `.env.sample` for an example.

#### Running the app locally with npm at `localhost:3000`

```
npm run dev
```

To view pdfs locally through the webreader, you will need to set up a local proxy. If you used environment variables from `.env.sample` you should be able to pull the [web-reader](https://github.com/NYPL-Simplified/web-reader) repo, install it, and run `npm run cors-proxy`. See the web-reader repo for more [instructions](https://github.com/NYPL-Simplified/web-reader#cors-proxy)
#### Local Hosting

In order to successfully login under a local deployment, you will need to update your machine's `etc/hosts` file. This hosts file maps local host names to ip addresses.

Add this to your `etc/hosts` file:
This is necessary because NYPL's authentication system works by reading cookies and parsing the patron's encrypted credentials. These cookies only work on .nypl.org domains, so we need to map our local deployment to a .nypl.org domain.

Add this line to your `etc/hosts` file:

```
127.0.0.1 local.nypl.org
```

#### Running the app locally with Docker

1. Download and install Docker.
2. `cd` into `sfr-bookfinder-front-end` repo
3. To build and run the application, run:

```
docker-compose up
```

4. Check that app is being served at http://localhost:3000

### Deploying to Production

1. Create a new branch off `development` with the name `NO-REF_prepare-<VERSION>`, i.e. `NO-REF_prepare-1.2.3`. Replace any reference to "Pre-release" and the previous production version in the package.json and package-lock.json files with the current version number. Push the branch and create a Pull Request with the name `NOREF prepare <VERSION> release`, i.e. `NOREF prepare 1.2.3 release`. Merge these changes once the PR is approved.
1. Create a new branch off `development` with the name `NO-REF_prepare-<VERSION>`, i.e. `NO-REF_prepare-1.2.3`. Replace any reference to "Pre-release" and the previous production version in the package.json and package-lock.json files with the current version number. Push the branch and create a Pull Request with the name `NOREF prepare <VERSION> release`, i.e. `NOREF prepare 1.2.3 release`. Merge these changes once the PR is approved.
2. Create a Pull Request to `production` from `development` with the name `Release <VERSION> to production`, i.e. `Release 1.2.3 to production`. The description of the PR should be the new version's changelog to be used in the tag and release step of the .yaml file.
3. Merge the PR after approval to trigger the [`build-production.yaml`](./.github/workflows/build-production.yaml) GitHub Action, which pushes a Docker image to ECR, updates the `production` ECS deployment, and creates a new release version on GitHub.
4. Add the link to the PR to the release ticket in Jira and tag the appropriate member of QA, the project manager, and the product manager. Move the ticket to "In QA" and assign it to the appropriate member of QA. QA should be done on https://drb-qa.nypl.org/.


### Dependencies

- NextJS
- Redux
- NYPL Header and Footer npm modules
- NYPL Design System
- NYPL Web Reader

### Usage

### Searchbar
#### Searchbar

Currently takes in a query string to pass along to the ResearchNow Search API which submits a keyword search to the Elasticsearch instance, and renders the returned output. Sends the `query` parameter specified in the rendered search form on the main page.

Expand All @@ -63,23 +88,23 @@ Term combinations

These types of combinations can be used with any available field selection.

### Filtering
#### Filtering

Search Results can be filtered by year range, language and available format.

### Advanced Search
#### Advanced Search

Advanced Search works like the Simple Search, but allows searching for multiple fields and for pre-filtering. Terms use the AND boolean operator
Term combinations

- Example: Subject:"English Literature" AND Keyword:"Witches"

### Works and Editions
#### Works and Editions

- Each source record is represented as an Item (something that can actually be read online), which are grouped into Editions (e.g. the 1917 edition of X), which are in turn grouped into Works, (e.g. Moby Dick, or, The Whale). Through this a user can search for and find a single Work record and see all editions of that Work and all of its options for reading online.
- The information and code for this normalization is found in the [drb-etl-pipeline repo](https://github.com/NYPL/drb-etl-pipeline)

### Accessing books
#### Accessing books

- Books can be read three ways:
- Embedded page: DRB embeds a read-online page from a different source. DRB commonly does this for Hathitrust books
Expand Down
18 changes: 0 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"next-transpile-modules": "^7.0.0",
"react": "^18.2.0",
"react-cookie": "7.1.4",
"redux": "4.0.1",
"sass": "^1.62.1",
"typescript": "^4.1.3"
},
Expand Down

0 comments on commit a608757

Please sign in to comment.