# hrushikeshpawar/codemorph architecture

> Architecture diagram of the GitHub repository hrushikeshpawar/codemorph, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hrushikeshpawar/codemorph
- Repository: https://github.com/hrushikeshpawar/codemorph

## Overview

##### Project Type and Purpose
- CodeMorph is a modular, CLI-driven toolkit for semi-automated migration of legacy PL/SQL code to Java SpringBoot.
- It has two core functional packages—PL/SQL analysis and dependency graph analysis—plus an orchestration layer and demo/configuration assets.

##### File-Structure Analysis
- Top-level:
- packages/
├─ plsql_analyzer/ (parsing, extraction, persistence)
└─ dependency_analyzer/ (graph building, analysis, visualization)
- src/codemorph/ (main orchestrator & CLI entrypoint “codemorph”)
- demo/ (sample inputs, configs, and generated artifacts)
- pyproject.toml, README, docs, planning (roadmaps)
- Patterns & layers:
- CLI layer (cli.py, cli_app.py in each package)
- Core services (analysis, builder, orchestration modules)
- Persistence (SQLite DB modules under persistence/)
- Visualization (Graphviz-based exporter)
- Utilities & config loaders
- CI/config: uv.lock, .github, .gitignore, config.toml files.

##### README Insights
- Two logical subsystems: PL/SQL Analyzer and Dependency Analyzer.
- Orchestrated by codemorph CLI.
- Uses SQLite for metadata, Graphviz/NetworkX for visuals, and LLM integration for future phases.
- Roadmap includes a FastAPI backend and React frontend (future).

a. Main Components
1. CLI Orchestration Layer (src/codemorph/cli_app.py)
2. PL/SQL Analyzer Package
- Parsing Engine (signature, structural, call extractors)
- Persistence (SQLite via database_manager)
- Profiling & change-detection scripts
3. Dependency Analyzer Package
- Graph Constructor & Overload Resolver
- Analysis Engine (cycle detection, reachability, classification)
- Visualization Exporter (Graphviz)
- Persistence (graph storage)
4. Configuration Module (dep_analyzer_config.toml, plsql_analyzer_config.toml)
5. Demo Data & Artifacts (input SQL files, demo DB, graphs)
6. External Services & Libraries
- SQLite
- Graphviz
- LLM API (planned)
7. Future Web Interface
- FastAPI backend
- React frontend

b. Relationships & Interactions
- User invokes `codemorph` or `plsql-analyzer / dependency-analyzer` CLI.
- CLI layer loads configuration → calls analysis/orchestration workflows.
- PL/SQL Analyzer reads SQL files → parsing modules → metadata → persists in SQLite.
- Dependency Analyzer reads metadata DB → graph constructor → analysis modules → exports graphs.
- Orchestration layer coordinates cross-package workflows (e.g., run plsql_analyzer then dependency_analyzer).
- Future: orchestration layer will expose REST endpoints via FastAPI and serve React UI.

c. Architectural Patterns & Principles
- Layered Architecture: CLI → Orchestration → Core Services → Persistence → External Libraries
- Separation of Concerns: Parsing vs. Analysis vs. Visualization vs. Storage
- Modular Packaging: Independent installable packages for plsql and dependency analyzers
- Builder Pattern: graph_constructor, overload_resolver
- Workflow/Orchestration Pattern: extraction_workflow, cli_app

d. Key Technologies
- Python 3.12+, Pydantic for settings, Loguru for logging
- SQLite for metadata persistence
- NetworkX & Graphviz for graph modeling & rendering
- TOML config files
- uv/pip for package management

##### Essential Elements
- Clear component names (e.g., plsql_analyzer.core, dependency_analyzer.builder)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "CLI & Orchestration"
        CLI["CLI Orchestration\n(src/codemorph/)"]:::cli
    end

    subgraph "PL/SQL Analyzer Package"
        PLCLI["plsql_analyzer CLI\n(cli.py)"]:::cli
        Parsing["Parsing Engine\n(parsing/)"]:::core
        PSettings["Settings Loader\n(settings.py)"]:::config
        PWorkflow["Extraction Workflow\n(extraction_workflow.py)"]:::core
        PPersist["SQLite Persistence\n(database_manager.py)"]:::persistence
        PProfile["Profiling Scripts\n(profiling_scripts/)"]:::core
    end

    subgraph "Dependency Analyzer Package"
        DCLI["dependency_analyzer CLI\n(cli_app.py)"]:::cli
        DService["CLI Service & Utils\n(service.py, utils.py)"]:::core
        GraphConst["Graph Constructor\n(graph_constructor.py)"]:::core
        Overload["Overload Resolver\n(overload_resolver.py)"]:::core
        Analysis["Analysis Engine\n(analyzer.py)"]:::core
        DPersist["Graph Storage\n(graph_storage.py)"]:::persistence
        Exporter["Visualization Exporter\n(exporter.py)"]:::visualization
        DSettings["Config & Settings\n(dep_analyzer_config.toml, settings.py)"]:::config
        DbLoad["Database Loader\n(database_loader.py)"]:::core
    end

    subgraph "Demo Data & Config"
        DemoSQL["Input SQL Sources\n(dummy_plsql_source/)"]:::external
        DemoDB["Sample DB & Graphs\n(artifacts/)"]:::external
        DemoConf["Demo Config\n(config.toml)"]:::config
    end

    subgraph "External & Future"
        SQLite["SQLite DB"]:::external
        Graphviz["Graphviz"]:::external
        LLM["LLM API (planned)"]:::external
        subgraph "Future Web UI"
            FastAPI["FastAPI Backend"]:::external
            React["React Frontend"]:::external
        end
    end

    CLI -->|loads config| PSettings
    CLI -->|loads config| DSettings
    CLI -->|invoke| PLCLI
    CLI -->|invoke| DCLI

    DemoSQL -->|sample input| PLCLI
    DemoConf -->|demo config| CLI
    DemoDB -->|demo artifacts| DService

    PLCLI -->|parse SQL| Parsing
    Parsing -->|run workflow| PWorkflow
    PWorkflow -->|persist metadata| PPersist
    PWorkflow -->|profile changes| PProfile
    PWorkflow -->|store metadata| SQLite

    DCLI -->|invoke service| DService
    DService -->|load DB| DbLoad
    DbLoad -->|reads metadata| PPersist
    DService -->|build graph| GraphConst
    GraphConst -->|resolve overloads| Overload
    Overload -->|analyze graph| Analysis
    Analysis -->|store graph| DPersist
    DPersist -->|export| Exporter
    Exporter -->|render| Graphviz

    %% Click Events
    click CLI "https://github.com/hrushikeshpawar/codemorph/tree/main/src/codemorph/"
    click PLCLI "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/plsql_analyzer/src/plsql_analyzer/cli.py"
    click Parsing "https://github.com/hrushikeshpawar/codemorph/tree/main/packages/plsql_analyzer/src/plsql_analyzer/parsing/"
    click PPersist "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/plsql_analyzer/src/plsql_analyzer/persistence/database_manager.py"
    click PWorkflow "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/plsql_analyzer/src/plsql_analyzer/orchestration/extraction_workflow.py"
    click PProfile "https://github.com/hrushikeshpawar/codemorph/tree/main/packages/plsql_analyzer/profiling_scripts/"
    click PSettings "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/plsql_analyzer/src/plsql_analyzer/settings.py"

    click DCLI "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/cli_app.py"
    click DService "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/cli/service.py"
    click DService "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/cli/utils.py"
    click GraphConst "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/builder/graph_constructor.py"
    click Overload "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/builder/overload_resolver.py"
    click Analysis "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/analysis/analyzer.py"
    click DPersist "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/persistence/graph_storage.py"
    click Exporter "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/visualization/exporter.py"
    click DSettings "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/dep_analyzer_config.toml"
    click DSettings "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/settings.py"
    click DbLoad "https://github.com/hrushikeshpawar/codemorph/blob/main/packages/dependency_analyzer/src/dependency_analyzer/utils/database_loader.py"

    click DemoSQL "https://github.com/hrushikeshpawar/codemorph/tree/main/demo/dummy_plsql_source/"
    click DemoDB "https://github.com/hrushikeshpawar/codemorph/tree/main/demo/artifacts/"
    click DemoConf "https://github.com/hrushikeshpawar/codemorph/blob/main/demo/config.toml"

    %% Styles
    classDef cli fill:#D0E8FF,stroke:#007ACC,color:#000;
    classDef core fill:#E0FFD0,stroke:#2E8B57,color:#000;
    classDef persistence fill:#FFE0B2,stroke:#FF8C00,color:#000;
    classDef visualization fill:#E5D0FF,stroke:#800080,color:#000;
    classDef external fill:#F0F0F0,stroke:#A0A0A0,color:#000;
    classDef config fill:#FFF5BA,stroke:#FFD700,color:#000;
```
