Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
chore: make hosts configurable and enrich project documentation #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
chore: make hosts configurable and enrich project documentation #65
Changes from all commits
09e4e4d
18b3952
257fd38
7653bde
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Promo-CodePromo Code APIThe application provides an HTTP API for companies and end-users, is integrated with an external anti-fraud service, and uses PostgreSQL and Redis for data storage and caching.
📜 Table of Contents
📝 About the Application
This document outlines the functionality of the Promo Code API, a comprehensive platform designed to connect businesses with end-users through promotional offers. The application is logically divided into two primary sections: a Business-to-Business (B2B) interface for companies to manage their campaigns and a Business-to-Consumer (B2C) interface for users to discover, interact with, and activate promotions.
✨ Key Features
This platform provides a comprehensive solution for managing promotional campaigns, with a clear separation between B2B and B2C interfaces.
👤 Dual Account System: Supports separate registration and authentication for Companies (B2B) and Users (B2C). The same email can be used for both a company and a user account.
🔐 Secure Authentication & Authorization:
Authorization: Bearer {token}
).📈 Advanced B2B Promo Management:
COMMON
: A single, reusable code (e.g.,SUMMER-SALE-20
) with a configurable usage limit.UNIQUE
: A list of unique, single-use codes for tracking specific campaigns./stat
) provides detailed activation statistics for each promo, broken down by country.🛍️ Rich B2C User Experience:
🛡️ Core System & Reliability:
GET /api/ping
endpoint to verify service availability.🛠️ Tech Stack
📋 Prerequisites
🚀 Installation and Setup
The application and all its dependencies are launched using Docker Compose and configured via environment variables.
Clone the repository:
git clone https://github.com/RandomProgramm3r/Promo-Code-API.git cd Promo-Code-API
Create and configure the
.env
file: Copy the.env.example
file to.env
. Thedocker-compose.yml
is configured to use these variables for all services.Run the application: Execute the following command in the project's root directory to build the images and run the containers in the background:
Apply database migrations:
After a successful launch, the main service will be available on the host machine at
http://localhost:8000
.⚙️ Environment Variables
All project configuration is managed through an
.env
file.DJANGO_SECRET_KEY
: A secret key for a particular Django installation.DJANGO_DEBUG
: Toggles Django's debug mode (True
/False
).DJANGO_ALLOWED_HOSTS
: A list of strings representing the host/domain names that this Django site can serve.POSTGRES_USERNAME
: Username for PostgreSQL connection.POSTGRES_PASSWORD
: Password for PostgreSQL connection.POSTGRES_HOST
: Host for PostgreSQL connection (e.g.,db
).POSTGRES_PORT
: Port for PostgreSQL connection (e.g.,5432
).POSTGRES_DATABASE
: The name of the database to use.REDIS_HOST
: Host for Redis connection (e.g.,redis
).REDIS_PORT
: Port for Redis connection (e.g.,6379
).ANTIFRAUD_ADDRESS
: The address (domain or IP) and port of the anti-fraud service API (e.g.,http://antifraud:9090
).📄 API Specification
The application's REST API is implemented strictly according to the provided OpenAPI specification file,
api.yml
.🧭 API Endpoint Examples
Health Check
/api/ping
B2B (Company) Endpoints
Authentication
/api/business/auth/sign-up
/api/business/auth/sign-in
Promo Management
/api/business/promo
/api/business/promo
/api/business/promo/{id}
/api/business/promo/{id}
target
structure, are replaced)./api/business/promo/{id}/stat
B2C (User) Endpoints
Authentication & Profile
/api/user/auth/sign-up
/api/user/auth/sign-in
/api/user/profile
/api/user/profile
Promo Feed & Details
/api/user/feed
/api/user/promo/{id}
Activation, History, Likes & Comments
/api/user/promo/{id}/activate
/api/user/promo/history
/api/user/promo/{id}/like
/api/user/promo/{id}/like
/api/user/promo/{id}/comments
/api/user/promo/{id}/comments
/api/user/promo/{id}/comments/{comment_id}
/api/user/promo/{id}/comments/{comment_id}
/api/user/promo/{id}/comments/{comment_id}
🧪 Testing
To run the tests, launch the application and run the following command from the project's root directory. The command will run the tests inside the container of the running application (
web
).Uh oh!
There was an error while loading. Please reload this page.