This commit introduces the foundational elements for the new "Company Explorer" web application, marking a significant step away from the legacy Google Sheets / CLI system. Key changes include: - Project Structure: A new directory with separate (FastAPI) and (React/Vite) components. - Data Persistence: Migration from Google Sheets to a local SQLite database () using SQLAlchemy. - Core Utilities: Extraction and cleanup of essential helper functions (LLM wrappers, text utilities) into . - Backend Services: , , for AI-powered analysis, and logic. - Frontend UI: Basic React application with company table, import wizard, and dynamic inspector sidebar. - Docker Integration: Updated and for multi-stage builds and sideloading. - Deployment & Access: Integrated into central Nginx proxy and dashboard, accessible via . Lessons Learned & Fixed during development: - Frontend Asset Loading: Addressed issues with Vite's path and FastAPI's . - TypeScript Configuration: Added and . - Database Schema Evolution: Solved errors by forcing a new database file and correcting override. - Logging: Implemented robust file-based logging (). This new foundation provides a powerful and maintainable platform for future B2B robotics lead generation.
63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
import os
|
|
import logging
|
|
from typing import Optional
|
|
|
|
# Versuche Pydantic zu nutzen, Fallback auf os.environ
|
|
try:
|
|
from pydantic_settings import BaseSettings
|
|
|
|
class Settings(BaseSettings):
|
|
# App Info
|
|
APP_NAME: str = "Company Explorer"
|
|
VERSION: str = "0.2.2"
|
|
DEBUG: bool = True
|
|
|
|
# Database (Store in App dir for simplicity)
|
|
DATABASE_URL: str = "sqlite:////app/companies_v3_final.db"
|
|
|
|
# API Keys
|
|
GEMINI_API_KEY: Optional[str] = None
|
|
OPENAI_API_KEY: Optional[str] = None
|
|
SERP_API_KEY: Optional[str] = None
|
|
|
|
# Paths
|
|
LOG_DIR: str = "/app/logs_debug"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
|
|
settings = Settings()
|
|
|
|
except ImportError:
|
|
# Fallback wenn pydantic-settings nicht installiert ist
|
|
class Settings:
|
|
APP_NAME = "Company Explorer"
|
|
VERSION = "0.2.1"
|
|
DEBUG = True
|
|
DATABASE_URL = "sqlite:////app/logs_debug/companies_debug.db"
|
|
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
|
|
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
|
SERP_API_KEY = os.getenv("SERP_API_KEY")
|
|
LOG_DIR = "/app/logs_debug"
|
|
|
|
settings = Settings()
|
|
|
|
# Ensure Log Dir
|
|
os.makedirs(settings.LOG_DIR, exist_ok=True)
|
|
|
|
# API Key Loading Helper (from file if env missing)
|
|
def load_api_key_from_file(filename: str) -> Optional[str]:
|
|
try:
|
|
if os.path.exists(filename):
|
|
with open(filename, 'r') as f:
|
|
return f.read().strip()
|
|
except Exception as e:
|
|
print(f"Could not load key from {filename}: {e}") # Print because logging might not be ready
|
|
return None
|
|
|
|
# Auto-load keys if not in env
|
|
if not settings.GEMINI_API_KEY:
|
|
settings.GEMINI_API_KEY = load_api_key_from_file("/app/gemini_api_key.txt")
|
|
|
|
if not settings.SERP_API_KEY:
|
|
settings.SERP_API_KEY = load_api_key_from_file("/app/serpapikey.txt") |