Skip to content

Commit 0647a28

Browse files
authored
feat: replace Flask backend with Node.js/Express (#269)
* feat: migrate Software Discovery Tool from Flask to Node.js/Express - replace Flask backend with Express + MySQL API implementation - move distro mapping to a single JSON source of truth - restrict CORS via ALLOWED_ORIGINS and add backend tests - add Node.js database build script and update docs - remove deprecated Flask source tree Signed-off-by: TusharB-07 <tusharnbiswas07@gmail.com> * fix: add "type":"module", restore config_build.py, and update Installation.md --------- Signed-off-by: TusharB-07 <tusharnbiswas07@gmail.com>
1 parent 97a264e commit 0647a28

60 files changed

Lines changed: 7276 additions & 4313 deletions

Some content is hidden

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

.DS_Store

8 KB
Binary file not shown.

.env.example

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

.github/workflows/updatesubmodules.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: ssh and git module update
10-
uses: appleboy/ssh-action@master
10+
uses: appleboy/ssh-action@v1.0.3
1111
with:
1212
host: ${{ secrets.HOST }}
1313
username: ${{ secrets.USERNAME }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
*.pyc
22
.env
33
src/config/supported_distros.py
4+
node_modules/
5+
react-frontend/node_modules/
6+
backend/node_modules/
7+
react-frontend/build/
8+
log/
9+
venv/
10+
node_modules/
11+
backend/node_modules/

README.md

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,83 @@ Welcome to the Software Discovery Tool! This tool is designed to help you discov
1010

1111
To get started with the Software Discovery Tool, let's take a quick tour of the project and its repositories.
1212

13-
| Repository | Description |
14-
| -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15-
| [Software Discovery Tool](https://github.com/openmainframeproject/software-discovery-tool) | The main repository of the Software Discovery Tool contains the core functionalities and codebase of the tool. It enables you to search and discover open source software for `zArchitecture/s390x`. You'll find the source code, documentation, and guidelines for contributing to the project in this repository. |
16-
| [Software Discovery Tool Data](https://github.com/openmainframeproject/software-discovery-tool-data) | The Software Discovery Tool Data repository holds the necessary data for the software available in the tool. It contains information such as the names and versions of the software that you can discover using the Software Discovery Tool. This data is regularly updated to provide you with the most comprehensive and up-to-date software inventory. |
13+
| Repository | Description |
14+
| ---------- | ----------- |
15+
| [Software Discovery Tool](https://github.com/openmainframeproject/software-discovery-tool) | The main repository of the Software Discovery Tool contains the core functionalities and codebase of the tool. It enables you to search and discover open source software for `zArchitecture/s390x`. You'll find the source code, documentation, and guidelines for contributing to the project in this repository. |
16+
| [Software Discovery Tool Data](https://github.com/openmainframeproject/software-discovery-tool-data) | The Software Discovery Tool Data repository holds the necessary data for the software available in the tool. It contains information such as the names and versions of the software that you can discover using the Software Discovery Tool. This data is regularly updated to provide you with the most comprehensive and up-to-date software inventory. |
1717
| [Software Discovery Tool Deploy](https://github.com/openmainframeproject/software-discovery-tool-deploy) | The Software Discovery Tool Deploy repository serves as the deployed version of the main Software Discovery Tool repository. It utilizes the main repository as a submodule and integrates the data repository as a sub-submodule. This deployment repository enables you to quickly set up and run the Software Discovery Tool in your environment. Read more about it [here](https://gist.github.com/rachejazz/de39c09612788635d5d0f491dcf8571a). |
1818

19+
## Local Development Setup
20+
21+
To run the Software Discovery Tool locally for development:
22+
23+
### 1. Prerequisites
24+
- Node.js (v18+) and npm
25+
- MariaDB or MySQL server
26+
- Python 3 (only if you need to run `bin/package_build.py`)
27+
28+
### 2. Database Setup
29+
1. Create a database (e.g., `sdtDB`) and a user with `SELECT` permissions.
30+
2. Clone the data submodules:
31+
```bash
32+
git submodule update --init --recursive
33+
```
34+
3. Install root dependencies:
35+
```bash
36+
npm install
37+
```
38+
4. (Optional) Fetch additional distro data (requires Python):
39+
```bash
40+
python3 bin/package_build.py debian
41+
```
42+
5. Initialize the database schema and populate data:
43+
```bash
44+
node bin/database_build.js
45+
```
46+
*Note: Use a privileged database user (like root) when prompted to create tables. This script uses the database configuration from `backend/.env`.*
47+
48+
### 3. Backend Setup
49+
1. Navigate to the `backend` directory:
50+
```bash
51+
cd backend
52+
```
53+
2. Install dependencies:
54+
```bash
55+
npm install
56+
```
57+
3. Configure environment:
58+
Copy `backend/.env.example` to `backend/.env` and fill in your database credentials:
59+
```bash
60+
cp .env.example .env
61+
```
62+
*Note: Set `ALLOWED_ORIGINS` to your frontend URL (e.g., `http://localhost:3000`) to enable CORS.*
63+
4. Start the backend:
64+
```bash
65+
npm start
66+
```
67+
68+
### 4. Frontend Setup
69+
1. Navigate to the `react-frontend` directory:
70+
```bash
71+
cd react-frontend
72+
```
73+
2. Install dependencies:
74+
```bash
75+
npm install
76+
```
77+
3. Configure environment:
78+
Copy `react-frontend/.env.example` to `react-frontend/.env`:
79+
```bash
80+
cp .env.example .env
81+
```
82+
Ensure `REACT_APP_API_URL` points to your backend (default `http://localhost:5000`).
83+
4. Start the frontend:
84+
```bash
85+
npm start
86+
```
87+
88+
The application will be available at `http://localhost:3000`.
89+
1990
## Contributing
2091

2192
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

backend/.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Database Configuration
2+
DB_HOST=localhost
3+
DB_USER=sdtreaduser
4+
DB_PASSWORD=UPDATEME
5+
DB_NAME=sdtDB
6+
7+
# Server Configuration
8+
PORT=5000
9+
ALLOWED_ORIGINS=http://localhost:3000

backend/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:20-slim
2+
3+
WORKDIR /app
4+
5+
COPY package*.json ./
6+
7+
RUN npm install --production
8+
9+
COPY . .
10+
11+
EXPOSE 5000
12+
13+
CMD ["npm", "start"]

backend/config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
8+
const distrosPath = path.join(__dirname, '..', 'config', 'distros.json');
9+
export const SUPPORTED_DISTROS = JSON.parse(fs.readFileSync(distrosPath, 'utf8'));
10+
11+
export const MAX_RECORDS_TO_SEND = 100;

0 commit comments

Comments
 (0)