"""
{{ project_name }}
{{ config.project.description }}
"""
{% if config.volume %}
import sys
{% for path in config.volume.mount_paths %}
sys.path.append('{{ path }}')
{% endfor %}
{% endif %}

{% if web_framework == 'flask' %}
from flask import Flask
from app.config import load_config
from app.endpoints import register_routers

# Use ND-SDK auto-initialization API
from nd_sdk import initialize_sdk, get_initialized_component

initialize_sdk.init()

def create_app() -> Flask:
    """Create and configure Flask application"""

    # Initialize SDK here, inside the factory function
    initialize_sdk.init()

    logger = get_initialized_component('logger')

    # Load configuration
    config = load_config()

    app = Flask(str(config.get('project', {}).get('name', '{{ project_name }}')))

    # Register blueprints
    register_routers(app)

    logger.info("Application initialized successfully")

    return app


app = create_app()

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8000)

{% else %}
from fastapi import FastAPI
from typing import Optional
from app.config import load_config
from app.endpoints import register_routers

# Use ND-SDK auto-initialization API
from nd_sdk import initialize_sdk, get_initialized_component
import logging


def create_app() -> FastAPI:
    """Create and configure FastAPI application"""

    # Load configuration
    config = load_config()

    # Auto-initialize ND-SDK components from environment variables.

    # Create FastAPI app
    app = FastAPI(
        title=str(config.get('project', {}).get('name', '{{ project_name }}')),
        description=str(config.get('project', {}).get('description', '')),
        version=str(config.get('project', {}).get('version', '0.0.0')),
    )

    # Register routers (your endpoints module should import/cache components as needed)
    register_routers(app)

    logger.info("Application initialized successfully")

    return app


app = create_app()

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(
        "main:app",
        host="0.0.0.0",
        port=8000,
        reload=True,
    )
{% endif %}
