Dependency Management
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
Dependency management in the OdooConnectorAPI project is structured to support a multi-layered environment, ranging from local Python development to containerized microservices and Kubernetes orchestration. The project relies on specific Python libraries for its RESTful API functionality and Odoo communication, while using container technologies to manage external service dependencies like PostgreSQL and the Odoo ERP itself.
The management strategy ensures that the application environment remains consistent across development, testing, and production by defining requirements in standardized formats such as requirements.txt for Python packages, docker-compose.yml for service orchestration, and Helm charts for infrastructure as code.
Sources: README.md:1-15, requirements.txt:1-7
Python Dependencies
The core functionality of the API is built on a specific stack of Python libraries. These are managed via a requirements.txt file, which is used during local setup and Docker image builds.
Core Libraries
| Library | Purpose |
|---|---|
fastapi | High-performance web framework for building APIs. |
odoorpc | Python library to communicate with Odoo via RPC. |
uvicorn | ASGI server implementation to run the FastAPI application. |
python-dotenv | Loads environment variables from a .env file. |
Development and Testing Tools
| Library | Purpose |
|---|---|
flake8 | Tool for style guide enforcement (linting). |
pylint | Static code analysis tool. |
tox | Generic virtualenv management and test command line tool. |
Sources: requirements.txt:1-7, README.md:27-35
The diagram above illustrates how Python dependencies defined in the requirements file are integrated into the application runtime.
Sources: requirements.txt:1-7, app/main.py:1-6
Container and Service Orchestration
The project uses Docker Compose to manage dependencies between the API application and the Odoo ERP environment. This ensures that all necessary services are available and correctly configured to communicate with each other.
Service Relationships
The application is split into two primary Compose contexts:
- Application Environment: Manages the API service, which builds from the local source and relies on environment variables for Odoo connectivity.
- Odoo Environment: Manages the Odoo ERP instance (version 17) and its backend PostgreSQL database (version 13).
The flowchart shows the operational dependency where the API service connects to the Odoo stack using credentials and URLs defined in environment configurations.
Sources: docker-compose.yml:3-12, odoo/docker-compose.yml:3-56
Health and Resource Constraints
The Odoo environment includes specific dependency constraints to ensure stability:
- Resource Limits: Both Odoo and Postgres services are limited to 0.50 CPUs and 512M of memory.
- Healthchecks: The database must be ready (
pg_isready) before Odoo starts, and Odoo includes a healthcheck viacurlon port 8069.
Sources: odoo/docker-compose.yml:6-12, odoo/docker-compose.yml:40-46
Infrastructure Dependencies (Helm)
For Kubernetes deployments, dependencies are managed through Helm charts. The project defines a chart named odooconnectorapi (version 0.1.0) which abstracts the deployment, service, and environmental configuration.
Deployment Configuration
The Helm chart manages the following aspects:
- Image Management: Defines the repository, tag (default
latest), and pull policy for the API container. - Environment Injection: Maps Kubernetes values to environment variables like
ODOO_URLandODOO_DB. - Service Exposure: Configures a
ClusterIPservice to expose the API internally on port 80, mapping to container port 8000.
Sources: charts/odooconnectorapi/Chart.yaml:1-5, charts/odooconnectorapi/values.yaml:4-21, charts/odooconnectorapi/templates/service.yaml:6-12
Environment Variable Dependencies
The API relies heavily on specific environment variables to establish connections. Without these, the odoorpc client cannot initialize or authenticate.
# Configuration of odoorpc via environment variables
ODOO_URL = os.getenv('ODOO_URL', 'localhost')
ODOO_DB = os.getenv('ODOO_DB', 'mydb')
ODOO_USERNAME = os.getenv('ODOO_USERNAME', 'admin')
ODOO_PASSWORD = os.getenv('ODOO_PASSWORD', 'admin')
Sources: app/main.py:10-14
Summary
Dependency management in OdooConnectorAPI is a tiered system. Python-level dependencies ensure the application has the necessary libraries for execution and testing. Container-level dependencies (Docker) manage the lifecycle and interaction between the API and the Odoo/Postgres services. Finally, infrastructure-level dependencies (Helm) manage the deployment parameters for Kubernetes environments. This modular approach allows for flexible development while maintaining strict control over the production runtime.
Sources: README.md:1-20, charts/odooconnectorapi/values.yaml:14-21