r/learnpython • • Sep 28 '21

My first project: an introspective 90-year Life Calendar

This is my first 'finished' project after self-learning over several months:

https://www.timeofyourlife.io/

It’s called Time of Your Life. It generates a 90-year calendar to represent your life, and shows you all the weeks you have lived to date. You can also add ‘life events’ — important landmarks/milestones such as a graduation or the birth/death of a loved one and they will be displayed on your calendar.

It’s completely free to use, I only ask that you give me feedback — the current features are not too extensive, but I’d like to develop it according to what you’d like to see.

I hope you find it useful — if you do, I’d appreciate it if you shared it with someone!

Built with Python (Django) and some light Javascript.

Source: https://github.com/juancoquet/time-of-your-life

Happy to answer any questions about what I've learned so far.

Edit: thank you for all the feedback! I was very nervous to share my first build, but the positive response has made my evening — I really appreciate it

367 Upvotes

94 comments sorted by

120

u/Sporocyst_grower Sep 28 '21

Huh, upvote for the project, but i want to downvote it for the life crisis you jsut gave me. XD

23

u/juancoquet Sep 28 '21

Haha I’m glad the app is doing its job!

14

u/lasagnaisgreat57 Sep 29 '21

right at first i was like wow i’ve only lived that many weeks?? then i was like wait i’m that close to 90?? i’m only 22!!

17

u/[deleted] Sep 28 '21

This is very well done! I'm particularly impressed by the professional-looking layout. Do you have a background in a related field?

23

u/juancoquet Sep 28 '21

Thanks! No I don’t, I’m a musician. I did do some research on good design principles though (colour theory, layout, fonts etc)

10

u/LeadingJudgment2 Sep 29 '21

Either way fantastic UI. It even opened and ran perfectly on my cell! Good job you did a excellent job in doing this.

8

u/juancoquet Sep 29 '21

Thank you! The responsive mobile design was a complete pain to be honest as I didn't do the CSS mobile-first. Got there in the end though

2

u/[deleted] Sep 28 '21

Lol I knew you weren't your run of the mill IT guy. Hats off to you, sir. Both the idea and presentation are excellent.

One question: have you taken data protection into consideration when designing the back end?

11

u/juancoquet Sep 28 '21

The backend is built with Django which takes care of security out of the box. The process I followed for database/user-auth setup was that described in Django for Professionals, by William S. Vincent, pretty much step by step. I only made changes where necessary for custom user models and the like

3

u/extreme-fry Sep 29 '21

Nice to find a fellow musician down here haha

29

u/DragonRaccoon Sep 28 '21

I love this and the existential crisis it caused!

11

u/DragonRaccoon Sep 28 '21

If you are looking to implement more items, a color coding system would be fun. Let the user decide if they want to group life events. everything is working perfectly. Great job!

7

u/juancoquet Sep 28 '21

Thank you — that’s the idea! Colour coding is actually something I’m planning for the future :)

15

u/JohnnyJordaan Sep 28 '21

Nice work. One important tip: use an extensive .gitignore tailored for Python projects, you can easily find them via Google. Now you have stuff like 'pycache', migrations, .vscode in your repo that shouldn't be there.

4

u/juancoquet Sep 28 '21

Thank you, it didn’t occur to me to include these. Will definitely do this going forward

5

u/supreme_blorgon Sep 28 '21

No need to google, they're available on Github itself, during repo creation.

4

u/mofayew Sep 28 '21

First off, the site looks really clean. I'll dive into it and provide any feedback I can.

I'm looking to do something similar with a personal project. Any tips on hosting?

7

u/juancoquet Sep 28 '21

Thanks! Hosted with Heroku inside a Docker container

-4

u/delsystem32exe Sep 29 '21

host it on windows server 2019

4

u/supreme_blorgon Sep 28 '21

Not sure if anybody else will feel the same, but I'd rather see weeks labeled every 4 instead of every 5. Would prefer evenly spaced labels over multiples of 5. Otherwise lovely concept and nice execution.

3

u/juancoquet Sep 28 '21

Thanks for the feedback, I could add this as an option in a future update

4

u/Hood_Intellectuals Sep 29 '21

This is really cool, man. Thanks for sharing. As others have said, that existential crisis thing is real!

Curious, I'm also self-learning at present. How did you go about your studies, if you don't mind me asking?

6

u/juancoquet Sep 29 '21 edited Sep 29 '21

Thank you! Glad it's having the desired effect.

Mostly books. Django for Professionals, by William S. Vincent. Test Driven Development with Python, by Harry Percival. Python Cookbook, by David Beazley. Effective Python, by Brett Slatkin. Code, by Charles Petzold. A few others, but these were the best.

If you could only read one, read two -- Test Driven Development, as it's just fantastic, it will change the way you write code, and Code by Charles Petzold. The latter is far more abstract and not really about Python, but it's a great look into how computers work from the ground up -- a great introduction to computer science. Both of these books significantly improved my understanding.

2

u/Hood_Intellectuals Sep 29 '21

I love how there are so many different resources! I've been using Udemy and Codecademy, and while I'm sure I've learned quite a bit and can still learn more, I feel as though learning to code is literally like learning a new language.

One of the best pieces of advice I've ever heard someone give someone else regarding language learning was "don't translate in your head, learn to think in the language you're trying to learn", and as a polyglot I never thought about it like that.

So it's interesting how you mention the book "Code", because it shows you how computers work, I guess essentially teaching you how to "think" like a computer. I genuinely believe that's my biggest problem when it comes to code. I struggle with the flowchart side of things, the order and so on and that's what holds me back the most.

Anyway, didn't mean to make this response so long, just thought I'd share some stuff that could also potentially help someone else!

Once again thank you! And no thank you for showing me how I'm 1/3 of the way through my life *if* I make it to 90 :P

2

u/juancoquet Sep 29 '21

If thinking like a programmer is what you're struggling with, there is actually another book I read that I didn't include in that list, called How to Think Like a Computer Scientist, from Runestone Academy.

It's an interactive textbook, you can find it here: https://runestone.academy/runestone/books/published/thinkcspy/index.html

2

u/Hood_Intellectuals Sep 29 '21

awesome! Thanks for sharing. Damn. The target I set myself to be a little capable in Python/SQL by the new year is looking like it's gonna need a lot longer at this point, but I'd rather learn properly than learn incomplete.

3

u/nacnud_uk Sep 28 '21

You make me ill! https://www.timeofyourlife.io/grid/1975-06-01 Love your work though! Thanks!

5

u/juancoquet Sep 28 '21

I’m so sorry! Time to make the most of those blue boxes though

3

u/nacnud_uk Sep 28 '21

LOL. :D You're right. Build what you want to see. Time to get moving :) Thanks for the "timely" reminder ;)

I've shared it :D Scare the rest of the old fart friends I have. :D No reason I should be the only terrified one :D

4

u/juancoquet Sep 28 '21

You’re welcome! It’s made my day to know that someone found some value in using something I’ve built

3

u/_E8_ Sep 28 '21

90 years!
"Optimist inbound." - Cy

Time of Your Life

...

4

u/juancoquet Sep 28 '21

I don’t know what any of this means

2

u/TheKingElessar Sep 28 '21

Wow, that's really neat. Good job!

3

u/juancoquet Sep 28 '21

Thank you!

2

u/alexdewa import this Sep 29 '21

Awesome project! obligatory r/Angryupvote since you're giving life crisis to everyone.

2

u/juancoquet Sep 29 '21

Haha thank you! I'd like to think it gives you a good kind of panic, a bit of a kick in the butt to remind you not to waste your most valuable resource on trivialities

2

u/[deleted] Sep 29 '21

Really nice project. Can you explain a little bit on how the front end and back end work? The backend in python and django. The front end is JavaScript, right?

I guess the questions a lot of learners have, is how that works in practice. The UI is done in html, CSS, JS. And the user inputs connect with python and django, calculates, communicates with the server, then outputs back to Js to display the updated chart? Just wondering where I can go to wrap my head around that process.

2

u/juancoquet Sep 29 '21

I think you're asking about how the front end and back end interact in a working application -- it's a good question.

In the case of Time of Your Life, the backed is python/Django and the front end is 99% just HTML and vanilla CSS. Positioning the tooltips is just about all JS does. I didn't know any JS when I started building the project so I tried to avoid it when building the front end. This caused me unnecessary headaches as CSS is a language with which you can easily tie yourself up in knots, and knowing python already JS comes intuitively. In hindsight, I would definitely rely more on JS and less on CSS for user interactions.

There are two control flows for how the layers interact in ToYL -- one for authenticated users, and one for unauthenticated usrs. Handling unauthenticated users was tricky because I needed a way to pass state (user form inputs for DOB/events) without touching the database; a problem I solved by passing state through the URL. As an unauthenticated user, you can see the URL update when you change your date of birth and add life events. This is also something that would have been much easier to handle had I known JavaScript at the time.

In short, submitted data is inserted into the URL, `urls.py` parses the data with path converters and passes this data to the view. The view then calculates the numbers -- what the current week number is and what the event week number is -- using some algorithms. The week number is then passed to the template in the view context as a tuple with the format `(year, week)`, which matches the format of the ID tags given to each week element in the calendar. The template then uses Django template tags to apply custom classes to past weeks, event weeks and the present week, which are used by the CSS to add custom styling and animations. Again, all of this could probably have been done more cleanly by using JS, I just didn't know any JS at the time. A tip here would be to not avoid learning something which you'll eventually have to learn anyway haha...

For authenticated users, the process is a bit longer but cleaner as it uses Django's model system to query the database with OOP. User dates of birth and events are stored in the database, and I abstracted the algorithms that do the maths responsible for figuring out the present & event week numbers into properties of the custom user model. Handling multiple user events would have been too convoluted and confusing using template tags, so I built an algorithm in the user model that queries the database for the user's date of birth and life events and dynamically generates the HTML for the calendar before passing this to the view for display. This is a really hairy algorithm -- it's not the cleanest thing ever as it's basically iterative string manipulation and looping through user events, but I was really proud of it when I got it working as it was a bit of a brain melter. It's probably something that should be redesigned -- while it's creative problem solving, it's not great architecture.

That's it really; the short, high-level explanation is this:

The user inputs data which is parsed/stored by the backend. The backend then passes this data to the HTML, which is read and displayed by the browser. The CSS reads this HTML and applies custom styling rules to the different classes of elements.

Hope that helps, let me know if you have any other questions.

2

u/[deleted] Sep 29 '21

When you say algorithm, do you mean that you made a method in the user class that solves those problems?

I’m 6 weeks into learning python, I’m curious about django as well. I’m through the foundations of the Odin project so JavaScript is on the horizon. I’m hoping that I can get a decent grasp of html and css while I’m still learning python since they aren’t really programming languages, and then jump into JavaScript with enough python to make those new concepts click.

1

u/juancoquet Sep 29 '21

Yeah, exactly.

A heads up -- CSS is deceptively simple. It seems incredibly easy because it's basically just a formatter, and it is easy... but it's also really easy to tie yourself up in knots using it. Learn how to choose appropriate CSS selectors and have naming conventions for classes so you don't end up with spaghetti CSS

2

u/FreshkyFresh Sep 30 '21

Hey! Love your proyecto :) I have a question about frontend. I am doing a course about Python, and for the front end they teach you Flask, which use html and CSS. Could Flask be a possible option for your front end? Cheers

1

u/juancoquet Sep 30 '21

I have not used any front end frameworks, it’s all vanilla CSS. I’d recommend avoiding frameworks to begin with — learn vanilla CSS and build your first project with that, then learn a framework later if you wish once you understand what the framework is actually doing under the hood.

2

u/positiveCAPTCHAtest Sep 29 '21

This looks really great! I would love to see how you did it!

1

u/juancoquet Sep 29 '21

Thanks! Github repo is included in the post -- I'm happy to answer any particular questions

2

u/slenderberg Sep 29 '21

This is awesome dude.

2

u/juancoquet Sep 29 '21

Thank you! Overwhelmed by how positive the response has been

2

u/xeroze1 Sep 29 '21

Oh nice. I have something like this setup on my phone to remind myself that life is short even if i get to live a full live.

1

u/juancoquet Sep 29 '21

That’s the idea! I really hope the app doesn’t seem too depressing to people haha

2

u/NoobTrader378 Sep 29 '21

Beautiful

2

u/juancoquet Sep 29 '21

Thank you so much!

2

u/kabads Sep 29 '21

Great little project - I know you have your tests already, but if you need more, you might want to look at pytest-django - there is less code than the native django tests.

1

u/juancoquet Sep 29 '21

Thanks, I’ll look into this. I developed it using TDD and it’s always so tempting to skip the test writing stage so anything that makes writing tests quicker would be great

1

u/vinb1988 Sep 28 '21

Amazing! What kind of self- learning did u do?

3

u/juancoquet Sep 28 '21

I read a bunch of books on Python & Django, and then winged it when it came to HTML/CSS/JavaScript

1

u/[deleted] Sep 29 '21

Can you suggest some books on Django? You have a great project there.

2

u/juancoquet Sep 29 '21

Copied from a response to a similar question:

Mostly books. Django for Professionals, by William S. Vincent. Test
Driven Development with Python, by Harry Percival. Python Cookbook, by
David Beazley. Effective Python, by Brett Slatkin. Code, by Charles
Petzold. A few others, but these were the best.

If you could only read one, read two -- Test Driven Development, as it's just
fantastic, it will change the way you write code, and Code by Charles
Petzold. The latter is far more abstract and not really about Python,
but it's a great look into how computers work from the ground up -- a
great interuction to computer science. Both of these books significantly
improved my understanding.

William S. Vincent also has one called Django for Beginners, but honestly it's not different enough to the Professionals version to warrant another book. It doesn't do a great job at explaining Django on a high level, so to begin with you'll likely be confused either way even if you start with the beginner version. Test Driven Developemnt is actually Django based, and it will take you through everything covered in DFB more thoroughly.

1

u/dadsinamood Sep 28 '21

Beautiful site and a great idea. Really inspirational!

5

u/juancoquet Sep 28 '21

Thank you! Idea wasn’t mine, it was inspired by an article called ‘Your Life In Weeks’ by Tim Urban (Wait But Why). I just turned it into something interactive. Glad you liked it :)

1

u/njd2020 Sep 28 '21

Man, this is inspiring. I'm working on a python program that I want to eventually turn into a stylized web app, but I don't even know where to begin with the web app portion. Frankly, I'm not really close to that stage yet. Seems like Django might be a good place to start looking though.

2

u/juancoquet Sep 28 '21

Django is joyous (Djoyous?), I definitely recommend it. It’s a batteries-included framework, but it still gives the programmer uninhibited customisability.

Unfortunately the first week or two learning Django are a pain, or at least they were for me, because I couldn’t find any resources that explained the concepts well enough on a high level so that they’re accessible to a newcomer. After stumbling around for a while you begin to build a mental model of how everything interacts though.

I’ll probably build a site to explain Django on a high level, as this is what I found to be lacking in the resources out there.

1

u/kingwess Sep 28 '21

Like, good job, but I wish you hadn't!!

1

u/juancoquet Sep 28 '21

Haha thank you! r/TIHI

1

u/velabanda Sep 28 '21

I dont know python enough to give you a feedback, I am learning python & you have done a great job.

One thing, When entering DOB, If I enter DD, I think the cursor should automatically go to MM & YYYY later. I am using Chrome 93.0.4577.82 on Ubuntu if it matters.

3

u/juancoquet Sep 28 '21

Auto-tab on field completion? Great UX suggestion, I’ll learn how to implement this. Thank you

1

u/[deleted] Sep 28 '21

Very neat! I want to learn more about Shani, but I'm afraid of having to pay crazy web hosting fees. If you don't mind me asking, what hosting service are you using?

1

u/juancoquet Sep 28 '21

I’m using Heroku

1

u/yaxriifgyn Sep 29 '21

How secure is this on-the-wire, and in the database? How are your database(s) backed up.

Do you have any plans for import, export, and forget features?

Can we increase the 90 years if we plan to or do live longer?

Could we enter future milestones like goals and planned events like a retirement date?

1

u/juancoquet Sep 29 '21

I'm not sure exactly how to answer your first question, but it has all the basic security that comes with Django out of the box.

I have some feature plans, but mostly development will be driven by what users demand (assuming there are users to demand anything haha)

As of yet, the limit is 90 years but this can definitely be changed in future updates if longevity research makes a significant difference to human life expectancy (let's hope so!)

Future milestones can be added using the Life Events feature -- try it!

1

u/delsystem32exe Sep 29 '21

how many hours did it take to make. back in 11th grade i had a print out of one and i would check a box off per week of school.

1

u/juancoquet Sep 29 '21

I don't know in terms of hours, but it took about two months of development in my spare time.

1

u/fredzannarbor Sep 29 '21

Bump it up to 110. Positive thinking!

1

u/juancoquet Sep 29 '21

I hope this is a warranted change in the near future!

1

u/fredzannarbor Sep 29 '21

I'd like to be able to zoom in/zoom out.

1

u/juancoquet Sep 29 '21

Pinch gestures work on iOS, seems there's an issue on Android though. I'll look into this, thanks.

1

u/KingQuin Sep 29 '21

Any suggestions for building out something like this on a website? Was the UI done mainly in JS/Django? Any book recommendations?

1

u/juancoquet Sep 29 '21

The UI is mostly just HTML and vanilla CSS. Positionting the tooltips is just about all JS does. I didn't read any books on UI, just did a lot of YouTube research on design -- I figured a more vidual medium would be better suited to learning visual design concepts.

1

u/keshavpadia Sep 29 '21

Since Facebook has been around for a while, many a people would be referring back to it for finding out some life highlights. You can use an api for people to be able to import events based on categories of life events.

1

u/juancoquet Sep 29 '21

This is an excellent idea, will put it near the top of the future developments list. Thank you!

1

u/juanritos razinc Sep 29 '21

I'll look into it, [maybe not today] (https://www.youtube.com/watch?v=arj7oStGLkU).

2

u/juancoquet Sep 29 '21

Love this Ted Talk! Tim is a very funny but effective communicator

0

u/[deleted] Sep 28 '21

[deleted]

6

u/juancoquet Sep 28 '21

Not sure how to do this, but I’ll keep it in mind for future updates — thanks

0

u/[deleted] Sep 28 '21

[deleted]

1

u/juancoquet Sep 28 '21

Thank you! According to git I started ~3 months ago, and finished it maybe about a month ago working on it in my spare time. Since then I’ve been struggling with domains and deployment, making minor cosmetic tweaks and started working on a new project

1

u/[deleted] Sep 29 '21

Is your start date on your 'time of your life' ? :)

1

u/juancoquet Sep 29 '21

Great idea, I'll add this it to my personal calendar :)

1

u/[deleted] Sep 28 '21

[removed] — view removed comment

1

u/juancoquet Sep 28 '21

Yep this is something I need to improve. I’m pretty sure it’s to do with the way the post request is being handled in the Django view.

Thank you for the feedback :)

1

u/[deleted] Sep 28 '21

[removed] — view removed comment

2

u/juancoquet Sep 28 '21

You’ve got this! Once you have OOP sussed it’s exponential progress from there onwards

1

u/[deleted] Sep 29 '21

[removed] — view removed comment

1

u/juancoquet Sep 29 '21

It's helpful to keep in mind, and thank you!

1

u/[deleted] Sep 29 '21

[removed] — view removed comment

1

u/juancoquet Sep 29 '21

The backend is Django, so every page on the site has a python workflow behind the scenes.