Skip to content

API for selling and buying everything

License

Notifications You must be signed in to change notification settings

arshia-rgh/deal_direct

Repository files navigation

DealDirect

Python

Django

Django REST Framework

Django Channels

Redis

RabbitMQ

Celery

Docker

SQLite

PostgreSQL

HTML

Pytest

Swagger UI

Redoc

Black

License

------------------------------------------------

Table of Contents

------------------------------------------------

Endpoints

To see the current endpoints, run the following command:

python manage.py stdout_endpoints > ENDPOINTS.md

------------------------------------------------

API Documentation

The API documentation is available in two formats:

  • Swagger UI: Provides an interactive API documentation interface.

    • URL: http://127.0.0.1:8000/api/schema/swagger-ui/
  • Redoc: Provides a more detailed and customizable API documentation interface.

    • URL: http://127.0.0.1:8000/api/schema/redoc/

------------------------------------------------

ERD

checkout the diagram at:

------------------------------------------------

Code Formatting

This project uses black for code formatting. Black is a code formatter for Python that ensures consistent code style.

Pre-commit Hooks

Pre-commit hooks are used to ensure code quality before committing changes. This project uses the following pre-commit hooks:

  • check-yaml: Checks YAML files for syntax errors.

  • end-of-file-fixer: Ensures files end with a newline.

  • trailing-whitespace: Removes trailing whitespace.

  • black: Formats Python code using black.

To install the pre-commit hooks, run:

pre-commit install

to run the pre-commit hooks manually, use:

pre-commit run --all-files

------------------------------------------------

Usage

  1. Clone the repository:
git clone [email protected]:serene1212/porsojo.git
  1. Navigate to the project directory:
cd deal_direct
  1. Install the required packages:
python -m venv .venv

source .venv/bin/activate

pip install -r requirements.txt
  1. Copy sample.env and change variables:
cp sample.env .env
  1. Run the server:
python manage.py runserver

Using Docker

To build and run the Docker containers, use the following commands:

docker-compose up --build

This will start all the necessary services defined in the docker-compose.yml file.

For more details, refer to the Dockerfile in the project repository. ------------------------------------------------

Chat Feature

You can start real time chat for a product with the seller of the product.

How to Use the Chat

  1. Run the Django Development Server:

    python manage.py runserver
  2. Access the Chat Room:

  3. Start Chatting:

    • Type a message in the input box and press "Send" or hit the Enter key to send the message. Messages will appear in the chat log.
  4. Permissions:

    • The IsParticipant permission class ensures that only authenticated users who are participants of the chat room can access the chat.

Testing

This project aims to achieve over 95% test coverage.

All tests are written using pytest.

To run the tests and see the coverage report, use the following command:

pytest --cov --cov-config=.coveragerc

this command will exclude custom_commands directory from testing