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
PythonFlaskSQLAlchemyFlask-Migrate
Frontend
HTMLCSSJavaScriptFetch APIChart.js
Database
PostgreSQLSQLite
AI
Google Gemini API
Infrastructure
DockerDocker ComposeRender
Testing and Automation
pytestGitHub 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()
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_URLexisted - 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
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
For AI-related functions:
Sales data
↓
Prompt-generation logic
↓
Gemini API
↓
AI-generated advice
↓
Displayed in the browser
For deployment:
GitHub
↓
GitHub Actions
↓
Render
↓
Flask application and PostgreSQL
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
- https://qiita.com/tosane932/items/ac18b633c8c87b9807bb
- https://qiita.com/tosane932/items/f0aeed574d39c5fa5093
- https://qiita.com/tosane932/items/e19ed4a2ffe27f53faf0
- https://qiita.com/tosane932/items/c1609f17cddf842f1e7c
- https://qiita.com/tosane932/items/b9b6576c1fda3d3a76d2
Pre-Production Inspection Trilogy
- https://qiita.com/tosane932/items/7a15e942745545a37b6a
- https://qiita.com/tosane932/items/3db0e915439048624a40
- https://qiita.com/tosane932/items/b9f32a1b03b99405ad0a
Top comments (0)