This project involves building a Freebie Tracker App for developers attending hackathons. The app will help developers keep track of the free items (freebies) they receive. The application is built using Python with SQLAlchemy to manage the database relationships.
The app consists of three models:
- Company: A company that gives out freebies.
- Dev: A developer who collects freebies.
- Freebie: Represents a free item given by a company to a developer.
A Company has many Freebies, a Dev has many Freebies, and a Freebie belongs to both a Dev and a Company. The relationship between Company and Dev is a many-to-many relationship.
Ensure you have the following installed:
- Python (3.x recommended)
- pipenv (for dependency management)
- SQLAlchemy (ORM for database management)
Clone the repository and navigate to the project directory:
$ git clone <repository-url>
$ cd freebie-tracker-appInstall dependencies and activate the virtual environment:
$ pipenv install && pipenv shell-
Migrate the Database
- Create the
freebiestable with necessary attributes and foreign keys. - Run the migrations using SQLAlchemy.
- Create the
-
Seed the Database
- Populate the database with sample data using
seed.py.
- Populate the database with sample data using
-
Test the App
- Run the debug tool to test the implemented methods:
$ python debug.py
- Use the interactive shell to check object relationships and methods.
-
Implement Methods
- Follow the deliverables list to implement and test methods for the models.
- Ensure relationships are correctly established.
| Column | Type |
|---|---|
| name | String |
| founding_year | Integer |
| Column | Type |
|---|---|
| name | String |
| Column | Type |
|---|---|
| item_name | String |
| value | Integer |
| dev_id | ForeignKey (devs.id) |
| company_id | ForeignKey (companies.id) |
Freebie.dev: Returns the Dev instance associated with the freebie.Freebie.company: Returns the Company instance associated with the freebie.Freebie.print_details(): Returns a formatted string:{dev name} owns a {freebie item_name} from {company name}.
Company.freebies: Returns all freebies given by the company.Company.devs: Returns all developers who collected freebies from the company.Company.give_freebie(dev, item_name, value): Creates a new Freebie instance associated with the company and the given developer.Company.oldest_company(): Returns the company with the earliest founding year.
Dev.freebies: Returns all freebies collected by the developer.Dev.companies: Returns all companies the developer has received freebies from.Dev.received_one(item_name): ReturnsTrueif the developer has received a freebie with the given item_name, otherwiseFalse.Dev.give_away(dev, freebie): Transfers a freebie from one developer to another if the freebie belongs to the giving developer.
- Run the debug session:
$ python debug.py- Use the interactive shell to create instances and test relationships.
- Focus on error-free code before completing all deliverables.
- Test your code frequently in the console.
- Prioritize working code over clean code; refactor later if time allows.
- Leave comments if methods are incomplete.
Before submitting:
- Ensure all required methods are implemented and functional.
- Run and verify that your code works as expected.
- Comment on any incomplete or non-working methods explaining your progress.
Developed as part of a Moringa School student Project by Kairu Maina.
This project is licensed under the MIT License.