DEV Community

Cover image for My Progress After Two Months and 129 Hours of Learning Python — Building a Bakery Sales Management System
tosane932
tosane932

Posted on • Originally published at qiita.com

My Progress After Two Months and 129 Hours of Learning Python — Building a Bakery Sales Management System

This article was originally published in Japanese on Qiita and has been translated and adapted for DEV Community.

Introduction

Hello from Japan! 🇯🇵

I started learning Python on May 12, 2026.

Approximately two months have passed, and my total study time has reached 129 hours.

To record my current progress, I have published a bakery sales management system that I developed while learning.

GitHub repository:

https://github.com/tosane932/sales_data_app


🍞 What I Built

I built a web-based sales management application for bakery stores.

It is more than a simple sales-entry form.

The system includes:

  • Product master management
  • Daily sales entry
  • Data storage in PostgreSQL
  • Sales rankings
  • AI-powered sales analysis
  • An AI staff assistant

You can try the deployed application here:

https://bakery-salesdata.onrender.com/

The application runs on a free hosting plan, so it may take a little time to start if the server has been inactive.


📖 Why I Built It

I currently work in logistics as a driver of large and medium-sized trucks.

Before working in logistics, I also had experience selling food at department-store events.

In those workplaces, I repeatedly encountered situations where sales management depended heavily on Excel.

That made me wonder:

Could daily sales entry, aggregation, and analysis all be handled in one system?

That question became the starting point for this application.

I wanted to build something that reflected actual workplace needs rather than creating a project only for programming practice.


⚒️ Technology Stack

Backend

  • Python
  • Flask
  • SQLAlchemy
  • Flask-Migrate

Frontend

  • HTML
  • CSS
  • JavaScript
  • Fetch API
  • Chart.js

Database

  • PostgreSQL
  • SQLite

AI

  • Google Gemini API

Infrastructure

  • Docker
  • Docker Compose
  • Render

Testing and Automation

  • pytest
  • GitHub Actions

⚙️ Implemented Features

Product Registration

Users can register bakery products and their prices for each month.

The product information is then used by the daily sales-entry feature.

Daily Sales Entry

Users can enter the number of units sold for each product.

The page also displays a short seasonal message generated by AI.

Sales Analysis

The application aggregates the stored sales data and displays:

  • Product rankings
  • Sales charts
  • AI-generated business advice

The goal is not only to store numbers, but also to help users understand what the numbers may indicate.


💡 What I Focused On

In logistics, we work with the assumption that:

An accident may happen.

I tried to apply the same mindset to software development.

Instead of assuming:

The application will probably work correctly.

I designed it around the possibility that:

A user may enter invalid data, or an important setting may be missing.

Examples include:

  • Input validation
  • Exception handling
  • Application logging
  • Environment-variable management
  • Fail-Fast behavior

I wanted the system to detect problems early instead of depending only on users or developers behaving perfectly.


Defensive Design Examples

Input Validation

The application checks values before saving them to the database.

This reduces the risk of invalid sales data entering the system.

Environment-Variable Checks

The application verifies that required configuration values are available.

If a required value is missing, the system can stop before a user reaches the broken feature.

Logging

Important startup events and errors are written to standard output.

This makes it easier to investigate problems in Docker and Render.

Database Migration Management

I moved away from relying only on:

db.create_all()
Enter fullscreen mode Exit fullscreen mode

and introduced Flask-Migrate to manage database schema changes through migration history.


🏗️ What Was Most Difficult

The most difficult problem was:

It works locally, but it does not work in production.

I encountered differences involving:

  • Docker
  • PostgreSQL
  • Render
  • Environment variables
  • Python package versions
  • Database connection URLs
  • Persistent storage

I investigated each issue separately instead of trying to change everything at once.

For example, I checked:

  • Whether the required package was installed
  • Whether the version matched requirements.txt
  • Whether DATABASE_URL existed
  • Whether the application was connected to SQLite or PostgreSQL
  • Whether the migration command completed successfully
  • Whether the production logs matched my expectations

This process taught me that production problems are not always caused by the application code itself.

Sometimes the code is correct, but the surrounding infrastructure is incomplete or configured differently.


🚚 From Local Development to Automatic Deployment

The current workflow is:

Modify the application locally
        ↓
Run tests
        ↓
Push the changes to GitHub
        ↓
GitHub Actions runs pytest
        ↓
Render detects the update
        ↓
The application is built and deployed
Enter fullscreen mode Exit fullscreen mode

The project is now configured so that a GitHub push triggers automated testing through GitHub Actions and deployment to Render.

This does not mean the system is perfect.

However, it is a significant improvement over manually updating the production environment without an automated check.


✅ Testing

I currently use pytest to test the prompt-generation logic.

For example, I verify that:

  • Sales data is included in the generated prompt
  • Important AI instructions are included
  • The function returns a string
  • The output does not lose required content

The number of tests is still limited.

My next goal is to expand the test coverage to include:

  • Database operations
  • Input validation
  • Flask routes
  • API error handling
  • Authentication-related behavior
  • Integration between application components

I also learned that simply writing tests is not enough.

I need to deliberately break the relevant behavior and confirm that the tests actually detect it.


📊 Current Application Structure

The overall structure is approximately:

Browser
   ↓
Flask application
   ↓
SQLAlchemy
   ↓
PostgreSQL
Enter fullscreen mode Exit fullscreen mode

For AI-related functions:

Sales data
   ↓
Prompt-generation logic
   ↓
Gemini API
   ↓
AI-generated advice
   ↓
Displayed in the browser
Enter fullscreen mode Exit fullscreen mode

For deployment:

GitHub
   ↓
GitHub Actions
   ↓
Render
   ↓
Flask application and PostgreSQL
Enter fullscreen mode Exit fullscreen mode

Building these connected parts was much more difficult than creating a single page.

However, it helped me understand how application code, databases, testing, and infrastructure work together.


🚧 What I Want to Add Next

I plan to continue developing the system with features such as:

  • Inventory management
  • Purchase-order suggestions
  • AI-powered stockout prediction
  • Profit analysis
  • Weekday and seasonal analysis
  • More comprehensive automated tests
  • Improved error messages
  • Better mobile usability

My goal is to develop the project into a system that could genuinely help people working in a busy store.


What I Learned After 129 Hours

After approximately two months of study, I have learned that building a working application requires more than writing Python code.

It also involves:

  • Understanding user needs
  • Designing database structures
  • Managing dependencies
  • Handling failures
  • Reading logs
  • Testing assumptions
  • Deploying the application
  • Maintaining the production environment

I still have many areas to improve.

However, I can now investigate problems by separating them into categories such as:

  • Code
  • Data
  • Dependencies
  • Environment variables
  • Database
  • Infrastructure
  • User input

That change in how I approach problems may be one of the most important results of these 129 hours.


🍞 Conclusion

Approximately two months and 129 hours after beginning Python, I was able to develop and publish this application.

There are still many improvements I want to make and many topics I need to learn.

However, I have tried not to make “studying programming” the final goal.

Instead, I have focused on:

Learning by building something that actually works.

I want to continue adding features and improving the application little by little.

When I read this article again several months from now, I hope I will be able to think:

This was how far I had come at that time.

Thank you for reading.

Demo

https://bakery-salesdata.onrender.com/

GitHub

https://github.com/tosane932/sales_data_app


sales_data_app Maintenance Series

Pre-Production Inspection Trilogy

Post-Deployment Maintenance Series

🍞 sales_data_app on GitHub

Top comments (0)