This repository contains a Flask-based Sudoku game with puzzle generation, validation, hint support, and a web UI.
There are two related code paths in the starter/ folder:
starter/app/contains the current Flask application and Sudoku game logic used by the web app.starter/sudoku/contains the backend Sudoku generator, solver, and validation utilities imported by the Flask app.starter/sudoku_logic.pyis a separate legacy Sudoku helper module and is not required by the current Flask app.
-
Activate the virtual environment:
py -m venv .venv .\.venv\Scripts\Activate.ps1 -
Install dependencies (if not already installed):
pip install -r requirements.txt- Open a terminal in the workspace root:
cd C:\Users\arti.rajendra.jaware\Documents\GitHub\github-copilot-python\starter
-
Start the Flask app:
python app.py
-
Open a browser at
http://127.0.0.1:5000/.
-
starter/app.py- Application entrypoint.
- Imports
create_app()fromstarter/sudoku/__init__.pyand starts the Flask server.
-
starter/app/__init__.py- Creates the Flask app instance.
- Registers the main blueprint from
starter/app/routes.py.
-
starter/app/routes.py- Defines frontend routes and JSON API endpoints:
/returns the main HTML game page./api/newstarts a new game for the selected difficulty./api/validatechecks a user move against the stored solution./api/checkverifies the current board state./api/hintreturns the next hint and locks that cell.
- Defines frontend routes and JSON API endpoints:
-
starter/app/sudoku.py- Generates completed Sudoku grids and puzzles with unique solutions.
- Validates board completion.
- Finds incorrect cells.
- Provides a hint for the next empty or wrong cell.
-
starter/sudoku/generator.py- Creates a full Sudoku solution and removes cells to form a puzzle.
- Ensures puzzles have a unique valid solution.
-
starter/sudoku/solver.py- Implements backtracking-based solver utilities.
- Checks whether a move is safe and counts potential solutions.
-
starter/sudoku/validation.py- Validates an individual move within a board.
From starter/, run:
pytestTest files are located in starter/tests/.
- The app stores current game state in Flask session variables:
puzzle,solution,fixed, anddifficulty. - Difficulty levels are managed by the generator logic and control how many cells are left blank.
- The front-end logic and game UI live inside
starter/static/andstarter/templates/index.html.
starter/app/routes.pyfor API behavior.starter/app/sudoku.pyfor game logic and puzzle generation.starter/tests/to verify behavior and add new coverage.