chemistry-cafe

Web application to track chemical mechanisms, reactions, and chemicals

https://github.com/ncar/chemistry-cafe

Science Score: 75.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
    Organization ncar has institutional domain (ncar.ucar.edu)
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.7%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Web application to track chemical mechanisms, reactions, and chemicals

Basic Info
  • Host: GitHub
  • Owner: NCAR
  • License: apache-2.0
  • Language: TypeScript
  • Default Branch: main
  • Size: 33.3 MB
Statistics
  • Stars: 6
  • Watchers: 8
  • Forks: 3
  • Open Issues: 14
  • Releases: 16
Created over 9 years ago · Last pushed 7 months ago
Metadata Files
Readme License Citation

README.md

Chemistry Cafe

GitHub Releases License Docker builds NodeJS Dotnet codecov FAIR checklist badge DOI

ChemistryCafe is a web application built with React, Vite, and TypeScript. The app uses various libraries and frameworks such as MUI, Axios, and styled-components to provide a seamless and modern user experience. This README provides information about the application and how to run the code locally.

Getting Started

Backend Environment Variables

The backend of Chemistry Cafe requires certain secrets that cannot be stored in version control. These secrets are stored in environment variables that are either on the machine or loaded on runtime. Before running the application, make sure to define these variables ahead of time.

To define required environment variables, a .env file should be created with the following schema:

```py

Required

GOOGLECLIENTID= GOOGLECLIENTSECRET= MYSQLUSER=chemistrycafedev MYSQLPASSWORD=chemistrycafe MYSQLDATABASE=chemistrydb

Optional with defaults

MYSQLSERVER=localhost MYSQLPORT=3306 FRONTENDHOST=http://localhost:5173 BACKENDBASE_URL=/ ```

In order to use Google Authentication, a Google Cloud OAuth 2.0 project must be used with a client id and client secret. When creating the project, http://localhost:8080/signin-google should be added to the list of "Authorized redirect URIs" for testing.

FRONTEND_HOST and BACKEND_BASE_URL are required in a production environment. FRONTEND_HOST contains where the frontend is served and BACKEND_BASE_URL specifies what the backend urls should be prefixed with (eg. "/api/").

Note:

  • When running locally, the .env file must be in the /backend directory.
    • This includes when running database migrations locally
  • When running with docker, the .env file should be in the root directory unless otherwise specified. If it is in another directory, simply use docker compose --env-file <path/to/.env> up instead of the default.

Running Chemistry Cafe with Docker Compose

You must have Docker Desktop installed and running. With Docker Desktop running, open a terminal window. To build the project run:

$ docker compose up --build

To run project in background:

$ docker compose up -d

When finished, run: $ docker compose down

To view logs for backend/frontend/sql: $ docker compose logs backend $ docker compose logs frontend $ docker compose logs sql

To view logs for all services: $ docker compose logs -f

Note: To view changes, you must run the docker compose down and then run the project again.

Local Development (without Docker)

Framework dependencies

Setup

  1. Clone the repository: Open a terminal window, navigate to a folder where you would like the Chemistry Cafe files to exist, and run the following commands:

    $ git clone https://github.com/NCAR/chemistry-cafe.git $ cd chemistrycafe

  2. Install dependencies for frontend: shell $ cd frontend $ npm install $ cd ..

  3. Install dependencies for backend $ cd backend $ dotnet restore

Database Migrations

The database comes with a provided init.sql which creates all of the database tables. To create the migrations, we use a tool called dotnet-ef of which the documentation can be found here.

To install the tool:

bash $ dotnet tool install --global dotnet-ef

The following commands are useful when developing the application. All of these must be executed in the ./backend directory.

To create a migration:

bash $ dotnet ef migrations add <migration-name>

To apply migrations without generating a script:

bash $ dotnet ef database update

To generate a new init.sql script:

bash $ dotnet ef migrations script --idempotent -o init.sql

Testing

To test frontend

cd frontend npm run test:coverage If all tests past, the coverage report will generate in frontend/coverage/index.html

To test backend

docker compose up mysql -d dotnet test backend --collect:"Code Coverage;Format=cobertura" docker compose down

reportgenerator -reports:"backend/TestResults/**/**.cobertura.xml" -targetdir:coveragereport -reporttypes:Html,lcov -classfilters:"-MySqlConnector.*;-ChemistryCafeAPI.Migrations.*" -filefilters:-/_/src/MySqlConnector/*,-backend/TestResults/**/coverage.cobertura.xml; rm -r ./backend/TestResults

If all tests run, the coverage report will generate index.html and lcov.info under backend/coveragereport/.

Production

Environment Setup

To build for production, there is a provided docker-compose.production.yml file. A .env file in the root directory is required to specify environment variables of the production containers. The .env file should look like the following:

```py

Required

MYSQLUSER=chemistrycafe MYSQLPASSWORD=verystrongmysqlpassw0rd # Needless to say, do not use this as the actual password MYSQLDATABASE=chemistrydb MYSQLROOTPASSWORD=dontsharethiswithanyonebecausethatwouldbebad GOOGLECLIENTID= GOOGLECLIENTSECRET= FRONTENDHOST=https:// BACKENDBASE_URL=/api # This would be / if testing on localhost:8080

Optional with defaults

MYSQLSERVER=mysql MYSQLPORT=3306 ```

  • Note: compared to the development environment, the frontend requires more variables to be specified. This is to ensure less implicit functionality.
  • The FRONTEND_HOST variable should not have a trailing slash. This is because CORS policies treat https://<domain> and https://<domain>/ as different routes.

Frontend variables

The frontend requires a file named .env.production in its directory. This is because the final container will serve a static site to the user and it pastes the variables inline with the static code.

py VITE_BASE_URL=http://localhost:8080/api # Backend API endpoint VITE_AUTH_URL=http://localhost:8080/auth # Backend auth endpoint

For Contributors: Do not put secrets in this environment file. These environment variables are served directly to the web browser meaning they are public. Any functionality requiring API keys should solely be dealt with in the backend.

  • It's very easy to be tempted with an npm package that uses environment variables to call an external API. Many have fallen victim to this security vulnerability in the past.

To run the production containers:

docker compose -f ./docker-compose.production.yml up -d

After each container is built and running, the backend will be served in port 8080 and the frontend will be served on port 5173 just like the development environment.

To actually serve these containers to the world, use a reverse proxy like NGINX or Apache httpd to redirect traffic to the different services.

When serving on the same dns, it's generaly a good idea to put the frontend on / and the backend on something unique like /api. Though, if you use /api, do note that some routes in the backend may look like https://<host>/api/api/<route>.

License

Copyright (C) 2018-2024 National Center for Atmospheric Research

Owner

  • Name: NSF National Center for Atmospheric Research
  • Login: NCAR
  • Kind: organization
  • Location: Boulder, CO

NSF NCAR is sponsored by the U.S. National Science Foundation and managed by the University Corporation for Atmospheric Research.

Citation (CITATION.cff)

cff-version: 1.2.0
message: If you use this software, please cite it as below.
title: Chemistry Cafe
version: 1.6.1
authors:
  - family-names: Dawson
    given-names: Matthew
  - family-names: Shores
    given-names: Kyle
  - family-names: Conley
    given-names: Andrew
  - family-names: Longuet
    given-names: Brandon
  - family-names: Cyr
    given-names: Paul
  - family-names: Nguyen
    given-names: Brian
  - family-names: Schiller
    given-names: Britt
  - family-names: Hare
    given-names: Joshua
  - family-names: Mittal
    given-names: Nishka
  - family-names: Ogunleye
    given-names: Oreoluwa 
  - family-names: Ferris
    given-names: Sydney 
  - family-names: Cook
    given-names: Robert
  - family-names: Stewart
    given-names: Jackson
  - family-names: Fogle
    given-names: Kaili
  - family-names: Curvino
    given-names: Donato
  - family-names: Fontenot
    given-names: James
license: Apache-2.0
url: "https://github.com/NCAR/chemistry-cafe"

GitHub Events

Total
  • Create event: 101
  • Release event: 12
  • Issues event: 130
  • Watch event: 3
  • Delete event: 109
  • Member event: 5
  • Issue comment event: 114
  • Push event: 487
  • Pull request review comment event: 30
  • Pull request review event: 45
  • Pull request event: 190
  • Fork event: 3
Last Year
  • Create event: 101
  • Release event: 12
  • Issues event: 130
  • Watch event: 3
  • Delete event: 109
  • Member event: 5
  • Issue comment event: 114
  • Push event: 487
  • Pull request review comment event: 30
  • Pull request review event: 45
  • Pull request event: 190
  • Fork event: 3

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 70
  • Total pull requests: 142
  • Average time to close issues: 3 months
  • Average time to close pull requests: 8 days
  • Total issue authors: 9
  • Total pull request authors: 16
  • Average comments per issue: 0.54
  • Average comments per pull request: 0.65
  • Merged pull requests: 122
  • Bot issues: 0
  • Bot pull requests: 21
Past Year
  • Issues: 63
  • Pull requests: 134
  • Average time to close issues: 20 days
  • Average time to close pull requests: about 11 hours
  • Issue authors: 9
  • Pull request authors: 13
  • Average comments per issue: 0.48
  • Average comments per pull request: 0.69
  • Merged pull requests: 115
  • Bot issues: 0
  • Bot pull requests: 21
Top Authors
Issue Authors
  • LucientZ (31)
  • K20shores (20)
  • mattldawson (11)
  • BrittExe (3)
  • quasar32 (2)
  • KailiF (2)
  • Donato-Curvino (1)
  • JoshHare (1)
  • jts3304-tamu (1)
Pull Request Authors
  • LucientZ (35)
  • quasar32 (30)
  • SydZero (24)
  • github-actions[bot] (23)
  • JoshHare (21)
  • BrittExe (9)
  • jts3304-tamu (9)
  • oreogunleye24 (5)
  • Donato-Curvino (5)
  • K20shores (4)
  • AndrewJConley (4)
  • KailiF (4)
  • mattldawson (2)
  • montythind (2)
  • ecyr20 (1)
Top Labels
Issue Labels
V2 (21) bug (11) enhancement (7) future work (6) documentation (3) good first issue (2)
Pull Request Labels
dependencies (1) javascript (1)

Dependencies

.github/workflows/npm_build_test.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • codecov/codecov-action v1 composite
.github/workflows/codecov.yml actions
  • actions/checkout v2 composite
  • actions/setup-dotnet v3 composite
  • codecov/codecov-action v4 composite
.github/workflows/docker_image.yml actions
  • actions/checkout v4 composite
  • docker/build-push-action v4 composite
  • docker/login-action v2 composite
  • docker/setup-buildx-action v2 composite
.github/workflows/dotnet.yml actions
  • actions/checkout v3 composite
  • actions/setup-dotnet v3 composite
.github/workflows/music-box-interactive-folder/prettier.yml actions
  • actions/checkout v3 composite
  • peter-evans/create-pull-request v3 composite
.github/workflows/music-box-interactive-folder/test.yml actions
  • actions/checkout v2 composite
  • actions/setup-node v4 composite
.github/workflows/musica/clang_format.yml actions
  • actions/checkout v4 composite
  • peter-evans/create-pull-request v6 composite
.github/workflows/musica/clang_tidy.yml actions
  • actions/checkout v4 composite
  • peter-evans/create-pull-request v6 composite
.github/workflows/musica/docker.yml actions
  • actions/checkout v4 composite
  • codecov/codecov-action v3 composite
.github/workflows/musica/fetch_content_integration.yml actions
  • actions/checkout v4 composite
.github/workflows/musica/gh_pages.yml actions
  • actions/checkout v4 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/musica/mac.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.github/workflows/musica/pep8.yml actions
  • actions/checkout v4 composite
  • peter-evans/autopep8 v2 composite
  • peter-evans/create-pull-request v6 composite
.github/workflows/musica/pip.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.github/workflows/musica/release.yml actions
  • actions/checkout v4 composite
  • actions/download-artifact v4 composite
  • actions/setup-python v5 composite
  • actions/upload-artifact v4 composite
  • pypa/cibuildwheel v2.17 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/musica/ubuntu.yml actions
  • actions/checkout v4 composite
.github/workflows/musica/windows.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • actions/setup-python v4 composite
  • egor-tensin/setup-mingw v2 composite
backend/Dockerfile docker
  • base latest build
  • build latest build
  • mcr.microsoft.com/dotnet/aspnet 8.0 build
  • mcr.microsoft.com/dotnet/sdk 8.0 build
docker-compose.yml docker
  • mysql 9.0
frontend/Dockerfile docker
  • node 18 build
backend/package-lock.json npm
frontend/package-lock.json npm
  • 513 dependencies
frontend/package.json npm
  • @testing-library/react ^15.0.4 development
  • @types/node ^20.12.6 development
  • @types/react ^18.2.56 development
  • @types/react-dom ^18.2.19 development
  • @typescript-eslint/eslint-plugin ^7.0.2 development
  • @typescript-eslint/parser ^7.0.2 development
  • @vitejs/plugin-react ^4.2.1 development
  • @vitest/coverage-v8 ^1.5.2 development
  • eslint ^8.56.0 development
  • eslint-plugin-react-hooks ^4.6.0 development
  • eslint-plugin-react-refresh ^0.4.5 development
  • jsdom ^24.0.0 development
  • typescript ^5.2.2 development
  • vite ^5.1.4 development
  • vitest ^1.5.2 development
  • @emotion/react ^11.11.4
  • @emotion/styled ^11.11.5
  • @mui/icons-material ^5.15.15
  • @mui/material ^5.15.14
  • @mui/styled-engine-sc ^6.0.0-alpha.18
  • @mui/x-data-grid ^7.3.0
  • @mui/x-tree-view ^7.1.1
  • @react-oauth/google ^0.12.1
  • axios ^1.6.7
  • bootstrap ^5.3.3
  • express ^4.18.2
  • react ^18.2.0
  • react-bootstrap ^2.10.1
  • react-dom ^18.2.0
  • react-router-dom ^6.22.3
  • styled-components ^6.1.8
backend/Chemistry Cafe API.csproj nuget
  • MSTest.TestAdapter 3.3.1
  • MSTest.TestFramework 3.3.1
  • Microsoft.AspNetCore.Mvc.Testing 8.0.4
  • Microsoft.CodeCoverage 17.9.0
  • Microsoft.NET.Test.Sdk 17.9.0
  • Microsoft.VisualStudio.Azure.Containers.Tools.Targets 1.19.6
  • MySqlConnector 2.3.5
  • MySqlConnector.DependencyInjection 2.3.5
  • Swashbuckle.AspNetCore 6.5.0
  • coverlet.collector 6.0.2
  • coverlet.msbuild 6.0.2
  • xunit.extensibility.core 2.7.1