How can I organize a complex web application using Kohana v3.1?
===

We have written a pretty complex web application which has following requirements:

 - It has an API. Different versions of API may behave differently. We have to support old version of APIs for sometime.
 - It has a web client. The web clients uses AJAX to get various data. Say 99% The XHR requests are same as API requests. So, the source code for supporting these XHR requests should be shared for APIs. But same are different for example the login api should respond with cookies in case of web and with JSON in case of api. 
 - There are multiple types of clients such as iPhone, iPad, Android Phone, tablets, browser extensions etc. The behavior may vary based on the platform which is making a request.

One way to organize this stuff I was thinking of is extending the Kohana HMVC cascading style to a level more. For example: 

    src/
    htdocs/
    v1/
        device_group_phone/
            device_iphone/
                controllers/
                views/
            device_android/
                controllers/
                views/
            device_default/
                conrollers/
                views/
        device_group_tablet/
            device_ipad/
                controllers/
                views/
            device_default/
                conrollers/
                views/
        device_group_default/
            controllers/
            views/
            models/        
    v2/
        ...
        ...
        ...
    modules/
    system/



The way a request should be served is:

     - Go to proper version.
     - if there is a controller/view device(x),
         then load it.
       else, if there exists a controller/view for device_group(x)/device_default, 
         then load it.
       else if there exists a controller/view for device_group_default
         then load it.
    

 - First question, is there better way than this to organize this code?
 - Second question, if not, how to do it in Kohana?