Giter VIP home page Giter VIP logo

pycommerce's Introduction

Pycommerce

Overview (Work in Progress)

Pycommerce is an ecommerce example application intentionally designed to showcase how a medium-sized project structured with DDD, TDD, and Clean Architecture looks using the best of modern Python.

Although it's not a fully-featured real-world ecommerce application, it serves as an inspiration project that can be easily extended. It features:

Don't forget to check the FAQ for more information about the project's structure and design decisions.

Usage

While it's possible to run the application locally just using Python, it's highly recommended to install Docker to keep your local environment clean and facilitate the use of all the features.

Configuration

Pycommerce uses environment variables for configuration. You can check all the available options here. You can create and fill a .env file using the .env.example file as a reference, or set them manually like this:

export DB_URL="<database_url>"
export JWT_SECRET_KEY="<my_super_secret_key>"
...

If using Docker, just edit the environment variables on docker-compose.yml.

Installing

Activate your Python virtual environment and run:

poetry install

# or

pip install .

Type Checking

mypy pycommerce tests

Linting

ruff check .

Code Formatting

black --check pycommerce tests

Starting the Application

โš ๏ธ If not using Docker, remember to run the init.sql in your local database before running the application.

# set the DB_URL env var to point to the dev database, and run
alembic upgrade head && poetry run app

# or
alembic upgrade head && python -m pycommerce

# with Docker (optionally, you can add pg-admin to the list of containers)
docker-compose up app pg-db -d

Then, open the browser on http://localhost:8080/docs to see the OpenAPI docs:

Tests

# to run all the tests
pytest

# to run only the unit tests
pytest tests/unit/

# to run only the integration tests
pytest tests/integration/

# with Docker
docker-compose up tests

Development Workflow

Hot Reload

By default, hot reload is configured independently of whether you're using Docker or not, so you can have faster development feedback like this:

Watch Mode for Tests

Tests can also be triggered automatically whenever a test file is modified due to the use of pytest-watch, which leads to a nice and efficient TDD workflow:

For other options, you can use:

# to watch all project tests
docker-compose up watch

# to watch only the ingration tests
docker-compose up watch-integration

# without Docker
ptw -w -c tests/
ptw -w -c tests/unit/
ptw -w -c tests/integration/

License

This project is licensed under the MIT License - see the LICENSE file for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.