Hacker News new | ask | show | jobs
by syed123 3303 days ago
Thanks for the detailed rundown. How long do you think it will take to rebuild the existing letslunch.com website from scatch in python? just a rough estimate without going for the nitty gritty of table sizes, length, number of lines of code.. letslunch has data of 90,000 users, 60,000 lunches, 12-15 dynamic pages and about 6 api's that we use from linkedin, facebook etc
1 comments

Build it in parallel with your current codebase.

If you're not doing so already, create a staging database you can use for developing this. That way if something goes berserk production data stays safe.

Get a jumpstart by using Django and creating models that match your database via inspectdb [1]. Most important thing is getting the data to fit and relate as you'd expect.

Some recommended plugins are django-debug-toolbar (https://github.com/jazzband/django-debug-toolbar) and django-extensions (https://github.com/django-extensions/django-extensions).

Then for Social API logins use https://python-social-auth-docs.readthedocs.io. For Social API's themselves there are python wrappers, like https://github.com/mobolic/facebook-sdk. In the worst case, you'll be querying API's directly with requests (http://docs.python-requests.org).

Next, you begin to build views (and their templates) around the models you've created. You're going to want them to run at a parity with what you have in PHP. Use urls.py regular expressions to match your URL's too.

This is how you mitigate the risk of doing a "migration". And also a great way to get some experience under the belt while you do it. You should be able to get your site working off a staging database in a read-only way when you do this. Keep the PHP site in production until your ready to switch.

If you use JSON/REST, also check out Django REST Framework. http://www.django-rest-framework.org/

I'm going to be making a detailed blog post on django in a few days as well.

[1] https://docs.djangoproject.com/en/1.11/howto/legacy-database...

Based on the website and code base i have, i just want a rough estimate..are we talking 2 weeks, 2 months or 6 months here to rebuild in a new language? does it provide any advantage that the code was already written and api's work etc in the other language? trying to see if something can be reused or is it gonna be a total build from scatch new website..
> does it provide any advantage that the code was already written and api's work etc in the other language

If you build your models to be an exact fit with your current data, yes.

> Based on the website and code base i have, i just want a rough estimate..are we talking 2 weeks, 2 months or 6 months here to rebuild in a new language?

That's like asking a consultant for a time estimate when they don't know all the details. Factors include:

- How much python you know already

- How long does it take for you to grasp the fundamentals of virtual environments, packages, importing, etc.

> trying to see if something can be reused or is it gonna be a total build from scatch new website..

- Good point: If you end up keeping old API's running on the PHP side and just migrating the HTML stuff first, or only. That is a shortcut to get going faster.

- How much templating you have to do. But I think you can do that in maybe (2 Weeks). Django templates are easy to learn and you can extend from a common base.

- Database models. I think you should try the inspectdb thing ASAP as a trial to see how easy it is to display any data from your current schema. Be sure to use a copy (or sample) of your prod data in a separate staging database though. You could do that tonight. Getting everything (relations and all) to map perfectly (ORM -> your current db schema) could take a couple of weeks to get perfect. Use this 'managed = False': https://docs.djangoproject.com/en/1.11/howto/legacy-database...

- Development hosting: I recommend trying out Heroku. The deployment is straight forward. But outside of that you're going to have to wrap your brain around how to deploy it. nginx + uwsgi + supervisor is a common combo if you're doing it right on the server.

- Business logic: Most of this is done inside your views. This could take a month or so.

Since django is a big framework and these things work in tandem, it could be 3-6 months. Remember to build it in parallel so the PHP site can continue to be maintained if needed. And create a staging database that's based off your production schema with some sample data in there.

Also while you do this, you're going to continually get faster as you gain mastery with python.

For a speed boost, you can continue to keep API's running in PHP while you convert other stuff over first.

wow..excellent advice. You made me day and week!!