Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

movie_search_console_app

** educational project **

๐ŸŽฌ Movie Search Console App

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.


๐Ÿš€ Features

๐Ÿ” Search Functionality

  • Search movies by keyword
  • Filter by genre
  • Filter by years
  • Search by year or range of years
  • Combined search (genre + year range)

๐Ÿ“Š Statistics & Analytics

  • Top 5 most popular search queries
  • Last 5 recent search queries
  • Query performance tracking (execution time, result count)

๐Ÿ—„ Data Management

  • MySQL โ€” the main source of data on films
  • MongoDB โ€” storing query history and analytics

๐Ÿง  Additional Functionality

  • Pagination for search results

  • Input validation and error handling

  • Query logging with metadata:

    • timestamp
    • parameters
    • execution time
    • success status

๐Ÿ— Project Structure

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 & parsing

๐Ÿง  Architectural Overview

The 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

โœ… Benefits of This Structure

  • ๐Ÿ“Œ 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.


โš™๏ธ Technologies Used

  • Python 3.14
  • MySQL (relational database)
  • MongoDB (NoSQL database)
  • PyMySQL (MySQL connector)
  • pymongo (MongoDB driver)

โ–ถ๏ธ Getting Started

1. Clone the repository

git clone https://github.com/devsmish/movie_search_console_app.git
cd movie_search_console_app

2. Create and configure .env or config.py

Example 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"

3. Install dependencies

pip install pymysql pymongo

4. Run the application

python app/main.py

๐Ÿงช Example Usage

MAIN MENU
1. Search movies
2. View statistics
Q. Exit

๐Ÿ“ˆ Example Logged Data (MongoDB)

{
  "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"
}

๐Ÿงฉ Architecture Notes

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

๐Ÿ”ฎ Roadmap

๐Ÿ”ง v0.10.0

  • Project restructuring (modular architecture)
  • Improved documentation (docstrings)

๐ŸŒ v0.11.0

  • Internationalization (multi-language support)

๐Ÿ” v0.12.0

  • Basic user authentication

๐Ÿ“Š v0.14.0

  • Advanced analytics and reporting

๐Ÿ v1.0.0

  • Stable functional architecture

๐Ÿ”„ v2.0.0

  • Transition to Object-Oriented Programming (OOP)

๐ŸŽจ v3.0.0

  • UI layer (graphical interface)

๐ŸŽจ v4.0.0

  • UI layer (web interface)

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome!


๐Ÿ“„ License / Data Source

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

About

educational project

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages