** educational project **
A console-based application for searching movies with support for flexible filtering, search history tracking, and analytical reports.
This project is built using a functional programming approach and demonstrates working with relational and non-relational databases, modular architecture, and CLI interaction design.
- Search movies by keyword
- Filter by genre
- Filter by years
- Search by year or range of years
- Combined search (genre + year range)
- Top 5 most popular search queries
- Last 5 recent search queries
- Query performance tracking (execution time, result count)
- MySQL โ the main source of data on films
- MongoDB โ storing query history and analytics
-
Pagination for search results
-
Input validation and error handling
-
Query logging with metadata:
- timestamp
- parameters
- execution time
- success status
The project has been refactored into a modular and scalable architecture, separating responsibilities across distinct layers. This improves readability, maintainability, and prepares the codebase for future extensions (such as OOP or API integration).
app/
โ
โโโ main.py # Application entry point
โ
โโโ db/ # Data access layer (database interaction)
โ โโโ sql_connection.py # MySQL connection setup
โ โโโ sql_queries.py # SQL queries for movie search
โ โโโ mongo_connection.py # MongoDB connection setup
โ โโโ mongo_queries.py # Aggregation pipelines for analytics
โ
โโโ menu/ # CLI interface (user interaction layer)
โ โโโ main_menu.py # Main application menu
โ โโโ search_menu.py # Search options menu
โ โโโ stats_menu.py # Statistics menu
โ
โโโ flows/ # Application flows (user scenarios)
โ โโโ keyword_flow.py # Keyword search logic
โ โโโ genre_flow.py # Genre-based search
โ โโโ years_flow.py # Year/range search
โ โโโ genre_years_flow.py # Combined search (genre + years)
โ
โโโ services/ # Business logic layer
โ โโโ search_service.py # Search execution & orchestration
โ โโโ log_service.py # Logging search requests (MongoDB)
โ โโโ stats_service.py # Statistics and reporting logic
โ
โโโ utils/ # Utility functions (helpers)
โ โโโ input_utils.py # Safe input handling & validation
โ โโโ pagination.py # Paginated output for results
โ โโโ year_utils.py # Year normalization & parsingThe application follows a layered structure, where each module has a clear responsibility:
- menu/ โ handles user interaction (CLI interface)
- flows/ โ defines user scenarios and orchestrates actions
- services/ โ contains core business logic
- db/ โ responsible for all database operations
- utils/ โ reusable helper functions
- ๐ Clear separation of concerns
- ๐ง Easier debugging and testing
- ๐ฆ Scalable and extensible architecture
- ๐ Ready for transition to OOP (v2.0.0)
- ๐ Prepared for future features (i18n, authentication, UI)
๐ก This structure reflects a transition from a monolithic script to a production-like modular design, making the project easier to maintain and evolve.
- Python 3.14
- MySQL (relational database)
- MongoDB (NoSQL database)
- PyMySQL (MySQL connector)
- pymongo (MongoDB driver)
git clone https://github.com/devsmish/movie_search_console_app.git
cd movie_search_console_appExample configuration:
class Config:
MYSQL_HOST = "localhost"
MYSQL_USER = "your_user"
MYSQL_PASSWORD = "your_password"
MYSQL_DATABASE = "sakila"
MONGO_URI = "mongodb://localhost:27017/"
MONGO_DATABASE = "movie_search"
MONGO_COLLECTION = "logs"pip install pymysql pymongopython app/main.pyMAIN MENU
1. Search movies
2. View statistics
Q. Exit
{
"timestamp": "2026-03-30T12:00:00",
"search_type": "keyword",
"params": {
"keyword": "action",
"genre": "action",
"start_year": 1990,
"end_year": 2025},
"results_count": 42,
"duration_ms": 15.3,
"success": true,
"query_key": "keyword_action"
}This version is implemented using a functional approach:
- Business logic is split into reusable functions
- Search flows are isolated and modular
- Logging and execution are abstracted via helper functions
This design provides:
- simplicity
- predictability
- ease of debugging
- Project restructuring (modular architecture)
- Improved documentation (docstrings)
- Internationalization (multi-language support)
- Basic user authentication
- Advanced analytics and reporting
- Stable functional architecture
- Transition to Object-Oriented Programming (OOP)
- UI layer (graphical interface)
- UI layer (web interface)
Contributions, issues, and feature requests are welcome!
This project is open-source and available under the MIT License.
This project uses the Sakila sample database, a standard MySQL example dataset for learning and testing. The database is licensed under the BSD 3-Clause License, which allows free use, modification, and distribution. Source: https://dev.mysql.com/doc/sakila/en/sakila-license.html