How wahyupr/cdn-integration-kong works
Project Type and Purpose
• The project is a lightweight backend service written in Python (using Flask) that integrates with a Kong API Gateway. It demonstrates how to automatically create services and routes in Kong (with a graphical management tool called Konga available at port 1337) and serves as a simple CDN integration tool.
• The primary purpose is to use a Flask backend (api_cdn.py) to interact with Kong (and thus enable API gateway configuration) in a containerized environment via Docker Compose.
Analyzing the File Structure
• Top-Level Files:
• README.md: Contains usage instructions and details about the integration.
• POSTGRES_PASSWORD: Likely used to supply environment settings to one of the Docker containers (possibly a database container if used by Kong or backend, though not explicitly mentioned).
• docker-compose.yml: Configures the container orchestration; this file will include container definitions for the backend and likely for Kong, Konga, and possibly a database service.
• Directory “backend”:
• Contains api_cdn.py: The main Flask application which is responsible for the CDN integration and for automatically creating services and routes within Kong.
• There is no separate “frontend” – the focus is on back-end service integration and gateway configuration.
Examining the README
• Installation instructions emphasize using Docker Compose to bring up the environment.
• It explains that the Flask-based backend (in the “backend” directory) should be started with Python 3.
• Users are instructed to register/login to Konga through a specific port (localhost:1337), suggesting that a containerized Konga (web admin UI for Kong) is part of the setup.
• There is a note about adjusting the upstream host (using host.docker.internal) which indicates that the backend service might connect and integrate with external services or a locally running server.
a. Main Components:
• Docker Environment: Represent the Docker container orchestration as the common hosting environment.
• Backend Service (Flask API/CND Integration): A container/service that runs api_cdn.py.
• Kong API Gateway: The main API gateway container that will receive configurations from the backend.
• Konga UI: The administrative interface (accessible via port 1337) to manage Kong.
• (Optional) Database/Configuration Store: Represent any supporting components (e.g., PostgreSQL) that may be indirectly referenced by the POSTGRES_PASSWORD file if the Docker Compose file provisions it.
b. Relationships and Interactions:
• The Docker Compose environment ensures that all these containers communicate over a defined network.
c. Architectural Patterns & Design Principles:
• Containerization: The system is designed around microservices/components running within Docker containers.
• API Gateway Integration: The pattern of using an API Gateway to centralize request routing is a key architectural decision.
• Loose Coupling: The backend service is built to interact with the external Kong API, which in turn is managed by Konga; each plays a distinct role.
• Use of external configuration (such as the upstream host in the backend code).
d. Relevant Technologies:
• Python with Flask for the backend.
• Docker and Docker Compose for container orchestration.
• Kong as the API gateway.
• Konga for the administrative UI.
• (Possibly) PostgreSQL if the POSTGRES_PASSWORD file is used by any container.