Skip to content

Commit 58dcdaf

Browse files
authored
Vis improvement 2 (#53)
* feat: enhance UI components and improve accessibility - Updated typography styles across various components for better readability and consistency. - Changed heading levels and classes in DependencyDetails for improved semantic structure. - Refined button and text styles in HeaderControls and Header for a more cohesive design. - Enhanced error messages and loading indicators in MainContent for better user experience. - Improved session ID generation logic in utils for better uniqueness. - Added connection header to API requests for better performance. - Adjusted dropdown and tooltip components for improved usability and aesthetics. - Fixed minor bugs and improved overall code quality. * Add backend setup script and UI/CLI tweaks Add a backend setup-and-run.sh script and corresponding package scripts (root and backend) to automate environment creation, dependency install, DB container start, Drizzle schema generation/push, and dev server start; also add an MCP dev script and README quick-start/MCP notes. Update backend package.json and lockfile to include new dependencies required by these tools. Remove an old image optimization script. Apply assorted frontend/CLI refinements: adjust global font and diagram sizing, tweak dependency sidebar styling and tab label, enhance CodeBlock with a label and spacing, label batch commands, change save-analysis-history to deduplicate across all dates, and expand CLI command help/options and output formatting. These changes streamline local backend setup and improve UX for scanning/fixing workflows.
1 parent 845a614 commit 58dcdaf

15 files changed

Lines changed: 270 additions & 77 deletions

File tree

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ Clone the repository and open the repository in any text editor/IDE you like.
4343

4444
## Backend
4545

46+
- Quick start (one command from project root):
47+
48+
```bash
49+
bun run backend:setup
50+
```
51+
52+
- This command will:
53+
- create `backend/.env` if missing
54+
- set local defaults for `PORT`, `NODE_ENV`, `DEV_ORIGIN`, and `DATABASE_URL` (only if empty/missing)
55+
- install backend dependencies
56+
- start or create the Postgres Docker container
57+
- run Drizzle schema generation + push
58+
- start the backend dev server
59+
60+
- Manual setup (if you prefer step-by-step):
61+
4662
- Navigate to the **./backend** directory inside the repository
4763

4864
```bash
@@ -90,6 +106,21 @@ Clone the repository and open the repository in any text editor/IDE you like.
90106
bun run dev
91107
```
92108

109+
### MCP (Phase 1)
110+
111+
- Run the local MCP server (stdio transport) with:
112+
113+
```bash
114+
bun run backend:mcp
115+
```
116+
117+
- Phase 1 tools:
118+
- `scan_repo`
119+
- `scan_manifest`
120+
- `list_vulnerabilities`
121+
122+
- Full MCP notes are in `backend/mcp/README.md`.
123+
93124
# Ideation and Motivation
94125

95126
I came across <a href='https://gitdiagram.com/'>GitDiagram</a> where I made some contributions to the repository, I also had some idea to before this to build something like a visualisation for vulnerable dependencies, which can help people find, see and resolve them easily.

backend/bun.lock

Lines changed: 32 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"type": "commonjs",
99
"main": "index.js",
1010
"scripts": {
11+
"setup:dev": "./setup-and-run.sh",
12+
"mcp:dev": "bun mcp/server.ts",
1113
"dev": "bun --watch server.ts",
1214
"build": "cross-env NODE_ENV=production tsc",
1315
"start": "bun server.ts",
@@ -34,6 +36,7 @@
3436
"@langchain/core": "^0.3.72",
3537
"@langchain/google-genai": "^0.2.16",
3638
"@langchain/langgraph": "^0.4.9",
39+
"@modelcontextprotocol/sdk": "^1.26.0",
3740
"@openrouter/sdk": "^0.3.11",
3841
"@types/pg": "^8.15.5",
3942
"ae-cvss-calculator": "^1.0.8",
@@ -49,7 +52,8 @@
4952
"morgan": "^1.10.1",
5053
"multer": "^2.0.2",
5154
"pg": "^8.16.3",
52-
"xml2js": "^0.6.2"
55+
"xml2js": "^0.6.2",
56+
"zod": "^3.25"
5357
},
5458
"devDependencies": {
5559
"@types/cors": "^2.8.19",

backend/setup-and-run.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
cd "$SCRIPT_DIR"
6+
7+
require_command() {
8+
local cmd="$1"
9+
if ! command -v "$cmd" >/dev/null 2>&1; then
10+
echo "Error: '$cmd' is required but not installed."
11+
exit 1
12+
fi
13+
}
14+
15+
random_password() {
16+
if command -v openssl >/dev/null 2>&1; then
17+
openssl rand -base64 12 | tr '+/' '-_'
18+
else
19+
date +%s | shasum | awk '{print substr($1,1,16)}'
20+
fi
21+
}
22+
23+
upsert_env_value() {
24+
local key="$1"
25+
local value="$2"
26+
27+
if grep -q "^${key}=" .env; then
28+
local current_value
29+
current_value="$(grep "^${key}=" .env | tail -n 1 | cut -d '=' -f 2-)"
30+
if [ -z "$current_value" ]; then
31+
awk -v key="$key" -v value="$value" '
32+
BEGIN { replaced = 0 }
33+
{
34+
if ($0 ~ "^" key "=$" && replaced == 0) {
35+
print key "=" value
36+
replaced = 1
37+
} else {
38+
print $0
39+
}
40+
}
41+
' .env > .env.tmp && mv .env.tmp .env
42+
fi
43+
else
44+
echo "${key}=${value}" >> .env
45+
fi
46+
}
47+
48+
require_command bun
49+
require_command docker
50+
51+
if [ ! -f .env ]; then
52+
if [ -f .env.example ]; then
53+
cp .env.example .env
54+
else
55+
touch .env
56+
fi
57+
echo "Created backend/.env"
58+
fi
59+
60+
DB_PASSWORD="$(random_password)"
61+
upsert_env_value "PORT" "8080"
62+
upsert_env_value "NODE_ENV" "development"
63+
upsert_env_value "DEV_ORIGIN" "http://localhost:3000"
64+
upsert_env_value "DATABASE_URL" "postgresql://gitdepsec:${DB_PASSWORD}@localhost:5432/gitdepsec"
65+
66+
echo "Installing backend dependencies..."
67+
bun install
68+
69+
echo "Starting database container..."
70+
./database-start.sh
71+
72+
echo "Generating and pushing Drizzle schema..."
73+
bun run db:generate
74+
bun run db:push
75+
76+
echo "Starting backend server..."
77+
bun run dev

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6+
"backend:setup": "bun --cwd backend run setup:dev",
7+
"backend:mcp": "bun --cwd backend run mcp:dev",
68
"dev": "cross-env NODE_ENV=development next dev --turbopack",
79
"build": "cross-env NODE_ENV=production && next build",
810
"start": "cross-env NODE_ENV=production next start",

0 commit comments

Comments
 (0)