Rest API and admin in the same application - rest

I'm new to building APIs, I made the first one using an MVC framework: codeigniter, with chris kacerguis rest implementation.
I'm not really sure this was the best think to do because I believe maybe the framework is not that "slim" or light just to API's purposes.
I plan to do a mobile App, an admin and a website so the three can consume the Api's services.
Is it a bad idea to have the API, the website and the admin on the same project? which are the pros and cons? or the best architectural approach?
Otherwise I will have: One Codeigniter project for the API and Another Codeigniter project for website and admin
thanks

You can create folders in "controllers" folder to organize your project and use the same project/env configuration :
controllers/Home.php
controllers/api/MyApi.php
controllers/admin/Admin.php
Edit : You will share models and libraries too.

In my project I realized 2 types of controller - REST and API. Admin js gui work with REST, other world work with API. You can do it simply with silex framework, a little brother of symfony.

The purpose of building a REST API so that you only have to build one project for your business model. This allows you to construct any number of applications on any platform, only requiring you to consume the API in different ways. This essentially separates/decouples the user interface from the business logic, and vice versa.
You should create separate projects for the REST API and each UI project should also be separated projects. This allows you to change the underlying code, language and platform in any one of the projects without breaking any of the other projects as long as the API signatures remain the same.
For example, you could have a live version of your website built using Codeignitor while developing another septate project using AngularJS. When your AngularJS project is complete you would simply swap out the project on your server (or create an entirely new website or server) still allowing you to use the other if required. Additionally, you may decide that you would like to move the API onto a different platform, language or database, develope it and swap the implementation when finished causing no changes to any of your UI projects assuming you have not changed the API signatures.

Related

Adobe Experience Manager: (Blackbox) Web API for external access

Background: We're creating an offer for an Xamarin app for a customer, which is using AEM to manage a lot of content. We are not experienced with AEM, therefore I have the task to find the possibilities regarding a Web connection and how deep into AEM we need to interfere, to get the desired data.
Usually, I would never ask such a general question here, but after some hours of research, I didn't find any hint regarding a public API:
I've started a chat with an Adobe employee, but he told me, that he
can't help me regarding technical questions
I've analyzed the AEM architcture, finding Sling being a Web API
(https://helpx.adobe.com/experience-manager/using/querying-experience-manager-sling.html), but it also just Java
I've also found AEM Assets (https://helpx.adobe.com/experience-manager/6-4/assets/user-guide.html),but analyzing it, it seems like this is more like a Web App on top of AEM
I've also found Web APIs in AEM Screens,
https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/developing-screens-rest-api.html, but the architecture here seems also very tightly coupled between the UI and the Web APIs
So, my question: Is there just no Web API at all? Or is one of the subproducts of AEM the endpoint, we could use to get data?
Based on the fact that you mentioned Xamarin I guess you are supposed to work on a mobile app.
You basically have four options, if you want to build that using AEM:
Use the Single Page Application (SPA) capabilities of AEM (requires AEM 6.4):
Use the (legacy) PhoneGap capabilities of AEM.
Use the out-of-the-box Sling APIs to expose the data you need and use them in your Xamarin app.
Write a custom (web service) API and use that in your Xamarin app.
I would strongly suggest to have a look at the SPA support or PhoneGap capabilities if you are not running AEM 6.4.
Working with the Sling API or building your own API is not the best option if you are new to AEM. There are so many pitfalls that will cause you a lot of headaches and you run the risk of creating an unmaintainable mess of an AEM project.

How should a frontend framework (like Vue/Angular) interact with a backend MVC framework (Laravel/Sails)

We need a restful backend that provides APIs for a mobile app.
We also need a admin website to manage the restful backend.
Right now we have Sails.js as the backend framework, Vue.js as the frontend framework.
I m pretty new to MVC frameworks and I am a little bit confused how should these two frameworks interact with each other:
Should:
The frontend framework lives indepedently (maybe on a separate server), it calls api exposed by the backend framework, or
The frontend framework lives INSIDE the Sails.js, acting as the "views" for the Sails framework
I am not even 100% sure is my question a valid question, I want to know which are the popular ways and is there any pros and cons?
You can do both i.e. keep frontend framework in Sails project as well as separate independent project.
I have done both and I keep following points in mind while making this decision:
If the project is complex enough then its better to create a separate project using some scaffolding tool.
If the project is going to change frequently and evolve on its own then also its better to create a separate project.
If some one time/small view is to be made then I would prefer to keep it part of Sails project
Since you are using frontend framework for admin panel which I think
will be complex, I would recommend you to create separate project on the same server.
You can use yeoman for scaffolding. I have used it for some angular projects and it works great.
Your question is too wide for a single explanation, but the main concept is as per my understanding is data binding.
You can find a lot of free screencasts for starting from scratch, assuming you already know some JavaScript.

Alfresco as App development framework?

I was surfing the Internet where I found an article saying that Alfresco is a Content Management Framework as well as App Development Framework. While I understood it as Content Management Framework, I am not able to know about it as an App Development Framework.I tried researching over it, but could not find anything viable.
I want to know that how Alfresco can be used as an App Development Framework ?
Hi Alfresco has an application development framework, more info here:
Guides: https://community.alfresco.com/community/application-development-framework/pages/get-started
Angular 2 components repository: https://github.com/Alfresco/alfresco-ng2-components
Alfresco App Yeoman generator: https://github.com/Alfresco/generator-ng2-alfresco-app
JavaScript API repository: https://github.com/Alfresco/alfresco-js-api
Some videos:
https://www.youtube.com/watch?v=-OFI3izSDdk
https://www.youtube.com/watch?v=kjOgVbINAyU
In case you want a live support you can use the Gitter channel: https://gitter.im/Alfresco/alfresco-ng2-components
Well, if for App is meant mobile application, Alfresco has a Mobile SDK available for both iOS and Android which can help you create your own application to work against the Alfresco Platform.
Moreover there is another framework called Aikau which has one main goal
The main purpose of Aikau is to provide a library of widgets that can be easily assembled into a web application for accessing an Alfresco repository. The aim is not to replace Share but it was necessary to migrate away from its original implementation, which was based around the Surf paradigms of pages, templates, components and web scripts, towards a solution that provided for rapid development and customization.
This feature was first introduiced in Alfresco 4.2 and then extended in Alfresco 5.0
If you want to build applications for Alfresco you have a number of options available to you - as mentioned you can build mobile applications (and there are SDKs available to do this).
If you want to build web applications then you have the option of either customizing the default Alfresco Share client (which is built on top of the Alfresco Surf framework using a combination of YUI 2 and Aikau). Alternatively you can built your own web client by building a new client with the Maven Aikau Archetype.
The advantage of the Surf framework is that it takes care of Alfresco authentication across all the various APIs (WebScript, CMIS, Public API, etc) as well as providing lots of security benefits (CSRF, XSS white-lists, etc).
The advantage of using Aikau is that it provides a large number of out-of-the-box widgets that are specifically designed to work with Alfresco data and address Alfresco (ECM) specific use cases.
You are of course not limited to these options - you can build an application on top of any stack you wish, but ultimately you will want to be making use of the REST APIs that the Alfresco Repository provides.
Depending upon the application you are building you may also want to build custom data models and build in workflow via Activiti BPM as well.

How to use alfresco java API to submit form values

I have developed one spring based java web application. In my project it is requirement to use alfresco as a CMS. For this I want to integrate this application with alfresco. So I decided to use alfresco java API's.
http://dev.alfresco.com/resource/docs/java/
But I am not getting how to use those API's to complete backend work of my web application. Suppose I would like to submit one form having user name & password fields in it. After click on submit button how can I handle request in backend so it will use Alfresco java API to process request and store details in database.
I have to do many operations in my project like upload file, play with documents, Submit different forms. view those forms etc.
My first question is am I going in right direction by using alfresco java API's. if yes then how can use those API? is there any other way to do this?
Any help would be appreciate!!!
Thanks in Advance,
Kailas Salunke.
Well, based on my experience, Alfresco is an excellent ECM but not suitable for being a CMS.
Apart from that, it is difficult to give suggestions, starting from the very general overview you have given, but things like user name and password have little to do with an ECM and storing of data in a database.
You have two options available.
One involve using the Web Content Management Quick Start, it's a Spring Surf app you can (not easily in my opinion) customize for your needs.
The other solutions, if you have an existing web app, rather than develop your own API have a look at CMIS, I have put a simple wikipedia explanation, you can dig further from there.
Then, when you are ready, have a look at Alfresco CMIS first, and the most used Java API for doing CMIS call, which is Apache Chemistry
CMIS, in its intent, guarantee that Alfresco could be replaced with any other CMIS compliant ECM. You can easily integrate Apache Chemistry in your Spring app.

A good way to structure AngularJS client code with Play 2.1 as backend

I own a Play 2.1 application.
Initially, I used the default template mechanisms from Play 2.1 until I .. learned AngularJS.
Now, I clearly want my client side to be an AngularJS app.
However, while surfing the net, I find there are no clear way to achieve it:
Letting Play behave as a simple RESTful application (deleting the view folder) and making a totally distinct project to build the view (AngularJS app initialized by grunt.js).
Advantage: Likely to be less messy, and front and backend teams would work easily separately.
Drawback: Need another HTTP server for the AngularJS app.
Try to totally integrate AngularJS app with the traditional Play's workflow.
Drawback: With a pretty complex framework like AngularJS, it would lead to a confusion of templates managementfor instance : scala.html (for Play) / tpl.html (for Angular) ... => messy.
Making a custom folder within the play project but distinct from the initial folders created by the Play scaffolding. Let's call it myangularview instead of traditional view for instance. Then, publish static contents generated by grunt.js into the Play's public folder, in order to be reachable from browser through Play's routing.
Advantage: SRP between components is still fairly respected and no need to use another light HTTP server for the client-side like in 1.
I pointed out my own views of advantage and drawbacks.
What would be a great way to achieve the combination of Play with Angular?
Yes, I'm answering to my own question :)
I came across this way of doing:
http://jeff.konowit.ch/posts/yeoman-rails-angular/
Rails?? No matter the framework is, the need remains exactly same.
It advocates a real separation between APIs (backend side), and front-end side (in this case making AJAX calls to backend server).
Thus, what I've learned is:
During development phase, a developer would use two servers: localhost on two distinct ports.
During production phase, the front-end elements would be encompassed into the whole backend side (the article would deal with a kind public folder, aiming to serve static contents: HTML, angular templates (for instance), CSS etc... Advantage? => dealing with a one and unique serving server's APIs exposition as well as static assets for the UI.
With this organization, some tools like Yeoman would be able to bring some really awesome handy things to developers like for instance: the livereload feature. :):)
Of course, during development phase, we end up with two different domains, (localhost:3000 and localhost:9000 for instance) causing issues for traditional ajax requests. Then, as the article points out, a proxy may be really useful.
I really find this whole practice very elegant and pleasant to work with.
There was an interesting discussion on the play mailinglist a couple of days ago about frontend-stack/solution, could be something in it for you, quite some people using angular it seems: https://groups.google.com/forum/#!searchin/play-framework/frontend/play-framework/IKdOowvRH0s/tQsD9zp--5oJ