https://github.com/vlymar1/what_to_watch
A simple Flask web application that generates random opinions about movies
https://github.com/vlymar1/what_to_watch
alembic docker docker-compose flask makefile postgresql python sqlalchemy
Last synced: 3 months ago
JSON representation
A simple Flask web application that generates random opinions about movies
- Host: GitHub
- URL: https://github.com/vlymar1/what_to_watch
- Owner: vlymar1
- License: mit
- Created: 2024-10-29T19:49:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-29T19:59:38.000Z (over 1 year ago)
- Last Synced: 2025-09-07T07:24:48.618Z (10 months ago)
- Topics: alembic, docker, docker-compose, flask, makefile, postgresql, python, sqlalchemy
- Language: Python
- Homepage:
- Size: 609 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.python.org/)
[](https://flask.palletsprojects.com/en/stable/)
[](https://www.postgresql.org/)
[](https://flask.palletsprojects.com/en/stable/)
[](https://www.postgresql.org/)
[](https://www.docker.com/)
[](https://pypi.org/project/psycopg2-binary/)
# Simple Flask WebApp with Docker Compose, Makefile, and PostgreSQL
## Table of Contents
- [Project Description](#Project-Description)
- [Requirements](#Requirements)
- [Quick Start](#Quick-Start)
- [Project Structure](#Project-Structure)
- [API Endpoints](#API-Endpoints)
- [Implemented Makefile Commands](#Implemented-Makefile-Commands)
- [License](#license)
## Project Description
This project is a simple Flask web application that generates random opinions about movies and allows users to interact with these opinions.Key features include:
- ***Retrieve a Random Opinion:*** Users can get a random opinion about a movie.
- ***View Specific Opinions:*** Navigate to specific opinion details through direct links.
- ***Add New Opinions:*** Users can contribute their own movie opinions.
### Features
- ***Flask:*** Straightforward project structure with configurations for easy local setup.
- ***Docker Compose:*** Manages containerized services for the Flask app and PostgreSQL database.
- ***PostgreSQL:*** Configured as the default database, ready to run in a Docker container.
- ***Makefile:*** Simplifies common tasks, such as building containers, starting/stopping services, and running migrations.
- ***Environment Variables:*** .env.example included to simplify configuration of database credentials and other sensitive settings.
## Requirements
*To use this app, ensure you have the following installed on your machine:*
- ***Docker:*** Required for containerizing the Django application and PostgreSQL database.
- [Install Docker](https://docs.docker.com/get-docker/)
- ***Docker Compose:*** Used to manage multiple Docker containers in a single setup.
- Docker Desktop includes Docker Compose. Alternatively, install it separately: [Docker Compose Installation](https://docs.docker.com/compose/install/)
- ***Make:*** Allows simplified command execution using the Makefile.
- *Linux/macOS:* Make is usually pre-installed. If not, install it via your package manager:
```sh
# Ubuntu/Debian
sudo apt install make
# macOS (with Homebrew)
brew install make
```
- *Windows:* Use make with [Git Bash](https://gitforwindows.org/) or [WSL](https://docs.microsoft.com/en-us/windows/wsl/install) (Windows Subsystem for Linux).
## Quick Start
1. **Clone the repository:**
```sh
git clone https://github.com/dev-lymar/
cd
```
2. Setup environment variables from .env.example:
```sh
cp .env.example .env
```
3. Run project
```sh
make app
```
## Project Structure
*The project structure is organized to keep core components isolated and manageable:*
```sh
.
├── .env
├── Dockerfile
├── entrypoint.sh
├── Makefile
├── LICENSE
├── README.md
├── app
│ ├── static/
│ ├── templates/
│ ├── api_views.py
│ ├── cli_commands.py
│ ├── error_handlers.py
│ ├── forms.py
│ ├── models.py
│ └── views.py
└── docker_compose
├── app.yaml
├── db.yaml
└── docker-compose.prod.yaml
```
## API Endpoints
*The API provides the following endpoints for interacting with opinions:*
1. **Get, Update, or Delete a Specific Opinion**
- Endpoint: `/api/opinions//`
- Methods: `GET` (retrieve a specific opinion), `PATCH` (update an opinion), `DELETE` (remove an opinion)
2. **Retrieve List of Opinions or Add New Opinion**
- Endpoint: `/api/opinions/`
- Methods: `GET` (retrieve all opinions), `POST` (add a new opinion)
3. **Get Random Opinion**
- Endpoint: `/api/get-random-opinion/`
- Methods: `GET` (retrieve a random opinion from the database)
## Implemented Makefile Commands
* `make app` - Starts the application and database infrastructure.
* `make app-logs` - Follow the logs in app container.
* `make app-container` - Connects to the application container for interactive commands.
* `make app-down` - Down application and all infrastructure.
* `make db` - Up only infrastructure. You should run your application locally for debugging/developing purposes.
* `make db-logs` - Follow the logs in storages containers.
* `make db-down` - Down all infrastructure.
* `make postgres` - Enter postgres container.
* `make migrate` - Runs database migrations inside the app container.
* `make app-prod` - Launches the application in production mode with production-specific settings.
* `make app-prod-down` - Stops and removes the production setup.
## License
This project is licensed under the MIT License. See the LICENSE file for more information.