Skip to content

AI4Green4Students is a pedagogical version of AI4Green, promoting sustainable chemistry practices and research data management.

Notifications You must be signed in to change notification settings

AI4Green/AI4Green4Students

Repository files navigation

Introduction

This repository is for AI4Green4Students.

This currently consists of a .NET backend that interacts with a PostgreSQL database.

Getting Started

Prerequisites

  1. .NET SDK 8.x
    • The backend API is .NET8
  2. Node.js >=16.9
    • 16.9 and newer include Corepack
  3. Enable Corepack
    • Simply run corepack enable in your cli
  4. Docker

Database setup

The application stack interacts with a PostgreSQL Server database, and uses code-first migrations for managing the database schema.

The repository contains a docker-compose for the database, so just run docker-compose up -d to start it running.

When setting up a new environment, or running a newer version of the codebase if there have been schema changes, you need to run migrations against your database server.

The easiest way is using the dotnet cli:

  1. If you haven't already, install the local Entity Framework tooling

    • Anywhere in the repo: dotnet tool restore
  2. Navigate to the same directory as AI4Green4Students.csproj

  3. Run migrations:

    • dotnet ef database update
    • The above runs against the default local server, using the connection string in appsettings.Development.json
    • You can specify a connection string with the --connection "<connection string>" option

Working with JavaScript

This monorepo uses pnpm workspaces to manage JS dependencies and scripts.

Basically, where you might normally use npm or yarn, please use pnpm commands instead.

You don't need to install anything special; Corepack will.

A brief pnpm cheatsheet is provided later in this document.

📁 Repository contents

Areas within this repo include:

  • Application Source Code
    • .NET8 backend API AI4Green4Students
    • Azure Functions App az-functions
    • React (Vite) frontend web app client-app

Backend Configuration

Notes on configuration values that can be provided, and their defaults.

The backend app can be configured in any standard way an ASP.NET Core application can. Typically from the Azure Portal (Environment variables) or an appsettings.json.

OutboundEmail:
  ServiceName: AI4Green4Students
  FromName: No Reply
  FromAddress: noreply@example.com
  ReplyToAddress: ""
  Provider: local

  # If Provider == "local"
  LocalPath: /temp

  # If Provider == "sendgrid"
  SendGridApiKey: ""

  # If Provider == "smtp"
  SmtpHost: "" # SMTP host name
  SmtpPort: # SMTP port
  SmtpUsername: "" # SMTP username
  SmtpPassword: "" # SMTP password
  SmtpSecureSocketEnum: # for example, assign 2 to implement SslOnConnect
  # Secure socket options
  # 1 - Auto
  # 2 - SslOnConnect
  # 3 - StartTls
  # 4 - StartTlsWhenAvailable

  # More information can be found here
  # http://www.mimekit.net/docs/html/T_MailKit_Security_SecureSocketOptions.htm

  ExcludedEmailAddresses: [] # Array of email addresses excluded from receiving emails, typically used for test or dummy emails.
  # Only applies to SMTP email provider for now.

Build a database with PubChem data for local development

Step 1 - Setup

  • Install Poetry

  • Clone the AI4Green repository.

  • Navigate to the project directory. cd AI4Green

  • Install the project dependencies. poetry install

  • Activate the virtual env created by Poetry. poetry shell

Step 2 - App Configuration

Configuration is controlled by PubChemSeeding/sources/config.py, the default values can be overridden by setting environment variables.

DATABASE_URL: postgresql://postgres:example@localhost:5433/ai4green # Postgres database connection string.
COMPOUND_LIMIT: 10000 # Sets the limit for the number of compounds extracted from PubChem. Note that a large database can cause smaller servers to crash.

Step 3 - Download PubChem data and build db

  • Navigate to the directory Webapp. cd Webapp.

  • Run flask db upgrade to make database migrations.

  • Run flask download-pubchem to download the PubChem database.

  • Run flask seed-db to seed data from the download.

About

AI4Green4Students is a pedagogical version of AI4Green, promoting sustainable chemistry practices and research data management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages