generated from ilkersigirci/python-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4baabe
commit 17b333a
Showing
1 changed file
with
28 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,123 +1,47 @@ | ||
# movie-guess | ||
# Movie Guess Game 🎬 | ||
|
||
Guess the movie from its posters and banners | ||
A web-based movie guessing game where players try to identify movies based on their backdrop images. The game progressively reveals more backdrops as players make incorrect guesses. | ||
|
||
## Project Structure | ||
## Features | ||
|
||
- It uses [uv](https://github.com/astral-sh/uv) for python dependency operations and virtual environment management. | ||
- It uses `project.toml` instead of `setup.py` and `setup.cfg`. The reasoning is following: | ||
- As [official setuptools guide](https://github.com/pypa/setuptools/blob/main/docs/userguide/quickstart.rst) says, " configuring new projects via setup.py is discouraged" | ||
- One of the biggest problems with setuptools is that the use of an executable file (i.e. the setup.py) cannot be executed without knowing its dependencies. And there is really no way to know what these dependencies are unless you actually execute the file that contains the information related to package dependencies. | ||
- The pyproject.toml file is supposed to solve the build-tool dependency chicken and egg problem since pip itself can read pyproject.yoml along with the version of setuptools or wheel the project requires. | ||
- The pyproject.toml file was introduced in PEP-518 (2016) as a way of separating configuration of the build system from a specific, optional library (setuptools) and also enabling setuptools to install itself without already being installed. Subsequently PEP-621 (2020) introduces the idea that the pyproject.toml file be used for wider project configuration and PEP-660 (2021) proposes finally doing away with the need for setup.py for editable installation using pip. | ||
- **Progressive Revelation**: Start with one movie backdrop, with more revealed after incorrect guesses | ||
- **Fuzzy Search**: Search for movies with forgiving text matching | ||
- **Real-time Search**: Search results update as you type | ||
- **Responsive Design**: Works on both desktop and mobile devices | ||
- **Clean UI**: Built with PicoCSS for a minimal, clean interface | ||
|
||
## Tech Stack | ||
|
||
## Install | ||
- **FastHTML**: A Python framework combining Starlette, Uvicorn, HTMX, and fastcore | ||
- **HTMX**: For dynamic content updates without writing JavaScript | ||
- **PicoCSS**: For styling and responsive design | ||
- **TMDB API**: For movie data and images | ||
|
||
### Default installation | ||
|
||
- Install uv - System wide | ||
|
||
```bash | ||
make -s install-uv | ||
source ~/.bashrc | ||
``` | ||
|
||
- Install the project dependencies | ||
## Running the Application | ||
|
||
1. Install the dependencies: | ||
```bash | ||
make -s install | ||
``` | ||
|
||
- After running above command, the project installed in editable mode with all development and test dependencies installed. | ||
|
||
### Docker | ||
|
||
```bash | ||
# Development build | ||
docker build --tag movie-guess --file docker/Dockerfile --target development . | ||
|
||
# Production build | ||
docker build --tag movie-guess --file docker/Dockerfile --target production . | ||
``` | ||
|
||
- To run command inside the container: | ||
|
||
2. Start the server: | ||
```bash | ||
docker run -it movie-guess:latest bash | ||
# Set up your TMDB API key | ||
export TMDB_API_KEY="your_api_key_here" | ||
|
||
# Temporary container | ||
docker run --rm -it movie-guess:latest bash | ||
make run-fasthtml | ||
``` | ||
|
||
- Development inside the container: | ||
- For more information [watch-versus-bind-mounts](https://docs.docker.com/compose/file-watch/#compose-watch-versus-bind-mounts) | ||
|
||
```bash | ||
docker compose up -d movie-guess-dev --watch | ||
3. Open your browser and navigate to: | ||
``` | ||
|
||
- Run production image: | ||
|
||
```bash | ||
docker compose up -d movie-guess-prod | ||
http://localhost:5001 | ||
``` | ||
|
||
## IDE Setings | ||
|
||
### Pycharm | ||
## Game Rules | ||
|
||
- Line-length: `Editor -> Code Style -> Hard wrap at 88` | ||
|
||
#### Inspections | ||
|
||
Settings -> Editor -> Inspections -> Python | ||
|
||
Enable all except: | ||
|
||
- Accessing a protected member of a class or a module | ||
- Assignment can be replaced with augmented assignments | ||
- Classic style class usage | ||
- Incorrect BDD Behave-specific definitions | ||
- No encoding specified for file | ||
- The function argument is equal to the default parameter | ||
- Type checker compatible with Pydantic | ||
- For "PEP 8 coding style violation": | ||
Ignore = E266, E501 | ||
- For "PEP 8 naming convetion violation": | ||
Ignore = N803 | ||
|
||
#### Plugins | ||
|
||
- Ruff | ||
- Pydantic | ||
|
||
### Vscode | ||
|
||
- All recommended settings and extensions can be found in `.vscode` directory. | ||
|
||
## Useful Makefile commands | ||
|
||
```bash | ||
# All available commands | ||
make | ||
make help | ||
|
||
# Run all tests | ||
make -s test | ||
|
||
# Run specific tests | ||
make -s test-one TEST_MARKER=<TEST_MARKER> | ||
|
||
# Remove unnecessary files such as build,test, cache | ||
make -s clean | ||
|
||
# Run all pre-commit hooks | ||
make -s pre-commit | ||
|
||
# Lint the project | ||
make -s lint | ||
|
||
# Profile a file | ||
make -s profile PROFILE_FILE_PATH=<PATH_TO_FILE> | ||
``` | ||
1. A movie backdrop is displayed | ||
2. Type your guess into the search box | ||
3. Select a movie from the search results | ||
4. Click "Submit Guess" | ||
5. If incorrect, a new backdrop is revealed | ||
6. Game continues until you guess correctly or run out of backdrops |