diff --git a/api/.gitignore b/api/.gitignore new file mode 100644 index 0000000..5b97d50 --- /dev/null +++ b/api/.gitignore @@ -0,0 +1 @@ +configs_repo/ diff --git a/api/config_analyzer.py b/api/config_analyzer.py index d326ca5..dd186a9 100644 --- a/api/config_analyzer.py +++ b/api/config_analyzer.py @@ -76,8 +76,8 @@ class ConfigAnalyzer: """ configs = [] - # Find all JSON files in configs directory - for config_file in sorted(self.config_dir.glob("*.json")): + # Find all JSON files recursively in configs directory and subdirectories + for config_file in sorted(self.config_dir.rglob("*.json")): try: metadata = self.analyze_config(config_file) if metadata: # Skip invalid configs diff --git a/api/main.py b/api/main.py index befd374..27b8383 100644 --- a/api/main.py +++ b/api/main.py @@ -31,7 +31,11 @@ app.add_middleware( ) # Initialize config analyzer -CONFIG_DIR = Path(__file__).parent.parent / "configs" +# Try configs_repo first (production), fallback to configs (local development) +CONFIG_DIR = Path(__file__).parent / "configs_repo" / "official" +if not CONFIG_DIR.exists(): + CONFIG_DIR = Path(__file__).parent.parent / "configs" + analyzer = ConfigAnalyzer(CONFIG_DIR) @@ -45,9 +49,11 @@ async def root(): "/api/configs": "List all available configs", "/api/configs/{name}": "Get specific config details", "/api/categories": "List all categories", + "/api/download/{name}": "Download config file", "/docs": "API documentation", }, "repository": "https://github.com/yusufkaraaslan/Skill_Seekers", + "configs_repository": "https://github.com/yusufkaraaslan/skill-seekers-configs", "website": "https://api.skillseekersweb.com" } @@ -178,9 +184,13 @@ async def download_config(config_name: str): if not config_name.endswith(".json"): config_name = f"{config_name}.json" - config_path = CONFIG_DIR / config_name + # Search recursively in all subdirectories + config_path = None + for found_path in CONFIG_DIR.rglob(config_name): + config_path = found_path + break - if not config_path.exists(): + if not config_path or not config_path.exists(): raise HTTPException( status_code=404, detail=f"Config file '{config_name}' not found" diff --git a/render.yaml b/render.yaml index 7138199..2c7b751 100644 --- a/render.yaml +++ b/render.yaml @@ -4,7 +4,9 @@ services: name: skill-seekers-api runtime: python plan: free - buildCommand: pip install -r api/requirements.txt + buildCommand: | + pip install -r api/requirements.txt && + git clone https://github.com/yusufkaraaslan/skill-seekers-configs.git api/configs_repo startCommand: cd api && uvicorn main:app --host 0.0.0.0 --port $PORT envVars: - key: PYTHON_VERSION