# Project Migration Task: Python/FastAPI to Bun/Hono ## 1. Role & Objective Act as a Senior Backend Engineer expert in both Python (FastAPI) and the modern JavaScript/TypeScript ecosystem (Bun runtime). **Your Goal:** Rewrite the existing API service located in the `python-ref/` directory using **Bun**, **Hono**, and **SQLite**. ## 2. Source Code Context The source code is located in the `python-ref/` folder. It currently runs on: - Python 3.x - FastAPI - SQLite3 (standard library) ## 3. Target Technology Stack You must use the following stack for the rewrite: - **Runtime:** Bun (latest version) - **Framework:** Hono (latest version) - **Database:** Native `bun:sqlite` (do not use generic node-sqlite3 unless necessary, prefer Bun's native high-performance driver). - **Language:** TypeScript ## 4. Strict Requirements The new service must be a "drop-in" replacement. Adhere to the following rules strictly: ### A. Database Integrity 1. Analyze the SQL schemas or ORM models in `python-ref`. 2. Recreate the **exact same** database table structures (table names, column names, data types, constraints). 3. If the Python code uses an ORM (like SQLAlchemy or Tortoise), translate the logic to raw SQL or a lightweight query builder suitable for `bun:sqlite`. ### B. API Consistency 1. Keep **all API URL paths** exactly the same (e.g., if Python has `/api/v1/users`, Hono must have `/api/v1/users`). 2. Keep **HTTP Methods** exactly the same (GET, POST, PUT, DELETE). 3. Keep **Request/Response JSON formats** exactly the same. Field names must not change (e.g., do not change `user_id` to `userId` in the JSON response, keep it consistent with the old API). ### C. Code Structure 1. Organize the code logically (e.g., separate `db.ts` for database connections, `index.ts` for routes). 2. Use TypeScript interfaces to define the shape of Request/Response bodies. ## 5. Deliverables Please read the files in `python-ref/` recursively. Then, generate the following: 1. **Project Setup:** The `package.json` command or content needed to install dependencies. 2. **Database Setup:** A script or function to initialize the SQLite database matching the old schema. 3. **Application Code:** The full source code for the Hono application. **Start by analyzing the key files in `python-ref/` and summarizing the endpoints and schema you found, then proceed to write the code.**