"""Generate thin FastAPI app shells."""

from __future__ import annotations

from pathlib import Path

from .base import get_template_env, write_generated_file


def generate_app_shell(project_name: str, output_dir: Path) -> Path:
    """Generate a FastAPI app shell.

    Args:
        project_name: Name of the project.
        output_dir: Base directory for generated app files.

    Returns:
        Path to the generated file.
    """
    env = get_template_env()
    template = env.get_template("app_shell.py.j2")

    content = template.render(project_name=project_name)

    apps_dir = output_dir / "_generated" / "app"
    file_path = apps_dir / "main.py"
    write_generated_file(file_path, content)

    # Write __init__.py
    init_content = "# AUTO-GENERATED by ninja-codegen — DO NOT EDIT\n\nfrom .main import app\n\n__all__ = ['app']\n"
    init_path = apps_dir / "__init__.py"
    write_generated_file(init_path, init_content)

    return file_path
