Skip to content

rishalab/COBRisk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⬑ CORisk β€” COBOL Migration Risk Scorer

Statically analyze your COBOL codebase and score each module across 5 risk dimensions β€” so your team migrates smart, not blind.


πŸ“ Full Project Structure

CORisk/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app.py              ← Flask API server (main entry point)
β”‚   β”œβ”€β”€ analyzer.py         ← Core COBOL risk analysis engine
β”‚   └── requirements.txt    ← Python dependencies
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── index.html      ← HTML shell with Google Fonts
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ index.js        ← React entry point
β”‚   β”‚   β”œβ”€β”€ index.css       ← Global CSS variables & theme
β”‚   β”‚   β”œβ”€β”€ App.js          ← Root component (page routing)
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ LandingPage.js          ← Upload page
β”‚   β”‚   β”‚   β”œβ”€β”€ LandingPage.module.css
β”‚   β”‚   β”‚   β”œβ”€β”€ DashboardPage.js        ← Results dashboard
β”‚   β”‚   β”‚   └── DashboardPage.module.css
β”‚   β”‚   └── components/
β”‚   β”‚       β”œβ”€β”€ SummaryCards.js         ← KPI stat cards + donut chart
β”‚   β”‚       β”œβ”€β”€ SummaryCards.module.css
β”‚   β”‚       β”œβ”€β”€ ModuleTable.js          ← Sortable/filterable table
β”‚   β”‚       β”œβ”€β”€ ModuleTable.module.css
β”‚   β”‚       β”œβ”€β”€ ModuleDetail.js         ← Side panel with radar chart
β”‚   β”‚       β”œβ”€β”€ ModuleDetail.module.css
β”‚   β”‚       β”œβ”€β”€ DependencyGraph.js      ← D3 force-directed canvas graph
β”‚   β”‚       β”œβ”€β”€ DependencyGraph.module.css
β”‚   β”‚       β”œβ”€β”€ MigrationPlan.js        ← Phased roadmap + checklist
β”‚   β”‚       └── MigrationPlan.module.css
β”‚   └── package.json
β”‚
β”œβ”€β”€ sample_cobol/
β”‚   β”œβ”€β”€ CUSTPROC.cob        ← Customer processing (HIGH risk demo)
β”‚   β”œβ”€β”€ VALCUST.cob         ← Validation utility (LOW risk demo)
β”‚   └── RPTGEN.cob          ← Report generator (MEDIUM risk demo)
β”‚
└── README.md

βš™οΈ Prerequisites

Tool Version Install
Python 3.9+ https://python.org
Node.js 18+ https://nodejs.org
npm 9+ Comes with Node.js
Git any https://git-scm.com

Check your versions:

python --version
node --version
npm --version

πŸš€ Setup & Run (Step by Step)

Step 1 β€” Clone / download the project

# If using git:
git clone <your-repo-url>
cd CORisk

# OR if you downloaded a zip, just extract and cd into it:
cd CORisk

Step 2 β€” Set up the Backend (Python / Flask)

# Navigate to backend folder
cd backend

# Create a virtual environment (recommended)
python -m venv venv

# Activate it:
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Start the Flask server
python app.py

βœ… You should see:

* Running on http://127.0.0.1:5000
* Debug mode: on

Leave this terminal open!


Step 3 β€” Set up the Frontend (React)

Open a new terminal window:

# From the CORisk root directory
cd frontend

# Install all npm packages (takes ~1-2 minutes first time)
npm install

# Start the React dev server
npm start

βœ… Your browser will auto-open at:

http://localhost:3000

πŸ§ͺ Using CORisk

Option A β€” Try Sample Files

  1. Open http://localhost:3000
  2. Click "Try Sample Files"
  3. The backend loads the 3 sample COBOL files from sample_cobol/
  4. Results appear instantly on the Dashboard

Option B β€” Upload Your Own COBOL Files

  1. Open http://localhost:3000
  2. Drag & drop your .cob / .cbl / .cpy files onto the dropzone
  3. Click "⚑ Analyze Risk"
  4. Explore the 4 dashboard tabs:
    • πŸ“Š Overview β€” Summary KPI cards + quick module list
    • πŸ“‹ Module Scores β€” Full sortable table; click any row for detail panel
    • πŸ•ΈοΈ Dependency Graph β€” Interactive force graph; drag nodes, click for details
    • πŸ—ΊοΈ Migration Plan β€” Phase-by-phase roadmap + MRI bar chart + checklist

πŸ“Š The 5 Risk Metrics Explained

Metric Weight What It Measures
Coupling Density 30% Inbound CALLs + shared file operations
Documentation Deficit 25% Comment-to-code ratio (low = risky)
Logic Volatility 20% GOTO count + paragraph count
Data Complexity 15% REDEFINES + COMP-3 + EBCDIC fields
Dead Code Ratio 10% Paragraphs defined but never PERFORMed

MRI (Migration Risk Index) = weighted sum of all 5 metrics (0–100).

MRI Range Risk Tier Action
0–34 🟒 LOW Safe to migrate now
35–59 🟑 MEDIUM Migrate with caution
60–100 πŸ”΄ HIGH Do NOT migrate yet

πŸ€– AI Suggestions Setup (Groq)

AI suggestions are powered by Groq's free LLM API (llama3-8b-8192).
The API key lives only in backend/.env β€” it is never sent to the frontend.

Step 1 β€” Get your free Groq API key

  1. Go to https://console.groq.com/
  2. Sign up (free, no credit card needed)
  3. Click "API Keys" β†’ "Create API Key"
  4. Copy the key

Step 2 β€” Add it to your .env file

Open backend/.env and replace the placeholder:

GROQ_API_KEY=gsk_your_actual_key_here
GROQ_MODEL=llama3-8b-8192

Step 3 β€” Restart the backend

# Stop the backend (Ctrl+C) then restart:
python app.py

Step 4 β€” Verify it's working

curl http://localhost:5000/api/ai-status
# Should return: {"configured": true, ...}

βœ… The dashboard header now shows "πŸ€– AI Ready" in green.

How it works

  • When you click "Get AI Suggestions" on a MEDIUM/HIGH risk module β†’ backend calls Groq β†’ returns structured JSON
  • When you click "Generate AI Suggestions for All Modules" in the Migration Plan tab β†’ batch call for all risky modules
  • LOW risk modules are skipped automatically
  • The API key is never exposed to the React frontend

Available Groq models (all free)

Model Speed Quality
llama3-8b-8192 ⚑ Fastest Good (default)
llama3-70b-8192 Slower Best quality
mixtral-8x7b-32768 Medium Great for long context

Change model in backend/.env:

GROQ_MODEL=llama3-70b-8192

πŸ”Œ API Endpoints (updated)

Method Endpoint Description
GET /api/health Health check + AI status
POST /api/analyze Upload and analyze COBOL files
GET /api/analyze-sample Analyze built-in sample files
POST /api/ai-suggest Get AI suggestions for a single module
POST /api/ai-suggest-all Get AI suggestions for all MEDIUM+HIGH modules
GET /api/ai-status Check if Groq API key is configured
Method Endpoint Description
GET /api/health Health check
POST /api/analyze Upload and analyze COBOL files
GET /api/analyze-sample Analyze built-in sample files

Example API call (curl):

curl -X POST http://localhost:5000/api/analyze \
  -F "files=@CUSTPROC.cob" \
  -F "files=@VALCUST.cob"

πŸ› Troubleshooting

"CORS error" in browser

Make sure the Flask backend is running on port 5000.

"No valid COBOL files found"

Ensure your files have .cob, .cbl, or .cpy extensions.

Frontend shows "Analysis failed"

Backend is not running. Start it first with python app.py.

Port 3000 already in use

# Kill whatever is on port 3000, or use a different port:
PORT=3001 npm start

Port 5000 already in use (macOS AirPlay)

# Edit backend/app.py, change the last line to:
app.run(debug=True, port=5001)
# Then update frontend/package.json "proxy" to http://localhost:5001

πŸ”¬ Adding More COBOL Files

Just drop .cob or .cbl files into sample_cobol/ to expand the sample dataset. Or upload any number of files directly via the UI.


πŸ—οΈ Tech Stack

Layer Technology
Backend Python 3 + Flask + Flask-CORS
Analysis Pure Python regex + graph algorithms
Frontend React 18 + CSS Modules
Charts Recharts (radar, bar, radial)
Graph Canvas 2D API with custom force simulation
Fonts Syne (display) + DM Sans (body) + DM Mono

πŸ“„ License

MIT β€” free to use, modify, and publish.

Built with ❀️ at RISHA Lab, IIT Tirupati.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors