Skip to content

1uphealth/prime-simplereport

 
 

Repository files navigation

Simple Report

https://simplereport.cdc.gov/

Table of Contents

Setup

  1. Install Docker and docker-compose
    • You can install docker hub directly: https://hub.docker.com/. This is the preferred solution and should come with docker-compose
    • Alternatively, you can install docker and run it as a daemon: brew install docker.

Backend

There are two major pieces:

  • Java Spring
  • Postgres

To run the service, you needs a DB and a connection to Okta for it to work. Locally, you can disable authentication, but you still need the database running locally.

Backend-Setup

If Java isn't installed on a Mac you can get it from brew:

brew tap adoptopenjdk/openjdk
brew cask install adoptopenjdk8
brew install gradle

Running with docker:

  1. cd backend
  2. Run docker-compose up --build
  3. view site at http://localhost:8080

Running spring app locally and db in docker

  1. cd backend
  2. Run docker-compose up db
  3. Run gradle bootRun --args='--spring.profiles.active=dev'
  4. view site at http://localhost:8080

Running spring app locally and db in docker on port 5433

  1. cd backend
  2. Run docker-compose --env-file .env.development up db
  3. Run SR_DB_PORT=5433 gradle bootRun --args='--spring.profiles.active=dev'
  4. view site at http://localhost:8080

Restart & Clean

When there are DB schema changes the backend may throw and error and fail to start.

Restarting the docker way:

  1. run cd backend
  2. Bring down the service by running docker-compose down
  3. Wipe the db by running docker system prune && docker images prune && docker volumes prune
  4. Restart the service docker-compose up --build

Restarting the SQL way:

  1. run db-setup/nuke-db.sh
  2. restart the spring app gradle bootRun --args='--spring.profiles.active=dev'

API Testing

Go to localhost:8080 to see interact with the graphql api. You would need to point the api endpoint to the backend at: http://localhost:8080/graphql This gives you a preview to query/mutate the local database.

Tests

All the test can be run with gradle test

Running a single test with a full stacktrace can be accomplished by supping the path to gradle test. Example

gradle test --tests gov.cdc.usds.simplereport.api.QueueManagementTest.updateItemInQueue --stacktrace

SchemaSpy

http://schemaspy.org/

cd backend
docker-compose up db
docker-compose up --build schemaspy
# to run on a different port than 8081
SR_SCHEMASPY_PORT=8082 docker-compose up --build schemaspy

visit http://localhost:8081

Frontend

The frontend is a React app. The app uses Apollo to manage the graphql API. For styling the app leverages the U.S. Web Design System (USWDS)

Frontend-Setup

  1. Install nvm
  2. (optional) Install react developer tools extensions
  3. cd frontend && nvm use && yarn install
  4. yarn start
  5. view site at http://localhost:3000
    • Note: frontend need the backend to be running to work

Deploy

See https://github.com/usds/prime-simplereport-docs/blob/main/azure/manual-app-deploy.md

Releases

No releases published

Packages

No packages published

Languages

  • Java 41.6%
  • TypeScript 19.4%
  • JavaScript 13.8%
  • HCL 13.5%
  • SCSS 10.0%
  • HTML 0.9%
  • Other 0.8%