Skip to content

Commit 6fd887f

Browse files
authored
Merge pull request #26 from cahaseler/22-add-sql-support-to-web-and-local-app-with-prisma-orm
Feat: SQL Database structure and seeding
2 parents a9898e4 + 30f4d72 commit 6fd887f

File tree

44 files changed

+155836
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+155836
-292
lines changed

.eslintrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"extends": [
33
"eslint:recommended",
4-
"prettier",
5-
"plugin:prettier/recommended",
64
"plugin:tailwindcss/recommended",
75
"plugin:react/recommended",
86
"next"
@@ -31,7 +29,7 @@
3129
},
3230
//Disable tailwindcss/no-custom-classname for the directories where we're not using tailwind
3331
{
34-
"files": ["pages/**", "components/**", "app/(bootstrap)/**"],
32+
"files": ["components/**"],
3533
"rules": {
3634
"tailwindcss/no-custom-classname": "off"
3735
}

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,10 @@ src-tauri/target/
6464
web_static/app/(frontend)/**/*
6565
web_static/public/**/*
6666
web_static/components/**/*
67-
web_static/lib/**/*
67+
web_static/lib/**/*
68+
/web_backend/target/*
69+
70+
# Exclude generated prisma clients, these are recreated on build
71+
/web/prisma/**/generated/*
72+
73+

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.14.0

.yarn/releases/yarn-4.4.0.cjs

Lines changed: 925 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarnPath: .yarn/releases/yarn-4.4.0.cjs

README.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=cahaseler_EMPACT&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=cahaseler_EMPACT)
77
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=cahaseler_EMPACT&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=cahaseler_EMPACT)
88

9-
**EMPACT: The Environment and Maturity Program Assessment and Control Tool** is an Open Source implementation of the IP2M METRR Environmental and Maturity evaluation model. The IP2M METRR model was developed by the US Department of Energy in collaboration with Arizona State University. EMPACT is an open source project intended as a collaborative effort by the greater earned value community and is not at this time funded or endorsed by ASU or DOE.
9+
**EMPACT: The Environment and Maturity Program Assessment and Control Tool** is an Open Source implementation of the IP2M METRR Environmental and Maturity evaluation model. The IP2M METRR model was developed by the US Department of Energy in collaboration with Arizona State University. EMPACT is an open source project intended as a collaborative effort by the greater earned value community and is not at this time funded or endorsed by ASU.
1010

1111
This tool is based on the originally published research findings in the DOE-funded study but is developed independently from ASU's proprietary IP2M METRR tool and does not reuse any code from that tool. Development priorities and features are derived from practical lessons learned from use of ASU's IP2M METRR tool.
1212

@@ -68,10 +68,76 @@ Here is the approach that will be followed:
6868

6969
This is an open source project and intended as a collaborative effort. Especially if you or your organization is using this software to facilitate reviews or otherwise benefit, there is an informal expectation that you give back to the greater earned value community by contributing to the codebase and collaborating on this project.
7070

71+
## Sponsors
72+
73+
This project is sponsored by the United States Department of Energy's Office of Project Management. Specifically, the Office has approved usage of paid contractor development hours towards working on this project.
74+
7175
## Code Structure
7276

7377
The codebase is organized as follows, with files relating to the whole project at the parent level and subfolders for specific components:
7478

7579
- /src-tauri: The code used for the Tauri local application, including the Rust functions for interacting with the database and configuration for the Tauri app.
7680
- /web: The NextJS application to be run on the server, containing the UI, API routes, and security layers. The UI is written in a way that works for both platforms, that is to say it calls generically named functions that use API calls in the web version and use Rust functions in the local version.
7781
- /web_static: A seperate NextJS website containing configuration for the static export required for the Tauri app. UI code in this folder is copied in from the web folder and should not be edited. In general this folder shouldn't need to be edited.
82+
83+
## Database Structure
84+
85+
See the [Prisma Schema](https://github.com/empact/EMPACT/blob/main/prisma/schema.prisma) for more details on the database schema, a diagram is below:
86+
87+
![Database Diagram](database.png)
88+
89+
## Installation
90+
91+
There are several approaches available to use this tool, described below.
92+
93+
### Standalone usage
94+
95+
Simply download and run the application installer provided in the Releases section of the Github Repository here: [https://github.com/empact/EMPACT/releases](https://github.com/empact/EMPACT/releases). The tool can be installed and run offline, with data stored on your local machine. Data can be exported using the export tools to provide it to others.
96+
97+
Advantages to this approach:
98+
99+
- No need for an external server or any database configuration
100+
- No need for an internet connection after initial installation
101+
- Simplified interface without user management or other complexity included in a multi-user system
102+
103+
Disadvantages to this approach:
104+
105+
- Single user, no group assessments supported
106+
- Requires installation rights on your local machine
107+
- Windows only, no MacOS support at this time (if you are willing to sponsor development costs for MacOS support, please contact us)
108+
109+
### Server installation with external MSSQL or PostGreSQL databases
110+
111+
This is the reccomended approach for a production level application, and involves installing the server Docker container and configuring it to point to an external PostGreSQL or MSSQL database that you own and manage - likely one that you use for other applications already. See the [Installation Guide](https://github.com/cahaseler/EMPACT/INSTALL.md) for more details.
112+
113+
Advantages to this approach:
114+
115+
- Multi-user assessments supported, along with appropriate roll-up reporting
116+
- Browser based web application that can be accessed from any computer with network access to the server, over the internet or an internal network
117+
- No operating system installation required, supports MacOS and other non-Windows platforms
118+
- Data is stored in your existing managed database solutions, making it available to other analytics platforms you may have, and providing your data with existing redundancy and security controls
119+
- Users can leverage single sign on via your existing authentication solution
120+
121+
Disadvantages to this approach:
122+
123+
- Requires server configuration and setup
124+
- Requires setting up the external database and opening appropriate connections between the EMPACT server and your database
125+
- No offline functionality
126+
127+
### Server installation with included PostGreSQL database docker container
128+
129+
This allows you to set up EMPACT as a standalone server running both the EMPACT container and a PostGreSQL database. See the [Installation Guide](https://github.com/cahaseler/EMPACT/INSTALL.md) for more details.
130+
131+
Advantages to this approach:
132+
133+
- Multi-user assessments supported, along with appropriate roll-up reporting
134+
- Browser based web application that can be accessed from any computer with network access to the server, over the internet or an internal network
135+
- No operating system installation required, supports MacOS and other non-Windows platforms
136+
- No existing systems or databased are needed, this is an all-in-one solution that includes both the database and the EMPACT server with no external connections
137+
- Users can leverage single sign on via your existing authentication solution
138+
139+
Disadvantages to this approach:
140+
141+
- Requires server configuration and setup
142+
- Database remains on the same server as EMPACT, meaning you will need to configure your own backups and security controls to ensure data retention
143+
- No offline functionality

database.png

190 KB
Loading

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,5 @@
3131
"devDependencies": {
3232
"@tauri-apps/cli": "1.6.0"
3333
},
34-
"dependencies": {
35-
},
36-
"packageManager": "[email protected]"
34+
"packageManager": "[email protected]"
3735
}

web/.eslintrc

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"extends": [
3+
"eslint:recommended",
4+
"prettier",
5+
"plugin:prettier/recommended",
6+
"plugin:tailwindcss/recommended",
7+
"plugin:react/recommended",
8+
"next"
9+
],
10+
"plugins": ["tailwindcss", "react", "jsdoc"],
11+
"rules": {
12+
//required for NextJS
13+
"react/react-in-jsx-scope": "off",
14+
"react/display-name": "off",
15+
"prettier/prettier": "error",
16+
"import/no-unresolved": "off",
17+
//report unused vars, unless they're exported. Currently a warning only since we have too much of this to fix
18+
"no-unused-vars": ["off", { "vars": "local" }],
19+
"react/prefer-read-only-props": "warn",
20+
"jsdoc/check-alignment": 1,
21+
"jsdoc/no-types": 1,
22+
"jsdoc/no-undefined-types": 1
23+
},
24+
// We don't want to check for undefineds in typescript since typescript already does that better
25+
"overrides": [
26+
{
27+
"files": ["*.ts", "*.tsx"],
28+
"rules": {
29+
"no-undef": "off"
30+
}
31+
}
32+
],
33+
"settings": {
34+
"tailwindcss": {
35+
"callees": ["cn", "cva"],
36+
"config": "tailwind.config.js"
37+
},
38+
"react": {
39+
"createClass": "createReactClass", // Regex for Component Factory to use,
40+
// default to "createReactClass"
41+
"pragma": "React", // Pragma to use, default to "React"
42+
"fragment": "Fragment", // Fragment to use (may be a property of <pragma>), default to "Fragment"
43+
"version": "detect" // React version. "detect" automatically picks the version you have installed.
44+
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
45+
// It will default to "latest" and warn if missing, and to "detect" in the future
46+
},
47+
"formComponents": [
48+
// Components used as alternatives to <form> for forms, eg. <Form endpoint={ url } />
49+
"Form"
50+
],
51+
"linkComponents": [
52+
// Components used as alternatives to <a> for linking, eg. <Link to={ url } />
53+
{ "name": "Link", "linkAttribute": "href=" }
54+
]
55+
},
56+
"globals": {
57+
"React": "writable",
58+
"JSX": "readonly"
59+
},
60+
"env": {
61+
"browser": true,
62+
"node": true,
63+
"es6": true
64+
}
65+
}

web/.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)