Organizing Large Flask + AngularJS application - python

I have previous experience with a moderately complex Flask + AngularJS application. But now I'm starting on a new more complex app and need help in how I need to setup both the Python and AngularJS application. Here are some info about the app.
The back-end is Python (Flask) app using Pandas to manipulate data
The Python will have an api for the front-end and also a public api
The front-end will be AngularJS SPA with mostly Google Charts
The app will have a both a free and paid version
The paid version will show more charts than the free version
There will also be some static pages for info, pricing, signup, login
Prefer to use a single Postgres DB for both free and paid
My thoughts are to divide each of the backend and front-end into separate modules. I was looking into using Blueprint in Flask to separate the free and paid apps. On the front-end I would prefer to have charts as modular directives that can be copied from free to paid or vice versa.
I'm not clear on how best to setup the folder structure of the Python app and the where the AngularJS files will reside. I also would prefer the free and paid app to be modular so that developers can work on each separately without effecting the other.
Questions:
Is a Microservice Architecture a better approach?
Should the free and paid app be one code base or completely separate
Is Blueprint the best approach with Flask or should the Python apps be completely separate?
What is a good domain strategy to use for free/paid? (e.g. should paid be a subdomain like admin.example.com and free example.com/dashboard or similar)

I'd start by doing something like this:
Create a Github repo named mysite-www. This repo will hold your HTMl / CSS / Angular code only and be deloyed as a static site to something like Amazon S3 / Cloudfront. This means your front-end will be very fast and not dependent on any backend code.
Create a Github repo named mysite-api. This repo will hold your Flask code and be deployed to a dynamic server infrastructure like Heroku / EC2 / Elastic Beanstalk.
Now you have that stuff setup, let's talk about your Flask API project.
You should have one codebase for both the free and paid version of your product. It doesn't make sense to separate these into separate projects as you'll be using 99% of the same code.
You should have some flags set on your user account, which tells you (and subsequently, your Angular front-end), if the user is a paid or free user, and then limits functionality based on those user settings.
You should always use blueprints with Flask if you have any moderately complex API. Blueprints let you have nice nested folders of Python code, that all control separate parts of your API / website.
Now, in general:
Have a single domain for your free / paid product. When a user signs up, let them choose a plan.
Don't change product URLs based on if the user is free or paid, both users should be directed to www.mywebsite.com/dashboard when logged in.
Depending on how you want to authenticate your users between your front-end and API, you likely want to use the OAuth2 protocol. I work for a company that makes this sorta thing easy, re: http://flask-stormpath.rtfd.org/, but there are lots of other great options too: Flask-Security, Flask-Login, etc.
Good luck!

Related

Using django web app backend with mobile app on ReactJS

I have backend of web app by django, include registrations/user profile,
the ability to add photo(video) file and view them, and list of places with the ability to book them.
Now I need to add the ability to work with a mobile application written in ReactJS.
The problem is that before that I did not work with mobile applications and I do not know what strategy to choose, but the frontend developer did not work with the backend. Can I pass django variables directly to the ReactJS code? Do I need additional technologies or frameworks? I would be grateful if someone shared their experience and described how to do it (preferably the least simple way)
You have to build a REST API. In your case, the best solution would be creating the API with Django REST Framework.
It is a very powerful framework for building APIs. They provide some nice tutorials to get started with it.
After that, you can create the frontend app with React by using API calls.

How to separate modules in Django enterprise application

I'm going to create a large scale web application using Django.
It has 2 main parts website and API. also in API I have different modules(controller) like user, event and some other layers things like security, utility ...
I'm looking for an enterprise architecture.
Use django to create a website and then expose whatever you want with django-tastypie as an API: https://github.com/toastdriven/django-tastypie

Creating an event-management/signup web application

I intend to create an event management system, where users may login, view a list of events, sign up to volunteer at events, cancel registration, and view a calendar view of events of the day. In addition, users should receive emails, notifying them when the event(s) they have signed up for is coming up.
Primarily, it should be accessible through a browser, but I would like, in the future, for it to become an organization-wide iPad app.
I have a few questions. How should I store my data? Will MySQL be sufficient? Is it better if I sign up for a service like Heroku, Appfog, or GAE? If I don't need these services, would it be able to run if I used my shared hosting plan over at GoDaddy?
I was thinking about using Google Drive Spreadsheets to store data, and using Google's spreadsheet API to access and write to it. Are there any advantages or disadvantages of taking this route?
Only 50 or so people would need to access it.
I like Python, but haven't done much on the web. Is web2py a good idea, or is it overkill for my purposes?
For UI, I was leaning towards HTML + jQuery + AJAX? + Bootstrap.
Thanks!
I would recommend you to use Django, which is a macro framework written in Python to develop web applications.
Database is of your choice like mysq, postgresql or by default you can use the sqlite3 database offered by Django.
The same goes with UI. You can use the technologies like html, js, CSS, jQuery, bootstrap etc.
Hope this helps.

Concern on hosting OSQA/Django on GAE

I'm going to build a website using OSQA which is built on Django (a famous framework of Python). I'll host this site to Google App Engine (GAE). I wonder if GAE has support all features of OSQA.?
I'm also new to web admin, so I don't know that I could use my own domain name (e.g abc.com) to point to my site hosted on GAE?
I'm going to build a website using OSQA which is built on Django (a famous framework of Python). I'll host this site to Google App Engine (GAE). I wonder if GAE has support all features of OSQA.?
At GAE you don't have support for relational databases (unless you are a beta-tester for CloudSQL). That means no admin, which is 90% of Django's sex-appeal.
Django-nonrel adds NoSQL database support to the ORM. This enables admin on GAE, but it is not fully compatible (Django-nonrel is almost Django but it is not 100% Django). Throw OSQA at it and see if it sticks - if so, you are probably good to go with GAE.
Other Django friendly PaaS worth a look:
Heroku
Gondor
AppHosted
Epio
For my Django projects I like Linode VPS, but I used to work as Linux sysadmin before being a full-time developer - I'll give you my root account when you take it from my cold, dead hands :-). Jokes apart, I would wait CloudSQL before using GAE for Django stuff.
[ update 1 ]
I'm also new to web admin, so I don't know that I could use my own domain name (e.g abc.com) to point to my site hosted on GAE?
You can't use your naked domain - abc.com is out, but you can use anything.abc.com. The FAQ suggests setting a redirect, which is easy enough. Note however that you won't be able to use your domain name with HTTPS at all on GAE - you are constrained to hideous URLs like https://your_app_id.appspot.com.
If you are on GAE, using Google Apps for your domain makes a lot of sense, so you can have Gmail handling email for your domain as well. It is free for 10 email accounts and will handle email for your naked domain (email#abc.com).
Go to http://appengine.google.com.
Choise your app.
Go to App setting.
Click to Add Domain in Domain Setting menu.
Add domain.
But domain must be registered at Google Apps (http://www.google.com/apps/intl/ru/business/index.html) :(
See http://code.google.com/intl/us-US/appengine/docs/domain.html for detail.

Multi tier architecture implementation on Python

I need to create web application, which can be reached by user as regular web site and as XML-RPC web service. Also web site should have mobile version. I'm planning to use next technologies:
Django (for web frontends (regular and mobile)).
Pyramid (for web service).
SQLAlchemy, Memcached (for persistence level)
Later other projects can reach this data and providing logic, so I think it is better to make two tiers. I see it in next way:
Tier 1. Main logic service level. This level will provide API for frontend applications (Django powered web site, for example).
Tier 2. Different mostly end client applications (web site, API for remote client devices).
For communication between this tiers I'm planning to use XML-RPC protocol.
In this case it will be easy to scale it and add new front end application or connect another projects to this (I believe it).
I have main question, -- what can I use to make it easy build first tier? Maybe there is some framework good for that?
And what do you think about this whole architecture. Because I'm filling that I'm thinking in Java terms developing in Python. Maybe there is some another idioms in Python world for such situations.
Thanks for you time and help.
P. S.
Some links for reading are welcome.
This architecture really makes no sense. You're using Django, a full-stack web framework, for the front end, but not using it for the database. And you're using Pyramid, another full-stack web framework, for the web service side, thus ensuring that you duplicate all the business logic.
Much as I am an advocate of Django, I would say it has no place in your architecture. It looks like the only thing you're really using it for is URL routing and templates, both of which Pyramid does itself fine - you can even use Jinja2, which is based on Django's template language, as the template language in Pyramid if you like.
Doing it this way means that you can share the business logic between the front-end and web service code, since you'll almost certainly find that a lot of it will be the same.
I must say also that I don't understand the division into tiers, which you have described as separate from the front-end/web service division. To me, the web service is the second tier. It makes no sense to have a further division.
You should checkout the Turbogears framework as it is composed of several popular components: ORM with sqlalchemy, pylons for logic and support for WSGI, permits support for several templating engines for the frontend... endless.
I use it for several web-services behind AJAX-enabled front-ends (like Flex-based apps, among others). You can front end the TG2-based webapp with apache or your favorite WSGI-enabled web server too.
Checkout their website since they have a tutorial to setup a wiki in 20 minutes.
Cheers!

Categories

Resources