TiagoGIM/flaskdockerapi

This is a Python CRUD project using Flask, Docker and PostgreSQL. It includes a Dockerfile, Python source code, and SQLAlchemy for easy database configuration. CRUD capabilities enable create, read, update, and delete operations. Code is structured in a modular, clean way for easy maintenance. Requirements file also provided.

★ 1Forks 0PythonGitHub ↗Compare

README

Python Flask CRUD Project

This is a Python CRUD project using Flask, Docker and PostgreSQL. It includes a Dockerfile, Python source code, and SQLAlchemy for easy database configuration. CRUD capabilities enable create, read, update, and delete operations. Code is structured in a modular, clean way for easy maintenance.

This application uses the Model-View-Controller (MVC) pattern to separate the different parts of the application into three distinct components. I believe that this approach can make my code more modular, easier to maintain and update, and facilitate collaboration among us developers. In brief, the use of the MVC pattern makes my application more robust, scalable, and easy to maintain.

For a step-by-step tutorial on how to set up and run this app, please check out our tutorial at link

Project Structure

├── controllers/
│   └── user_controller.py
├── models/
│   ├── __init__.py
│   └── user.py
├── repositories/
│   └── user_repository.py
├── services/
│   └── user_service.py
├── app.py
├── docker-compose.yml
├── Dockerfile
├── extensions.py
└── routes.py
  • app.py: main Flask application file
  • extensions.py: module for extensions (e.g. DB) initialization and connection to database (db.session)
  • routes.py: directory for Flask routes
  • Dockerfile: Dockerfile for building the app
  • requirements.txt: requirements file for pip
  • services:
  • controllers:
  • models: directory for database models

Getting Started

  1. Clone the repository:
    git clone https://github.com/username/repo.git
    
  2. To run the Postgres container, type:
    docker compose up -d flask_db
    
  3. Go back to the folder where the docker-compose.yml is located and type:
    docker compose build
    
    
  4. Run the flask_app service:
  docker compose up flask_app

  1. Access the app in your browser at http://localhost:5000/.

CRUD Operations

This app enables the following CRUD operations:

  • Create: Adds a new entry to the database.
  • Read: Retrieves data from the database.
  • Update: Modifies an existing entry in the database.
  • Delete: Removes an entry from the database.

Supporting Material

Contributing

To contribute to this project, please fork the repository and submit a pull request.

WIP

Next steps and use cases doc

Contributors

TiagoGIM

Issues