# Web Migration TODO: Flask to FastAPI This document contains tasks for migrating the web application from Flask to FastAPI. Each task should be marked as completed with [x] when finished. ## ๐Ÿ“‹ Project Analysis and Setup ### Initial Assessment - [ ] Review current Flask application structure in `/src/web/` directory - [ ] Identify all Flask routes and their HTTP methods - [ ] Document current template engine usage (Jinja2) - [ ] List all static file serving requirements - [ ] Inventory all middleware and extensions currently used - [ ] Document current error handling patterns - [ ] Review authentication/authorization mechanisms ### FastAPI Setup - [x] Install FastAPI dependencies: `pip install fastapi uvicorn jinja2 python-multipart` - [x] Update `requirements.txt` or `pyproject.toml` with new dependencies - [ ] Remove Flask dependencies: `flask`, `flask-*` packages - [x] Create new FastAPI application entry point ## ๐Ÿ”ง Core Application Migration ### Main Application Structure - [x] Create new `main.py` or update existing app entry point with FastAPI app instance - [x] Migrate Flask app configuration to FastAPI settings using Pydantic BaseSettings - [ ] Convert Flask blueprints to FastAPI routers - [x] Update CORS configuration from Flask-CORS to FastAPI CORS middleware ### Route Conversion - [ ] Convert all `@app.route()` decorators to FastAPI route decorators (`@app.get()`, `@app.post()`, etc.) - [ ] Update route parameter syntax from `` to `{id: int}` format - [ ] Convert Flask request object usage (`request.form`, `request.json`) to FastAPI request models - [ ] Update response handling from Flask `jsonify()` to FastAPI automatic JSON serialization - [ ] Convert Flask `redirect()` and `url_for()` to FastAPI equivalents ### Request/Response Models - [ ] Create Pydantic models for request bodies (replace Flask request parsing) - [ ] Create Pydantic models for response schemas - [ ] Update form handling to use FastAPI Form dependencies - [ ] Convert file upload handling to FastAPI UploadFile ## ๐ŸŽจ Template and Static Files Migration ### Template Engine Setup - [ ] Configure Jinja2Templates in FastAPI application - [ ] Set up template directory structure - [ ] Create templates directory configuration in FastAPI app ### HTML Template Migration - [ ] Review all `.html` files in templates directory - [ ] Update template rendering from Flask `render_template()` to FastAPI `templates.TemplateResponse()` - [ ] Verify Jinja2 syntax compatibility (should be mostly unchanged) - [ ] Update template context passing to match FastAPI pattern - [ ] Test all template variables and filters still work correctly ### Static Files Configuration - [ ] Configure StaticFiles mount in FastAPI for CSS, JS, images - [ ] Update static file URL generation in templates - [ ] Verify all CSS file references work correctly - [ ] Verify all JavaScript file references work correctly - [ ] Test image and other asset serving ## ๐Ÿ’ป JavaScript and Frontend Migration ### Inline JavaScript Review - [ ] Scan all HTML templates for inline `