SafeVixAI/SafeVixAI-Dataset-Hub
SafeVixAI Dataset Hub π‘οΈ The Intelligence Layer for the SafeVixAI platform β IIT Madras Road Safety Hackathon 2026 This repository hosts all datasets, pre-trained models, notebooks, and reproducible data acquisition scripts that power the SafeVixAI application. It is designed to be cloned directly into Google Colab or any research environment. Main Application Repo: SafeVixAI/SafeVixAI β‘ Quickstart (Google Colab) # Clone the entire intelligence layer !gitβ¦ See the full description on the dataset page: https://huggingface.co/datasets/SafeVixAI/SafeVixAI-Dataset-Hub.
1147
1#!/usr/bin/env python32"""3One-time script to generate the initial SafeVixAI_MASTER.docx4with Part A (static docs), Part B (semi-static config), and Part C marker.5"""6 7import os8import re9import glob10from docx import Document11from docx.shared import Pt, RGBColor, Inches, Cm12from docx.enum.text import WD_ALIGN_PARAGRAPH13from docx.enum.table import WD_TABLE_ALIGNMENT14 15ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))16DOCS_DIR = os.path.join(ROOT, "docs")17OUTPUT = os.path.join(DOCS_DIR, "SafeVixAI_MASTER.docx")18 19 20def add_heading(doc, text, level, color_hex="0D1117"):21 para = doc.add_heading(text, level=level)22 for run in para.runs:23 run.font.color.rgb = RGBColor(24 int(color_hex[0:2], 16),25 int(color_hex[2:4], 16),26 int(color_hex[4:6], 16),27 )28 return para29 30 31def add_para(doc, text, bold=False, italic=False, font_size=10, color_hex=None):32 para = doc.add_paragraph()33 run = para.add_run(text)34 run.bold = bold35 run.italic = italic36 run.font.size = Pt(font_size)37 if color_hex:38 run.font.color.rgb = RGBColor(39 int(color_hex[0:2], 16),40 int(color_hex[2:4], 16),41 int(color_hex[4:6], 16),42 )43 return para44 45 46def add_table(doc, headers, rows):47 table = doc.add_table(rows=1 + len(rows), cols=len(headers))48 table.style = "Light Grid Accent 1"49 for j, header in enumerate(headers):50 cell = table.rows[0].cells[j]51 cell.text = header52 for p in cell.paragraphs:53 for r in p.runs:54 r.bold = True55 r.font.size = Pt(9)56 for i, row in enumerate(rows):57 for j, val in enumerate(row):58 cell = table.rows[i + 1].cells[j]59 cell.text = str(val)60 for p in cell.paragraphs:61 for r in p.runs:62 r.font.size = Pt(9)63 return table64 65 66def read_md(filepath):67 """Read a markdown file and return its content."""68 try:69 with open(filepath, "r", encoding="utf-8") as f:70 return f.read()71 except Exception as e:72 return f"[Error reading {filepath}: {e}]"73 74 75def md_to_docx_section(doc, title, md_content, heading_level=2):76 """77 Convert markdown content to docx paragraphs.78 Handles: headings, bullet points, code blocks, tables, and plain text.79 """80 add_heading(doc, title, heading_level, "1A5C38")81 82 in_code_block = False83 code_lines = []84 85 for line in md_content.split("\n"):86 stripped = line.strip()87 88 # Code block toggle89 if stripped.startswith("```"):90 if in_code_block:91 # End of code block β flush92 code_text = "\n".join(code_lines)93 para = doc.add_paragraph()94 run = para.add_run(code_text)95 run.font.size = Pt(8)96 run.font.name = "Consolas"97 run.font.color.rgb = RGBColor(0x1A, 0x1A, 0x2E)98 para.paragraph_format.left_indent = Cm(1)99 code_lines = []100 in_code_block = False101 else:102 in_code_block = True103 continue104 105 if in_code_block:106 code_lines.append(line)107 continue108 109 # Skip empty lines110 if not stripped:111 continue112 113 # Headings (### β level 4, ## β level 3)114 if stripped.startswith("####"):115 add_heading(doc, stripped.lstrip("#").strip(), min(heading_level + 3, 5))116 elif stripped.startswith("###"):117 add_heading(doc, stripped.lstrip("#").strip(), min(heading_level + 2, 4))118 elif stripped.startswith("##"):119 add_heading(doc, stripped.lstrip("#").strip(), min(heading_level + 1, 3))120 elif stripped.startswith("#"):121 # Skip top-level heading (already used as section title)122 continue123 # Bullet points124 elif stripped.startswith("- ") or stripped.startswith("* "):125 doc.add_paragraph(stripped[2:], style="List Bullet")126 # Numbered lists127 elif re.match(r"^\d+\.\s", stripped):128 text = re.sub(r"^\d+\.\s", "", stripped)129 doc.add_paragraph(text, style="List Number")130 # Table rows (basic β just add as text)131 elif stripped.startswith("|"):132 # Skip separator rows133 if re.match(r"^\|[\s\-:|]+\|$", stripped):134 continue135 cells = [c.strip() for c in stripped.split("|")[1:-1]]136 if cells:137 doc.add_paragraph(" | ".join(cells), style="List Bullet")138 # Plain text139 else:140 add_para(doc, stripped, font_size=10)141 142 143def build_master_doc():144 doc = Document()145 146 # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ147 # TITLE PAGE148 # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ149 title_para = doc.add_paragraph()150 title_para.alignment = WD_ALIGN_PARAGRAPH.CENTER151 title_para.space_before = Pt(120)152 run = title_para.add_run("SafeVixAI")153 run.bold = True154 run.font.size = Pt(36)155 run.font.color.rgb = RGBColor(0x1A, 0x5C, 0x38)156 157 subtitle = doc.add_paragraph()158 subtitle.alignment = WD_ALIGN_PARAGRAPH.CENTER159 run = subtitle.add_run("AI-Powered Road Safety Platform")160 run.font.size = Pt(18)161 run.font.color.rgb = RGBColor(0x58, 0x58, 0x58)162 163 tagline = doc.add_paragraph()164 tagline.alignment = WD_ALIGN_PARAGRAPH.CENTER165 run = tagline.add_run(166 "Enterprise Master Document\n"167 "IIT Madras Road Safety Hackathon 2026"168 )169 run.font.size = Pt(14)170 run.italic = True171 172 meta = doc.add_paragraph()173 meta.alignment = WD_ALIGN_PARAGRAPH.CENTER174 meta.space_before = Pt(40)175 run = meta.add_run(176 "safevixai.vercel.app β’ github.com/SafeVixAI/SafeVixAI\n"177 "Structure: Part A (Static) + Part B (Semi-Static) + Part C (Live Auto-Updated)"178 )179 run.font.size = Pt(10)180 run.font.color.rgb = RGBColor(0x88, 0x88, 0x88)181 182 doc.add_page_break()183 184 # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ185 # TABLE OF CONTENTS (manual)186 # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ187 add_heading(doc, "Table of Contents", 1, "0D1117")188 toc_items = [189 "PART A β STATIC DOCUMENTATION",190 " A.1 Product Requirements (PRD)",191 " A.2 System Architecture",192 " A.3 Features & Modules",193 " A.4 Technology Stack",194 " A.5 API Reference (28 endpoints)",195 " A.6 Database Schema",196 " A.7 AI & Chatbot Architecture",197 " A.8 Agent Tools & Intent Detection",198 " A.9 Security & Authentication",199 " A.10 Offline Architecture",200 " A.11 UI/UX Design System (DESIGN.md)",201 " A.12 Data Sources & Datasets",202 " A.13 Deployment Guide",203 " A.14 Setup & Development (SETUP.md)",204 " A.15 Contributing Guidelines",205 " A.16 Roadmap",206 " A.17 Agent System Architecture (AGENTS.md)",207 " A.18 Project README",208 " A.19 Platform Capabilities (SKILL.md)",209 " A.20 UI/UX Component Reference",210 " A.21 Complete Resource Checklist",211 "",212 "PART B β SEMI-STATIC CONFIGURATION",213 " B.1 Environment Variables (3 services)",214 " B.2 Database Tables & Schema",215 " B.3 Dataset Placement Guide",216 "",217 "PART C β LIVE STATUS (AUTO-UPDATED DAILY)",218 " C.1 Repository Overview",219 " C.2 Deployment & Service Health",220 " C.3 Recent CI/CD Runs",221 " C.4 Open GitHub Issues",222 " C.5 Recent Commits",223 " C.6 Feature Completion Status",224 ]225 for item in toc_items:226 if not item:227 doc.add_paragraph("")228 continue229 if item.startswith("PART"):230 add_para(doc, item, bold=True, font_size=12, color_hex="1A5C38")231 else:232 add_para(doc, item, font_size=10)233 234 doc.add_page_break()235 236 # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ237 # PART A β STATIC DOCUMENTATION238 # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ239 add_heading(doc, "PART A β STATIC DOCUMENTATION", 1, "1A5C38")240 add_para(241 doc,242 "This section consolidates all project documentation into a single reference. "243 "Content is written once and updated only when architecture or design decisions change.",244 italic=True,245 font_size=10,246 )247 248 # Ordered list of docs to merge249 docs_to_merge = [250 ("A.1 Product Requirements (PRD)", "PRD.md"),251 ("A.2 System Architecture", "Architecture.md"),252 ("A.3 Features & Modules", "Features.md"),253 ("A.4 Technology Stack", "TechStack.md"),254 ("A.5 API Reference", "API.md"),255 ("A.6 Database Schema", "Database.md"),256 ("A.7 AI & Chatbot Architecture", "AI_Instructions.md"),257 ("A.8 Agent Tools & Intent Detection", "Agent.md"),258 ("A.9 Security & Authentication", "Security.md"),259 ("A.10 Offline Architecture", "Offline_Architecture.md"),260 ("A.11 UI/UX Design System", None), # DESIGN.md is top-level261 ("A.12 Data Sources & Datasets", "DataSources.md"),262 ("A.13 Deployment Guide", "Deployment.md"),263 ("A.14 Setup & Development", None), # SETUP.md is top-level264 ("A.15 Contributing Guidelines", "Contributing.md"),265 ("A.16 Roadmap", "Roadmap.md"),266 ("A.17 Agent System Architecture", None), # AGENTS.md is top-level267 ("A.18 Project README", None), # README.md is top-level268 ("A.19 Platform Capabilities", None), # SKILL.md is top-level269 ("A.20 UI/UX Component Reference", "UIUX.md"),270 ("A.21 Complete Resource Checklist", "Complete_Project_Resource_Checklist.md"),271 ]272 273 for title, filename in docs_to_merge:274 doc.add_page_break()275 276 if filename:277 filepath = os.path.join(DOCS_DIR, filename)278 elif "Design" in title:279 filepath = os.path.join(ROOT, "DESIGN.md")280 elif "Setup" in title:281 filepath = os.path.join(ROOT, "SETUP.md")282 elif "Agent System" in title:283 filepath = os.path.join(ROOT, "AGENTS.md")284 elif "README" in title:285 filepath = os.path.join(ROOT, "README.md")286 elif "Capabilities" in title:287 filepath = os.path.join(ROOT, "SKILL.md")288 else:289 filepath = None290 291 if filepath and os.path.exists(filepath):292 content = read_md(filepath)293 md_to_docx_section(doc, title, content, heading_level=2)294 add_para(295 doc,296 f"β Source: {os.path.relpath(filepath, ROOT)} β",297 italic=True,298 font_size=8,299 color_hex="999999",300 )301 else:302 add_heading(doc, title, 2, "1A5C38")303 add_para(304 doc,305 f"[Document not found: {filename or 'N/A'}]",306 italic=True,307 color_hex="CC0000",308 )309 310 # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ311 # PART B β SEMI-STATIC CONFIGURATION312 # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ313 doc.add_page_break()314 add_heading(doc, "PART B β SEMI-STATIC CONFIGURATION", 1, "1A5C38")315 add_para(316 doc,317 "Configuration that changes only when the system architecture is modified. "318 "Update this section when adding new services, tables, or environment variables.",319 italic=True,320 font_size=10,321 )322 323 # B.1 β Environment Variables324 doc.add_page_break()325 env_file = os.path.join(DOCS_DIR, "Environment.md")326 if os.path.exists(env_file):327 md_to_docx_section(doc, "B.1 Environment Variables", read_md(env_file))328 else:329 add_heading(doc, "B.1 Environment Variables", 2, "1A5C38")330 331 # Backend332 add_heading(doc, "Backend Service (.env)", 3)333 backend_env = os.path.join(ROOT, "backend", ".env.example")334 if os.path.exists(backend_env):335 content = read_md(backend_env)336 para = doc.add_paragraph()337 run = para.add_run(content)338 run.font.size = Pt(8)339 run.font.name = "Consolas"340 341 # Chatbot342 add_heading(doc, "Chatbot Service (.env)", 3)343 chatbot_env = os.path.join(ROOT, "chatbot_service", ".env.example")344 if os.path.exists(chatbot_env):345 content = read_md(chatbot_env)346 para = doc.add_paragraph()347 run = para.add_run(content)348 run.font.size = Pt(8)349 run.font.name = "Consolas"350 351 # Frontend352 add_heading(doc, "Frontend (.env.local)", 3)353 frontend_env = os.path.join(ROOT, "frontend", ".env.example")354 if os.path.exists(frontend_env):355 content = read_md(frontend_env)356 para = doc.add_paragraph()357 run = para.add_run(content)358 run.font.size = Pt(8)359 run.font.name = "Consolas"360 361 # B.2 β Database Schema362 doc.add_page_break()363 db_file = os.path.join(DOCS_DIR, "Database.md")364 if os.path.exists(db_file):365 md_to_docx_section(doc, "B.2 Database Tables & Schema", read_md(db_file))366 else:367 add_heading(doc, "B.2 Database Tables & Schema", 2, "1A5C38")368 add_para(doc, "[Database.md not found]", italic=True)369 370 # B.3 β Dataset Placement371 doc.add_page_break()372 dataset_file = os.path.join(DOCS_DIR, "DATASET_PLACEMENT.md")373 if os.path.exists(dataset_file):374 md_to_docx_section(375 doc, "B.3 Dataset Placement Guide", read_md(dataset_file)376 )377 else:378 add_heading(doc, "B.3 Dataset Placement Guide", 2, "1A5C38")379 add_para(doc, "[DATASET_PLACEMENT.md not found]", italic=True)380 381 # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ382 # PART C β LIVE STATUS MARKER383 # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ384 doc.add_page_break()385 add_heading(doc, "PART C β LIVE STATUS (AUTO-UPDATED DAILY)", 1, "1A5C38")386 add_para(387 doc,388 "β³ This section will be populated automatically by the GitHub Actions workflow "389 "(scripts/update_master_doc.py). Run the workflow manually or wait for the daily "390 "9:00 AM IST scheduled run.\n\n"391 "To trigger manually: GitHub β Actions β Update Master Document β Run workflow",392 italic=True,393 font_size=10,394 )395 396 # ββ Save ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ397 doc.save(OUTPUT)398 file_size_kb = os.path.getsize(OUTPUT) // 1024399 print(f"β
Master document created: {OUTPUT}")400 print(f" Size: {file_size_kb} KB")401 print(f" Parts: A (21 sections) + B (3 sections) + C (marker)")402 print(f" Source: 18 docs/ files + 5 root files = 23 total")403 print(f" Next: Run 'python scripts/update_master_doc.py' to populate Part C")404 405 406if __name__ == "__main__":407 build_master_doc()408 