This is a railway train management system that mimics IBM Maximo functionality. It provides a web interface to manage railway datasets and integrates with Google Sheets for live data storage.
- Train Master Management: Add/edit train information
- Branding Campaigns: Manage advertising campaigns on trains
- Fitness Certificates: Track safety certifications
- Job Cards: Maintenance task management
- Mileage Records: Track train usage and service intervals
- Stabling Geometry: Depot layout and movement data
IBM Maximo Clone (HTML/CSS/JS) → Google Sheets → MetroChetna Algorithm
-
File Structure Created:
index.html- Main application interfacestyles.css- Styling and responsive designscript.js- JavaScript functionality
-
Run Locally:
- Open
index.htmlin a web browser - Test navigation and form interfaces
- Currently uses sample data
- Open
- Go to Google Sheets
- Create a new spreadsheet named "Railway-Maximo-Data"
- Create these sheets (tabs):
train_masterbrandingfitness_certificatesjob_cardsmileagestabling_geometry
Copy headers from your existing CSV files to each sheet:
train_master sheet:
Train_ID | Year_Commissioned | Base_Mileage | Last_Service_Type | Last_Service_Date | Current_Status
branding sheet:
Campaign_ID | Train_ID | Advertiser_ID | Campaign_Name | Start_Date | End_Date | Required_Exposure_Hours | Accumulated_Exposure_Hours | Penalty_Per_Day | Remaining_Hours
(Similar for other sheets)
- Copy data from your CSV files into the respective Google Sheets
- Format dates properly
- Test data accessibility
Method 1: API Key (Simplest - Recommended for testing)
- Go to Google Cloud Console
- Create a new project:
- Click "Select a project" → "New Project"
- Name: "Railway-Maximo-API"
- Click "Create"
- Enable Google Sheets API:
- Go to "APIs & Services" → "Library"
- Search for "Google Sheets API"
- Click on it and press "Enable"
- Create API Key:
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "API Key"
- Copy the API key (keep it secure!)
- Click "Restrict Key" to add security:
- Under "API restrictions", select "Restrict key"
- Choose "Google Sheets API"
- Save
Method 2: Service Account (Production - More Secure)
- Follow steps 1-3 above
- Create Service Account:
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "Service Account"
- Name: "railway-maximo-service"
- Click "Create and Continue"
- Skip role assignment for now, click "Done"
- Generate Key File:
- Click on the created service account
- Go to "Keys" tab
- Click "Add Key" → "Create New Key"
- Choose "JSON" format
- Download and save the JSON file securely
- Share Google Sheet with Service Account:
- Open your Google Sheet
- Click "Share" button
- Add the service account email (from JSON file)
- Give "Editor" permissions
For API Key Method:
In script.js, update the Google Sheets configuration:
const GOOGLE_SHEETS_CONFIG = {
spreadsheetId: 'YOUR_ACTUAL_SPREADSHEET_ID', // Get from Google Sheets URL
apiKey: 'YOUR_ACTUAL_API_KEY', // From Google Cloud Console
sheets: {
trains: 'train_master',
branding: 'branding',
fitness: 'fitness_certificates',
jobcards: 'job_cards',
mileage: 'mileage',
stabling: 'stabling_geometry'
}
};How to find your Spreadsheet ID:
- Open your Google Sheet
- Look at the URL:
https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit - Copy the long string between
/d/and/edit
For Service Account Method: You'll need to implement server-side authentication or use the Apps Script approach (recommended).
- In your Google Sheet, go to Extensions → Apps Script
- Create functions for CRUD operations
- Deploy as web app
- Update JavaScript to call your Apps Script endpoints
- Create a Node.js/Express server
- Use Google Sheets API server-side
- Deploy to Heroku/Vercel/similar platform
- Update frontend to call your API
- Option 1: Direct Google Sheets access using Sheets API
- Option 2: Export data to CSV files periodically
- Option 3: Database integration with export functionality
// In Google Apps Script (script.google.com)
function doPost(e) {
const data = JSON.parse(e.postData.contents);
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(data.sheetName);
// Add row to sheet
sheet.appendRow(Object.values(data.rowData));
return ContentService.createTextOutput(JSON.stringify({success: true}));
}
function doGet(e) {
const sheetName = e.parameter.sheet;
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
const data = sheet.getDataRange().getValues();
return ContentService.createTextOutput(JSON.stringify(data))
.setMimeType(ContentService.MimeType.JSON);
}- Save the script
- Click "Deploy" → "New Deployment"
- Choose "Web app" type
- Set execution as "Me" and access as "Anyone"
- Copy the web app URL
// In script.js
const APPS_SCRIPT_URL = 'YOUR_APPS_SCRIPT_WEB_APP_URL';
async function saveToGoogleSheets(sheetName, data) {
const response = await fetch(APPS_SCRIPT_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ sheetName, rowData: data })
});
return response.json();
}- Add data through web interface
- Verify it appears in Google Sheets
- Test that MetroChetna can read the updated data
- Ensure Train IDs are consistent across sheets
- Validate date formats
- Check numerical data ranges
- API Key Protection: Use environment variables or server-side proxy
- Data Validation: Sanitize inputs before saving
- Access Control: Implement user authentication if needed
- Backup: Regular exports of Google Sheets data
- Regular Backups: Export sheets to CSV monthly
- Data Cleanup: Remove old/irrelevant records
- Performance: Monitor API usage limits
- Updates: Keep MetroChetna integration tested
- Airtable: More database-like features
- Firebase: Real-time database with good web integration
- Traditional Database: PostgreSQL/MySQL with web interface
- API Limits: Google Sheets API has usage limits
- CORS Issues: May need server-side proxy for production
- Data Synchronization: Handle concurrent updates carefully
- Batch operations when possible
- Cache frequently accessed data
- Use pagination for large datasets
- Implement loading states in UI
Step-by-Step Process:
- Open Google Apps Script: Go to script.google.com
- Create New Project: Click "New Project"
- Paste Code: Copy all code from
google-apps-script.jsfile - Save: Give it a name like "Railway-Maximo-Backend"
- Deploy as Web App:
- Click "Deploy" → "New Deployment"
- Type: "Web app"
- Execute as: "Me"
- Who has access: "Anyone"
- Click "Deploy"
- Copy Web App URL: Save this URL - you'll need it in JavaScript
- Update script.js: Replace
APPS_SCRIPT_URLwith your web app URL
No API keys needed with this method!
Step 1: Google Cloud Console Setup
- Go to console.cloud.google.com
- Sign in with your Google account
- Create Project:
- Click project dropdown → "New Project"
- Project name: "Railway-Maximo-SIH"
- Click "Create"
Step 2: Enable APIs
- In the left sidebar: "APIs & Services" → "Library"
- Search "Google Sheets API"
- Click on it → Click "Enable"
- Search "Google Drive API"
- Click on it → Click "Enable" (needed for file access)
Step 3: Create Credentials
- Go to "APIs & Services" → "Credentials"
- Click "+ CREATE CREDENTIALS" → "API Key"
- Copy the API Key (save it somewhere safe!)
- Click "RESTRICT KEY" for security:
- Under "Application restrictions": Select "HTTP referrers"
- Add your domain (or
*for testing) - Under "API restrictions": Select "Restrict key"
- Choose: "Google Sheets API" and "Google Drive API"
- Click "Save"
Step 4: Get Spreadsheet ID
- Open your Google Sheet
- Look at the URL:
https://docs.google.com/spreadsheets/d/SPREADSHEET_ID_HERE/edit - Copy the long ID between
/d/and/edit
Step 5: Make Sheet Public (for API access)
- In your Google Sheet, click "Share"
- Change to "Anyone with the link can view"
- Copy the share link
Step 6: Update JavaScript
// In script.js, update these values:
const GOOGLE_SHEETS_CONFIG = {
spreadsheetId: '1a2b3c4d5e6f7g8h9i0j', // Your actual spreadsheet ID
apiKey: 'AIzaSyABC123XYZ789', // Your actual API key
sheets: {
trains: 'train_master',
branding: 'branding',
fitness: 'fitness_certificates',
jobcards: 'job_cards',
mileage: 'mileage',
stabling: 'stabling_geometry'
}
};Quick Test:
- Open browser developer tools (F12)
- Go to Console tab
- Type this test (replace with your values):
fetch('https://sheets.googleapis.com/v4/spreadsheets/YOUR_SPREADSHEET_ID/values/train_master?key=YOUR_API_KEY')
.then(response => response.json())
.then(data => console.log(data));- If you see data, it's working!
"API key not valid" Error:
- Check if Google Sheets API is enabled
- Verify API key restrictions
- Make sure spreadsheet is shared publicly
"The caller does not have permission" Error:
- Make spreadsheet public (Anyone with link can view)
- Check API key restrictions
- Ensure correct spreadsheet ID
CORS Error:
- Use Apps Script method instead
- Or deploy through a web server
"Quota exceeded" Error:
- Google Sheets API has daily limits
- Consider caching data
- Use batch operations
- ✅ Basic HTML interface created
- 🔄 Set up Google Sheets (your next step)
- ⏳ Configure API integration
- ⏳ Test data flow
- ⏳ Deploy and connect with MetroChetna
- Create Google Sheet with 6 tabs
- Copy CSV data to Google Sheets
- Choose Apps Script OR API Key method
- Set up credentials following guide above
- Update JavaScript configuration
- Test the web interface
- Verify data flows to Google Sheets
- Connect with MetroChetna for reading data