Skip to content

Latest commit

 

History

History
139 lines (108 loc) · 4.13 KB

File metadata and controls

139 lines (108 loc) · 4.13 KB

TypeScript to Python Migration Guide

This document outlines the changes made during the repository refactoring from TypeScript/Node.js to Python/Streamlit/PostgreSQL.

Files to Remove

The following TypeScript/Node.js files are no longer needed and can be safely removed:

Node.js Configuration

  • package.json - Node.js dependency management (replaced by requirements.txt and pyproject.toml)
  • package-lock.json - Lock file (if present)
  • node_modules/ - Node.js dependencies directory

TypeScript Configuration

  • tsconfig.json - TypeScript compiler configuration
  • banking/banking.ts - TypeScript implementation (replaced by banking/banking.py)
  • banking/types.ts - TypeScript types (replaced by banking/types.py)
  • banking/banking.test.ts - Vitest tests (replaced by banking/test_banking.py)

Legacy Files

  • agent-sandbox/ - TypeScript examples (can be removed or kept for reference)
    • Dashboard.tsx
    • example.js
    • package.legacy.json

New Python Files Created

Core Application

  • app.py - Main Streamlit application
  • .python-version - Python version specification
  • requirements.txt - Python dependencies
  • pyproject.toml - Modern Python project configuration

Database Layer (New)

  • db/ - Database package
    • __init__.py - Package initialization
    • connection.py - PostgreSQL connection management
    • models.py - Database data models
    • crud.py - CRUD operations

Migrations (New)

  • migrations/ - Yoyo migration scripts
    • 0001_initial_schema.py - Initial database schema
    • 0002_sample_data.py - Sample data for testing
    • README.md - Migration documentation
  • yoyo.ini - Yoyo migration configuration

Banking Domain (Converted)

  • banking/banking.py - Business logic (from TypeScript)
  • banking/types.py - Type definitions (from TypeScript)
  • banking/test_banking.py - Pytest tests (from Vitest)
  • banking/__init__.py - Package initialization

Configuration

  • .env.example - Environment variable template
  • .streamlit/config.toml - Streamlit configuration
  • .gitignore - Updated for Python

Documentation

  • README.md - Updated with Python/Streamlit instructions
  • AGENTS.md - Updated with Python guidelines
  • CONVENTIONS.md - Updated with Python conventions

Migration Steps

To complete the migration:

  1. Remove TypeScript files:

    rm package.json tsconfig.json
    rm banking/banking.ts banking/types.ts banking/banking.test.ts
    rm -rf node_modules/
  2. Install Python dependencies:

    pip install -r requirements.txt
  3. Set up database:

    cp .env.example .env
    # Edit .env with your PostgreSQL credentials
    createdb banking_app
    yoyo apply --config yoyo.ini
  4. Run tests:

    pytest
  5. Start application:

    streamlit run app.py

Key Changes

Language & Framework

  • Before: TypeScript + Node.js + Vitest
  • After: Python 3.11+ + Streamlit + Pytest

Database

  • Before: No database (in-memory only)
  • After: PostgreSQL with Yoyo migrations

Frontend

  • Before: No UI (business logic only)
  • After: Streamlit interactive web application

Type System

  • Before: TypeScript interfaces and types
  • After: Python dataclasses with type hints

Testing

  • Before: Vitest with describe/it
  • After: Pytest with class-based organization

Dependency Management

  • Before: npm/package.json
  • After: pip/requirements.txt + pyproject.toml

Preserved Content

The following were preserved and adapted:

  • banking-spec.md - Functional requirements (language-agnostic)
  • prompts/ - Prompt experiments (unchanged)
  • charts/ - Mermaid diagrams (unchanged)
  • docs/ - Static assets (unchanged)

Benefits of the Migration

  1. Database Persistence - PostgreSQL provides real data storage
  2. Interactive UI - Streamlit offers immediate visual feedback
  3. Better Typing - Python 3.11+ type hints + mypy validation
  4. Simpler Deployment - Single streamlit run command
  5. Data Science Ready - Python ecosystem for analytics
  6. Professional Tooling - Black, Flake8, MyPy, Pytest