meatballs/DjAxelrod

Pure Django App or UI/API split?

Closed this issue · 13 comments

Two options here:

  1. We could write this app as pure django from model to template
  2. We could create an API layer (e.g. Django Rest Framework) and a separate UI layer

My preference is to separate the two. I've used DRF before and I've used AngularJS to create a UI on top of a DRF API. Left to my own devices, I'd repeat that architecture.

I can't say I know enough to be able to comment (but very much looking forward to learning all this stuff)...

I should add that separating the two also comes in two flavours:

  1. They could be two entirely separate apps in two separate repositories and hosted separately on Heroku (or wherever)
  2. Django could serve both layers within the same app even using AngularJS as the UI framework

I've done option 1 before with success, but I suspect option 2 might be better suited here.

Again can't offer much insight here... I'm very much looking forward to learning all this.

I think a distinct JSON API layer using DRF will enable us to serve up results data very easily for those that want to do their own analysis.

I've heard a lot about DRF and am definitely onboard!

And that the various AngularJS widgets will allow us to create visualisation of results for those that would prefer us to do it for them.

This might be one for some discussion at DjangoCon - I'd welcome meeting anyone with experience of hosting AngularJS within Django.

Hi, I don't know if this is the case, but one thing that you have to keep in mind is that if you want to use some kind a user control, keeping Angular and DRF in the same app let's you use SessionAuthentication which is easier to use.

From the DRF docs:

SessionAuthentication

This authentication scheme uses Django's default session backend for authentication. Session authentication is appropriate for AJAX clients that are running in the same session context as your website.

Otherwise I think you'll need to implement a token based auth or the basic with username and password that according to the docs is "generally only appropriate for testing".

Hope this helps. BTW in not an expert so maybe the advantages of decoupling the API from the frontend outweigh this.

Cheers

@alejandrodnm Thanks for that. I'm no expert either!

I'll see if I can get Erik Romijn (who did the security talk) to give us his thoughts.

Edit: The previous comment doesn't make any sense anymore when I know where is the "backend" code repository :)

I would go for API/UI design. It will be more interactive and interesting. Also, we can't add very thin layer of static templates (pure django) any time.

We are using JWT tokens to do authentication across Django and Ember. That should work with Angular too, I reckon.
http://jwt.io/

Thanks all. It looks like I'd better create a DjAxelrodUI repository this morning!