The "Skyproduct" Django app is a powerful e-commerce solution designed to manage and display product data efficiently. It provides a comprehensive database for storing product information and offers insightful data analytics for sales. With built-in authentication and deployment using Nginx, Gunicorn, and Unicorn, Skyproduct ensures a secure and high-performance environment for your e-commerce needs.
Skyproduct comes equipped with a robust product database that allows you to store detailed information about your products. Each product can have attributes like name, description, price, and category, ensuring that you can efficiently manage your product catalog.
Skyproduct simplifies the process of monitoring your product sales by providing an aggregated product table. This table displays a summary of essential product information, including name, category, and aggregated sales data. This feature allows you to gain quick insights into your product performance.
Keeping track of your sales trends is crucial for making informed business decisions. Skyproduct offers two distinct views for sales analytics:
-
Last Month Aggregated Sales: Skyproduct compiles data from the previous month to give you an overview of how your products performed in the past.
-
Current Month Aggregated Sales: Stay up-to-date with your sales in real-time. Skyproduct calculates and displays the sales data for the current month, helping you make timely adjustments to your business strategy.
Skyproduct includes a robust user authentication system, ensuring that only authorized personnel can access sensitive areas of your e-commerce platform. This feature provides peace of mind and protects your valuable data.
Skyproduct is ready for production deployment, thanks to its integration with Nginx, Gunicorn, and Unicorn. This stack ensures high performance, availability, and high-load resistance for your e-commerce website.
Note for Windows Users:
If you are using Windows, it's important to ensure that you have Windows Subsystem for Linux (WSL) 2 installed and configured correctly before running the provided commands under a WSL terminal. WSL 2 provides a Linux-compatible environment that can be used for development tasks.
To install and set up WSL 2 on your Windows machine, please follow the official Microsoft documentation: Install Windows Subsystem for Linux (WSL).
Once WSL 2 is set up, make sure to use the WSL terminal for running the commands specified in this documentation for a seamless development experience.
If you encounter any issues related to WSL or need further assistance, please refer to the Microsoft WSL documentation or seek support from the WSL community.
Install poetry using your package manager or official guide. (Project was maintained mostly with 1.6.1)
The easiest way to install required and dev dependencies is as follows:
make install| Environment Variable | Description |
|---|---|
| SECRET_KEY | Django's secret key used for cryptographic functions. Keep this value secret and secure. |
| DJANGO_ALLOWED_HOSTS | A list of allowed hostnames or IP addresses that can access the Django application. |
| DJANGO_INTERNAL_IPS | A list of your local machine IP addresses used by Django debug toolbar (not required in production) |
| DJANGO_SETTINGS_MODULE | Specifies the Django settings module to be used. Typically set to the development settings. |
| DB_ENGINE | Specifies the database engine to be used, in this case, PostgreSQL. |
| DB_DATABASE | The name of the PostgreSQL database for the Django application. |
| DB_USER | The username used to connect to the PostgreSQL database. |
| DB_PASSWORD | The password used to authenticate the PostgreSQL database user. |
| DB_HOST | The hostname of the PostgreSQL database server. |
| DB_PORT | The port number to connect to the PostgreSQL database server. |
| DB_NAME | An alternative database name, typically set to 'postgres' for PostgreSQL configurations. |
| DATABASE | An alias for the 'DB_NAME' environment variable, used in Django settings. |
| NGINX_PORT | The port number on which the Nginx web server should listen. |
| REDIS_BACKEND | The connection URL for the Redis cache backend, specifying the Redis server and port to use. |
-
Create a
.envFile:- Create a
.envfile in the root directory of your project if it doesn't already exist.
- Create a
-
Open the
.envFile:- Open the
.envfile using a text editor of your choice.
- Open the
-
Define Environment Variables:
-
Inside the
.envfile, define the following environment variables, providing values specific to your project:SECRET_KEY=django-secure-chw!h4ulgqj4=agc%@yhi9fj8^4sqn2gbiq38!!e+fact9f-7 DJANGO_ALLOWED_HOSTS='localhost 127.0.0.1 [::1]' DJANGO_INTERNAL_IPS='localhost 127.0.0.1 [::1]' DJANGO_SETTINGS_MODULE=api.settings.development DB_ENGINE=django.db.backends.postgresql DB_DATABASE=hello_django_dev DB_USER=hello_django DB_PASSWORD=hello_django DB_HOST=db DB_PORT=5432 DB_NAME=postgres DATABASE=postgres NGINX_PORT=8888 REDIS_BACKEND=redis://redis:6379/0
-
Replace the values in the above example with your specific configuration.
-
-
Save the
.envFile:- Save the changes to the
.envfile.
- Save the changes to the
To create all the neccessary tables and migrations, run:
make db_updateTo populate the database with initial data, follow these steps:
-
Open your terminal or command prompt.
-
Navigate to the project directory where your Django app is located.
-
Run the following command to access the Django management script:
make shellIn the Django management shell, type the following command to import the required tools:
from app.common.populate import populate_async, populate_threads, SettingsNow, you can use either populate_async() or populate_threads() function to populate your database with initial data (no configuration required):
populate_async()
# or
populate_threads()You can also fine-tune the process with custom settings:
settings = Settings(
categories_count=10,
products_per_category_count=10,
customers_count=10,
carts_per_customer_count=10,
cart_items_per_cart_count=10,
)Run populate_threads:
populate_threads(settings, threads_count=4)Or run populate_async:
populate_async(settings, tasks_count=4)Note:
You can use both the
populate_threadsandpopulate_asyncfunctions interchangeably. However, it is recommended to usepopulate_asyncfor small amounts of data andpopulate_threadsfor more substantial batch processing, capable of handling up to millions of items efficiently.
To run development server run:
make runNow you can check your localhost:8888
To run production server on the local machine:
- Install Docker Compose following the official guide.
- Build and run all containers locally:
make compose-upNow you can check your localhost:8000
Describe how to use your app here.
Formatting To format the source code, run:
make formatTo lint the source code, run:
make lintTo run the development Django server, use:
make runTo run the development Django server with Docker Compose, use:
make compose-upTo stop the development Django server with Docker Compose, use:
make compose-downTo run unit tests, use:
make tests-unitsTo run integration tests, use:
make tests-integrationsTo run all available tests, use:
make testThis project is licensed under the GNU GPLv3 License - see the LICENSE file for details.