Skip to content

A minimalist virtual pet built with Flask, Python, and SQLite. Your Tama evolves, reacts to real time, and needs care. Feed, clean, play, and heal your pet. CS50 Final Project — full-stack: Flask, SQLite, HTML/CSS.

Notifications You must be signed in to change notification settings

annaescalada/tamalife-flask-python-sqlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TamaLife

TamaLife is a virtual pet web application built with Flask and SQLite for CS50. The user can create a pet, interact with it, and keep it alive by maintaining four core stats: Hunger, Happiness, Cleanliness, and Health.

The project includes:

  • User registration and login system
  • A virtual pet associated with each user
  • Automatic stat decay over time
  • Evolution system based on pet age
  • Interactive actions to restore stats
  • Dynamic updates on the homepage using JavaScript polling

Features

1. User Accounts

Users can register, log in, and log out. Passwords are hashed using Werkzeug and stored securely in the database.

2. Pet Creation

Each user can create a single pet. The initial pet starts at full health and evolves over time.

3. Evolution System

The pet evolves according to its age in minutes. Stages include: Egg → Baby → Child → Teen → Adult → Elder → Dead.

4. Stat Decay

Stats automatically change over time depending on the last update timestamp. If a stat reaches a critical threshold, the pet will die.

5. Actions

Users can improve their pet's stats through four actions:

  • Feed
  • Play
  • Clean
  • Heal

These actions update the database and refresh the UI.

6. Live Updating

The homepage polls the /pet-status route every second. The frontend updates the pet sprite, animations, and progress bars without reloading the page.


Files

app.py

Main Flask application:

  • Route definitions
  • User authentication
  • Pet creation
  • Pet actions
  • Rendering templates

helpers.py

Contains helper functions:

  • login_required decorator
  • compute_stage (evolution logic)
  • update_needs (stat decay system)

static/

Contains:

  • CSS files
  • Pet sprite images
  • Backgrounds and UI assets

templates/

Contains Jinja templates:

  • layout.html
  • index.html
  • create_pet.html
  • login.html
  • register.html
  • dead.html

tama.db

SQLite database storing:

  • Users
  • Pets
  • All associated stats

How to Run

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Run Flask:

    flask run
    
  3. Access the app in your browser at:

    http://127.0.0.1:5000/
    

Database Schema

users table

  • id (INTEGER PRIMARY KEY)
  • username (TEXT UNIQUE)
  • hash (TEXT)

pet table

  • id
  • user_id
  • name
  • health
  • hunger
  • happiness
  • hygiene
  • birth
  • last_update

Acknowledgements

This project was created as part of Harvard's CS50. Frameworks and libraries used:

  • Flask
  • SQLite
  • Jinja
  • CS50 Library for Python

This project also used GPT-5 for image generation and for code suggestions during the development process.

About

A minimalist virtual pet built with Flask, Python, and SQLite. Your Tama evolves, reacts to real time, and needs care. Feed, clean, play, and heal your pet. CS50 Final Project — full-stack: Flask, SQLite, HTML/CSS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published