{"id":26630337,"url":"https://github.com/ivan-borovets/toml-config-manager","last_synced_at":"2026-05-14T23:41:51.083Z","repository":{"id":283292422,"uuid":"951284682","full_name":"ivan-borovets/toml-config-manager","owner":"ivan-borovets","description":"Python configuration system using TOML files as single source of truth across multiple environments. Provides TOML to .env conversion and direct config reading based on APP_ENV. Unifies application settings and infrastructure configuration. Works as simple drop-in solution with ready-to-use Makefile commands.","archived":false,"fork":false,"pushed_at":"2025-05-29T23:10:59.000Z","size":190,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-03T15:12:44.561Z","etag":null,"topics":["config","dev-tools","docker","dotenv","environment","makefile","python","secrets","toml","utilities"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivan-borovets.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-19T12:50:06.000Z","updated_at":"2025-05-29T23:11:02.000Z","dependencies_parsed_at":"2025-07-03T15:11:59.565Z","dependency_job_id":"0796effc-8847-4afa-a4f8-3ac08f3dc391","html_url":"https://github.com/ivan-borovets/toml-config-manager","commit_stats":null,"previous_names":["ivan-borovets/toml-to-dotenv","ivan-borovets/toml-config-manager"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ivan-borovets/toml-config-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivan-borovets%2Ftoml-config-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivan-borovets%2Ftoml-config-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivan-borovets%2Ftoml-config-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivan-borovets%2Ftoml-config-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivan-borovets","download_url":"https://codeload.github.com/ivan-borovets/toml-config-manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivan-borovets%2Ftoml-config-manager/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267552096,"owners_count":24106000,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","dev-tools","docker","dotenv","environment","makefile","python","secrets","toml","utilities"],"created_at":"2025-03-24T13:18:40.219Z","updated_at":"2026-05-14T23:41:51.078Z","avatar_url":"https://github.com/ivan-borovets.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://codecov.io/gh/ivan-borovets/toml-config-manager\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/ivan-borovets/toml-config-manager/graph/badge.svg\" alt=\"Codecov Coverage\"/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nConfiguration management system for Python projects that uses structured TOML files as the single source of truth, with\nsupport for multiple environments (local, development, production, custom).\n\nProvides both a conversion utility that transforms TOML to environment-specific .env files and a methodology for\napplications to read settings directly from the appropriate config directory based on APP_ENV value.\n\nTOML configuration files serve as single source of truth for both application settings and infrastructure configuration.\nBased on APP_ENV value, application reads settings directly from appropriate config directory, while .env files are\ngenerated for infrastructure tools like Docker Compose.\n\nDesigned as drop-in solution — just copy config directory to project root and use provided Makefile commands.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/1.tldr.svg\" alt=\"tldr\" /\u003e\n  \u003cbr\u003e\u003cem\u003eFigure 1: TL;DR\u003c/em\u003e\n\u003c/p\u003e\n\n# Prerequisites for usage\n\n* Python 3.12\n\n## Configuration Files\n\n- **config.toml**: Main application settings organized in sections\n- **export.toml**: Lists fields to export to .env (`export.fields = [\"postgres.USER\", \"postgres.PASSWORD\", ...]`)\n- **.secrets.toml**: Optional sensitive data (same format as config.toml, merged with main config)\n\nSee `examples/read_config.py` for usage examples.\n\n**Warning**: Despite the approach shown in `examples/read_config.py`, importing code from\n`config/toml_config_manager.py` is potentially dangerous.\nIf you need functionality from this file, copy the relevant code directly into your application instead of importing it.\n\n# Usage\n\n1. Add to `.gitignore`\n\n```gitignore\nconfig/dev/*\nconfig/prod/*\n.secrets.*\n.env.*\n```\n\n2. Copy to the root of your project\n\n* `config/`\n* `Makefile` snippets: `make env`, `make dotenv` (and dependencies) or entire `Makefile`\n\n3. [Configure](#configuration-files) local environment\n\n* Create `.secrets.toml` in `config/local` following `.secrets.toml.example`\n* Edit TOML files in `config/local` according to your project requirements\n* When using Docker Compose, remember to pass `APP_ENV` to your service:\n\n```yaml\nservices:\n  app:\n    # ...\n    environment:\n      APP_ENV: ${APP_ENV}\n```\n\n* `.env.local` will be generated later — **don't** create it manually\n\n\n4. [Configure](#configuration-files) dev/prod environment\n\n* Create similar structure in `config/dev` or `config/prod` with files:\n    * `config.toml`\n    * `.secrets.toml`\n    * `export.toml`\n    * `docker-compose.yaml` if needed\n* `.env.dev` or `.env.prod` will be generated later — **don't** create them manually\n\n\n5. Set environment variable\n\n```shell\nexport APP_ENV=local\n# export APP_ENV=dev\n# export APP_ENV=prod\n```\n\n6. Check it and generate `.env`\n\n```shell\nmake env  # should print APP_ENV=local\nmake dotenv  # should tell you where .env.local was generated\n```\n\n# Adding new environments\n\n1. Add new value to `ValidEnvs` enum in `config/toml_config_manager.py`\n2. Update `ENV_TO_DIR_PATHS` mapping in the same file\n3. Create corresponding directory in `config/` folder\n4. Add required [configuration files](#configuration-files)\n\nEnvironment directories can also contain other env-specific files like `docker-compose.yaml`, which will be used by\nMakefile commands.\n\n# Examples and tests\n\n1. Setup virtual environment\n\n```shell\n# sudo apt update\n# sudo apt install pipx\n# pipx ensurepath\n# pipx install uv\n# uv python install 3.12\nuv v\nsource .venv/bin/activate\n# .venv\\Scripts\\activate  # Windows\n# https://docs.astral.sh/uv/getting-started/installation/#shell-autocompletion\nuv pip install -e '.[dev,test]'\n```\n\n2. See the example how settings are read by the app from `.toml`\n\n```shell\n# locally\nexport APP_ENV=local\npython examples/read_config.py\n```\n\n```shell\n# or via Docker\ndocker rm myapp_test\ndocker build -t myapp:test -f examples/Dockerfile .\ndocker run -d --name myapp_test myapp:test\ndocker logs myapp_test\n```\n\n3. See the example how settings are read by the Docker Compose from `.env`\n\n```shell\nexport APP_ENV=local\nmake up.db-echo  # Ctrl + C to stop\nmake down\n```\n\n4. Run tests\n\n```shell\nmake code.cov.html\n```\n\n# Integration Example\n\nYou can see an example of this project in use\nat [fastapi-clean-example](https://github.com/ivan-borovets/fastapi-clean-example).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivan-borovets%2Ftoml-config-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivan-borovets%2Ftoml-config-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivan-borovets%2Ftoml-config-manager/lists"}