Architecture: API as core for a website & mobile-app

Once I've heard that a good way to develop a web application is to develop an API-Centric Web Application. The thing is, to me, if you couple the main service to the public API, building an API-Centric application, you lose the whole point of developing a public API at all.


This doesn't seem logical to me.

Yes, the API and the website and what ever might come next are separate things and website should be a client to the API itself but since it will simplify things greate, I believe that you should RE-USE the domain-classes to build and base your web-site logic. This way you can use all the same code base and handle all your issues including ads, invoicing and of course file uploads with ease.

For the public API, it should be on a separate box if possible re-using the same domain classes but with different authentication methods so that whatever problem might occur, it won't affect the main service.

Your cron-jobs should only be used to fire the call through the API itself and those calls should be made on the main app (website through the API)

If you build your website without repeating-yourself, as in, using the same code as the base and wrapping the web-app around it, you won't have the issue raising in q#2.

Same thing applies for question number 3. If you wrap the website around the API, the website can use the api itself without being a separate entity.

Your architecture seems complex but if you do these things, it will be simple. ;-)

Good luck!