Skip to content

shrikrishna97/TracKKaroo_v1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 logo
TracK Karoo

TracK Karo is a webapp that gives the user analytical results of its habits, health, mood, work, exersice data and helps the user to manage its daily routine on the basis of that analysis. Learn more about working of TracK Karo by reading the documentation below.

What's included

Within the application folder you'll find the following directories and files. You'll see something like this:

application/
├── main.py
│
├── TracK Karo/
│   ├── app.py
│   ├── model.py
│   ├── database.sqlite3
│   ├── static/
│   │       └── main.css
│   │
│   └── templates/
│        ├── base.html
│        ├── base1.html
│        ├── boolean.html
│        ├── create_tracker.html
│        ├── dashboard.html
│        ├── index.html
│        ├── login.html
│    	 ├── numeric.html
│     	 ├── multiplechoice.html
│     	 ├── sign_up.html
│        ├── update_log.html
│        └── update.html
│	
├── Report.pdf
├── requirements.txt
└── project.md  

How To Run "TracK Karoo":

We can run Run "TracK Karoo" using localhost. Below is the general command to run the application:

http://127.0.0.1:5000/

We can run Run "TracK Karoo" using online IDE Replit. Below is the general command to run the application on Replit:

https://tracker-app.shrikrishna6966.repl.co/

Database contents

Below are the contents of the application database model code-

Model Libraries

  1. Flask SQLAlchemy: Flask-SQLAlchemy is an extension for Flask that aims to simplify using SQLAlchemy with Flask by providing defaults and helpers to accomplish common tasks. One of the most sought after helpers being the handling of a database connection across the app. In TracK Karoo, We used flask-sqlalchemy to create database schema and tables.

  2. Datetime: Datetime is a python module which supplies classes to work with date and time. These classes provide a number of functions to deal with dates, times and time intervals. In the TracK Karoo, we used datetime module to get timestamp in the application.

Tables

  1. User: User table created in SQLite database by using Flask-sqlalchemy. It stores user data in rows i.e., user id, name, username, password and trackers. Here, all except user id and trackers are taken from user during sign up. User id is an autogenerated primary key of the User table and is unique to every user, name is name of the user, username is also unique to every user it is used for login every time by the user and trackers defines relationship between the user and the tracker table in a secondary table named user_trackers.

  2. Tracker: Tracker table created in sqlite database by using Flask-sqlalchemy. It stores data of trackers created by any user in rows i.e.,id, name, description, tracker type, setting,date created and logs. Here, user will decide the tracker name, description and tracker type while creating tracker. Id is an autogenerated primary key of the Tracker table and is unique to every user, name is name of the tracker, description is a description about the tracker by the user, tracker type a dropdown to select the type of tracker user wants, date created is the date when the tracker is created using datetime module of python and log defines relationship between the tracker table and the log table in a secondary table named tracker_logs.

  3. Logs: Logs table created in sqlite database by using Flask-sqlalchemy. It stores log data of trackers created by any user in rows i.e., id, name, description, tracker type, date created and logs. Here, user will decide the tracker name, description and tracker type while creating tracker. Id is an autogenerated primary key of the Tracker table and is unique to every user, name is name of the tracker, description is a description about the tracker by the user, tracker type a dropdown to select the type of tracker user wants and log defines relationship between the tracker table and the log table in a secondary table named tracker_logs.

Application contents

Below are the route and fuctions of the main application code-

Application Libraries

  1. Flask: Flask is used for developing web applications using python, implemented on Jinja2. We used different flask decorators and functions in the application for better handling here we used route,before_first_request decorator, redirect and render_template functions, Flask class and request, session, flash as others objects. Here, route is used to to bind a function with a specific url where in some function we used route with variable section also and before_app_request( ) registers a function that runs before the view function, no matter what URL is requested. redirect( ) fuction is used to redirect a user to another endpoint. render_template( ) function is used to render html templates stored in templates folder. Request is a flask object used to retrieve the data at the server side using its attributes. Flask is class used to create class instance in which __ name __ is passed as argument which represents the name of the application package. Flask-Session is an extension for Flask that support Server-side Session to the application. The Session is the time between the client logs in to the server and logs out of the server. flash( ) method of the flask module passes the message to the next request which is an HTML template.

  2. matplotlib.pyplot: matplotlib.pyplot is a collection of functions. Each pyplot function makes some change to a figure: e.g., creates a figure, creates a plotting area in a figure, plots some lines in a plotting area, decorates the plot with labels, etc. In matplotlib.

Index

With the release of localhost to run the application as the application begins to work index function will direct you to the index.html i.e., the home page of the application. The index page will direct user to any page of his/her choice. The url for index page is '/'.

Sign Up

From index page if user selects signup, the user is directed to the Sign Up page with url '/sign_up'. In the sign up route two methods are allowed i.e., GET and POST. When the request method to server is GET the html page for sign up is rendered to the user using render_template function. Where user have to fill the required fields and using submit button will send a POST request to the server after which the filled data will be extracted from the html form and a query is sent to the dB to check if the user with same username already exists or not if not the provided user data is stored in User table of database and user is redirected to the dashboard.

Login

From index page if user selects login, the user is directed to the Login page with url '/login'. In the sign up route two methods are allowed i.e., GET and POST. When the request method to server is GET the html page for login is rendered to the user using render_template function. Where user have to fill the required fields using submit button which will send a POST request to the server after which the filled data will be extracted from the html form and we will wirte query to check if user exist or not and if the userdata exists in database user is redirected to the dashboard, else will display error message using flash.

Dashboard

Login and signup will send a POST request to the server to redirect user to route url '/< string:username>/dashboard' (username is the application username of user) which will then render the dashboard html page to the user. In dashboard, user can create new trackers and if there are any previously created trackers present, they are displayed in the dashboard every time to the user in a tabular form.

Create Tracker

In dashboard if user selects Add tracker button i.e., url for route '/< string:username>/create_tracker' it will send a GET request to the server in response of it creater_tracker page is rendered to the user where user have to fill required fields to create a new tracker. Submitting the form provided to the user will send a POST reuqest to the server and the filled data is extracted from the html form and a query is sent to the dB to check if the tracker with same trackername already exists or not, if it does not exist, the provided trackerdata is stored in Tracker table of database and user is redirected to the dashboard displaying the newly created table on the dashboard and a relation between user_id and tracker id is created in secondary table user_tracker.

Log Tracker

In dashboard if user selects Add log button present in tracker table url for route '/< string:username>/<int:id >/logs'(id is tracker id) will send a GET request to the server in reponse of it log tracker page for the tracker type is rendered to the user where user have to fill required fields to log his/her tracker. Submitting the form provided to the user will send a POST reuqest to the server and the filled data is extracted from the html form and a query is sent to the dB to extract all preiviously created logs for the respective tracker and display all the logs on the log page in form of a table along with a graph(if applicable) the provided log data for respective tracker is stored in Log table of database and user is redirected back to the log page displaying the newly created table on the lag page.

Update Tracker

In dashboard if user selects update button present in the tracker table displayed on the dashboard will send a GET request to the server with route url '/< string:username>/update/<int:id >' in response of it update page for trackers is rendered to the user where user have to fill required fields to update the tracker. Submitting the form provided to the user will send a POST reuqest to the server and the filled data is extracted from the html form and a query is sent to the dB to delete the existing information for the tracker and to store newly updated data for the tracker in the Tracker table of dB and user is redirected to the dashboard displaying the updated table on the dashboard.

Delete Tracker

In dashboard if user selects delete button present in the tracker table displayed on the dashboard will send a GET request to the server with route url '/< string:username>/<int:id >/delete' in response of which a query is sent to the dB to delete the information for the tracker from thr Tracker table of dB and user is redirected to the dashboard displaying the updated table on the dashboard.

Update Log

In log tracker page for the respective tracker type if user selects update button present in the log table displayed on the log page will send a GET request to the server with route url '/< string:username>/<int:tracker_id >/<int:log_id >/update' in response of it update page for logs is rendered to the user where user have to fill required fields to update the tracker. Submitting the form provided to the user will send a POST request to the server and the filled data is extracted from the html form and a query is sent to the dB to delete the existing stored information for the tracker and add new log information for the respective tracker in the log table of dB and user is redirected to the log page displaying the updated table on the log page.

Delete Log

In log tracker page for the repective tracker type if user selects delete button present in the log table displayed on the log page will send a GET request to the server with route url '/< string:username>/<int:tracker_id >/< int:log_id>/delete' in response of which a query is sent to the dB to delete the information for the log present from the Log table of dB and user is redirected to the Log page displaying the updated table on the Log page.

Creator

  • Name : Shri Krishna Pandey
  • **Roll Number :
  • **Student Email :

Thanks

I am thankful to IIT Madras, Application Development 1 course team and peers for giving me the opportunity to develop such an interesting web application!

About

Quantified Self App using Python Flask, jinja2, SQLite for database.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors