- Created app/lib_schema_v3.py to isolate database and Pydantic model introspection. - Updated app/routers/api_crud_v3.py to use get_object_schema_info(), completing the modularization. - Finalized refactoring plan documentation in documentation/REFACTOR_API_CRUD_V3.md.
29 lines
1.3 KiB
Markdown
29 lines
1.3 KiB
Markdown
# Refactoring Plan: API CRUD V3
|
|
|
|
**Goal:** Modularize `app/routers/api_crud_v3.py` to improve maintainability, readability, and reusability. The file currently mixes route definitions, security enforcement, data sanitization, and helper utilities.
|
|
|
|
## Phase 1: Extract Helpers & Core Logic (Safest) - COMPLETED
|
|
**Objective:** Move pure functions and business logic out of the router file.
|
|
|
|
1. **Create `app/lib_api_crud_v3.py`**: DONE
|
|
2. **Update `app/routers/api_crud_v3.py`**: DONE (All endpoints now use `sanitize_payload`).
|
|
|
|
## Phase 2: Separate Child/Nested Routes - COMPLETED
|
|
**Objective:** Reduce file size by splitting standard CRUD from relational CRUD.
|
|
|
|
1. **Create `app/routers/api_crud_v3_nested.py`**: DONE
|
|
2. **Update `app/routers/api_crud_v3.py`**: DONE (Included via `router.include_router`)
|
|
|
|
## Phase 3: Schema Introspection - COMPLETED
|
|
**Objective:** Isolate database introspection logic.
|
|
|
|
1. **Create `app/lib_schema_v3.py`**: DONE
|
|
2. **Update `app/routers/api_crud_v3.py`**: DONE
|
|
|
|
## Refactoring Summary
|
|
The V3 CRUD system is now modularized into:
|
|
- `app/routers/api_crud_v3.py`: Top-level object routes.
|
|
- `app/routers/api_crud_v3_nested.py`: Relational/child object routes.
|
|
- `app/lib_api_crud_v3.py`: Shared security, filtering, and sanitization logic.
|
|
- `app/lib_schema_v3.py`: Database and model introspection logic.
|