How tylerm007/model_migration_service works
Project Type and Purpose
• This is a command-line “Model Migration Service” tool, written in Python, to read a CA Live API Creator (LAC) repository (file‐based, JSON/JS/SQL) and generate migration reports (sections: rules, data sources, resources, security) for use by API Logic Server (ALS).
• It is not a full-stack web app but a standalone CLI utility with modular parsing and report-generation components.
File-Structure Analysis
Top-level:
• reposreader.py – CLI entry point (arguments: --repos, --project, --section)
• module files: json_conversion.py, read_csv.py, resourceobj.py, role_security.py, rule.py, util.py
• system/ – custom_endpoint.py, free_sql.py, javascript.py (support code copied into ALS)
• behave_tests/ – test scaffolding generator for BDD
• docs/ – reference PDF architecture and meta-model docs
• venv/ – virtual environment
Repository input:
• CALiveAPICreator.repository/… – nested teamspaces/apis/<project> subfolders (api.json, rules, resources, functions, etc.)
Observations:
• Modular converters for each LAC section
• Skip list of files in code (“.DS_Store”, api.json, issues.json, etc.)
• Output is a set of text reports and code snippets to paste into an ALS project
Guiding Principles
a. Main Components
1. CLI Layer (reposreader.py)
2. Repository Input (LAC file system)
3. File Readers/Parsers
– JSON parser (json_conversion.py)
– JS→Python converter (system/javascript.py)
– SQL reader (system/free_sql.py)
4. Section-Specific Conversion Engines
– Rules converter (rule.py)
– Resource converter (resourceobj.py)
– Data-source converter (read_csv.py / util.py)
– Security converter (role_security.py)
5. Report Generator / Output
– Console formatter, code snippet emitter
6. Test Generator
– behave_tests/gen_behave_tests.py
7. External Target: API Logic Server (ALS) project (consumer of output)
b. Relationships and Data Flows
– User invokes CLI → reposreader
– reposreader reads input path → hands off to File Parsers
– For each requested section:
• Parser loads raw artifacts → Conversion Engine
• Conversion Engine transforms to ALS-compatible Python/report
– Report Generator collects all conversions → prints to stdout/files
– Test Generator optionally emits BDD stubs
– Operator copies generated code into ALS project (using system/ support modules)
c. Architectural Patterns / Design Principles
– Layered pipeline: CLI → Input → Parsing → Transformation → Output
– Separation of concerns: one module per LAC section
– Plug-in style for sections (add new “--section”)
– Reusable utility modules (util.py, json_conversion.py)
d. Key Technologies / Frameworks
– Python 3 CLI (argparse)
– JSON, JS, SQL file handling
– Behavior-driven test scaffolding (behave)
– API Logic Server (external target)
Essential Elements to Capture
– CLI entry point and argument parsing
– LAC repository folder as the input data store
– JSON/JS/SQL parsers feeding into section‐specific transformers
– Report generator consolidating transformed code snippets
– External ALS project as consumer of generated output
– Test generator producing BDD stubs