Skip to content

ErlendHaa/fusion-bmt

 
 

Repository files navigation

Barrier Management Tool

Build Status Codacy Badge

To run the project with docker-compose use:

  • docker-compose up --build

Prerequisites

Frontend

The frontend is built using TypeScript and components from the Equinor Design System (EDS).

Run frontend

cd frontend
npm install
npm start

Formatting

We use Prettier. Remember to set this up.

VSCode settings:

"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true

Page to edit Codacy settings

Backend

The backend is build using .NET 5.0. We use GraphQL to handle requests to the backend, and Hot Chocolate is used as the implementation in .NET.

We are using a Entity Framework SQL database for storing our data. The environment variable Database__ConnectionString can be a ADO.NET connection string to an existing database. If empty we use an InMemory database which is initialized with dummy data.

GraphQL schema

When running locally, a playground server for trying out GraphQL queries will be available at localhost:5000/graphql. This will not work properly in production, since the playground server will not provide a bearer token for authentication. For generating a bearer token and try out the API, the Swagger URL localhost:5000/swagger can be used.

The Schema used for the models in the backend can be found here.

Update frontend schema

When the data models in the backend changes, the corresponding models in frontend has to be updated as well. This is done by executing the command npm run schema in the fronend directory while the backend server is also running. Then there will be created an updated models.ts in the src/api folder which contains the updated models.

Run backend

cd backend/api
dotnet run

Configuration

Database configuration

Make sure you have dotnet-ef installed: dotnet tool install --global dotnet-ef and that you have set your Database__ConnectionString.

Check migrations existing in DB: dotnet ef migrations list

  • Create initial migration: dotnet ef migrations add InitialCreate
  • Delete database: dotnet ef database drop
  • Apply migrations: dotnet ef database update
  • Remove migrations: dotnet ef migrations remove
  • Roll back to earlier migration: dotnet ef database update {migragtion-name}

For populating SQL database with question templates go to backend/scripts make sure your Database__ConnectionString is set and run dotnet run -t PATH-TO-FILE. An example file of question templates: backend/api/Context/InitQuestions.json

Environment variables

Frontend Backend
Required AzureAd__ClientSecret
Optional API_URL
AD_APP_ID
ASPNETCORE_ENVIRONMENT
HTTPONLY
Database__ConnectionString

Deploy

We have 3 different environments in use; dev, test and prod. Dev is the environment that runs when pushing to master. Test and prod will run when pushing to the specific branches. Dev will only deploy to Radix environment, but Test and Prod will deploy the frontend to both Radix and Fusion.

Deploy to a specific environment is done by pushing a branch to the following branch:

git push upstream master:prod -f

This deploys the local master to prod environment. Remember to pull from upstream before performing this.

Dev

Test

Prod

Model overview

alt text

Etc

Packages

No packages published

Languages

  • TypeScript 58.8%
  • C# 40.5%
  • Other 0.7%