chore: standardize configuration, logging, and error handling across blockchain node and coordinator API

- Add infrastructure.md and workflow files to .gitignore to prevent sensitive info leaks
- Change blockchain node mempool backend default from memory to database for persistence
- Refactor blockchain node logger with StructuredLogFormatter and AuditLogger (consistent with coordinator)
- Add structured logging fields: service, module, function, line number
- Unify coordinator config with Database
This commit is contained in:
oib
2026-02-13 22:39:43 +01:00
parent 0cbd2b507c
commit 06e48ef34b
196 changed files with 4660 additions and 20090 deletions

99
scripts/generate_openapi.py Executable file
View File

@@ -0,0 +1,99 @@
#!/usr/bin/env python3
"""
Generate OpenAPI specifications from FastAPI services
"""
import json
import sys
import subprocess
import requests
from pathlib import Path
def extract_openapi_spec(service_name: str, base_url: str, output_file: str):
"""Extract OpenAPI spec from a running FastAPI service"""
try:
# Get OpenAPI spec from the service
response = requests.get(f"{base_url}/openapi.json")
response.raise_for_status()
spec = response.json()
# Add service-specific metadata
spec["info"]["title"] = f"AITBC {service_name} API"
spec["info"]["description"] = f"OpenAPI specification for AITBC {service_name} service"
spec["info"]["version"] = "1.0.0"
# Add servers configuration
spec["servers"] = [
{
"url": "https://aitbc.bubuit.net/api",
"description": "Production server"
},
{
"url": "https://staging-api.aitbc.io",
"description": "Staging server"
},
{
"url": "http://localhost:8011",
"description": "Development server"
}
]
# Save the spec
output_path = Path(output_file)
output_path.parent.mkdir(parents=True, exist_ok=True)
with open(output_path, 'w') as f:
json.dump(spec, f, indent=2)
print(f"✓ Generated {service_name} OpenAPI spec: {output_file}")
return True
except Exception as e:
print(f"✗ Failed to generate {service_name} spec: {e}")
return False
def main():
"""Generate OpenAPI specs for all AITBC services"""
services = [
{
"name": "Coordinator API",
"base_url": "http://127.0.0.2:8011",
"output": "api/coordinator/openapi.json"
},
{
"name": "Blockchain Node API",
"base_url": "http://127.0.0.2:8080",
"output": "api/blockchain/openapi.json"
},
{
"name": "Wallet Daemon API",
"base_url": "http://127.0.0.2:8071",
"output": "api/wallet/openapi.json"
}
]
print("Generating OpenAPI specifications...")
all_success = True
for service in services:
success = extract_openapi_spec(
service["name"],
service["base_url"],
service["output"]
)
if not success:
all_success = False
if all_success:
print("\n✓ All OpenAPI specifications generated successfully!")
print("\nNext steps:")
print("1. Review the generated specs")
print("2. Commit them to the documentation repository")
print("3. Update the API reference documentation")
else:
print("\n✗ Some specifications failed to generate")
sys.exit(1)
if __name__ == "__main__":
main()