Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ docker-compose.override.yml
# Supabase
.env.supabase.local
kong.yml

.DS_Store
8 changes: 8 additions & 0 deletions archive/backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__pycache__
*.pyc
.env
.pytest_cache
.mypy_cache
.coverage
venv/
.venv/
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions archive/backend/app/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from fastapi import APIRouter, Depends
from supabase._async.client import AsyncClient

from app.core.supabase import get_async_supabase
from app.routes.classification_routes import router as classification_router
from app.routes.migration_routes import router as migration_router
from app.routes.pattern_recognition_routes import router as pattern_recognition_router
from app.routes.preprocess_routes import router as preprocess_router
from app.routes.search_routes import router as search_router

api_router = APIRouter(prefix="/api")


@api_router.get("/health")
async def health_check(supabase: AsyncClient = Depends(get_async_supabase)):
try:
# Check raw_files table instead of tenants
await supabase.table("raw_files").select("count", count="exact").execute()
return {"status": "healthy", "database": "connected"}
except Exception as e:
return {"status": "unhealthy", "database": "disconnected", "error": str(e)}


api_router.include_router(preprocess_router)
api_router.include_router(search_router)
api_router.include_router(classification_router)
api_router.include_router(migration_router)
api_router.include_router(pattern_recognition_router)
File renamed without changes.
30 changes: 30 additions & 0 deletions archive/backend/app/core/neo4j.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# app/core/neo4j.py
import os
from app.repositories.graph_repository import GraphRepository

_graph_repo: GraphRepository


def get_graph_repo() -> GraphRepository | None:
"""
Returns a shared GraphRepository singleton.
Connection is created once on first call, reused after that.
Returns None if Neo4j is not configured or unreachable.
"""
global _graph_repo

if _graph_repo is not None:
return _graph_repo

try:
uri = os.getenv("NEO4J_URI", "bolt://localhost:7687")
user = os.getenv("NEO4J_USER", "neo4j")
password = os.getenv("NEO4J_PASSWORD", "password")
database = os.getenv("NEO4J_DATABASE", None)

_graph_repo = GraphRepository(uri, user, password, database)
print("Neo4j connection established", flush=True)
return _graph_repo
except Exception as e:
print(f"Neo4j not available: {e}", flush=True)
return None
File renamed without changes.
File renamed without changes.
62 changes: 62 additions & 0 deletions archive/backend/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import os
from contextlib import asynccontextmanager

from dotenv import load_dotenv
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

# Load env vars from .env file (looks in current or parent directories)
load_dotenv() # noqa: E402

# Fix for local dev: Map VITE_SUPABASE_URL to SUPABASE_URL if not set
if not os.getenv("SUPABASE_URL") and os.getenv("VITE_SUPABASE_URL"):
os.environ["SUPABASE_URL"] = os.getenv("VITE_SUPABASE_URL")

# Fix for local dev: Map SUPABASE_SERVICE_ROLE_KEY if differently named
if not os.getenv("SUPABASE_SERVICE_ROLE_KEY") and os.getenv(
"BACKEND_SUPABASE_SERVICE_ROLE_KEY"
):
os.environ["SUPABASE_SERVICE_ROLE_KEY"] = os.getenv(
"BACKEND_SUPABASE_SERVICE_ROLE_KEY"
)


from app.api import api_router # noqa: E402
from app.core.supabase import get_async_supabase # noqa: E402
from app.core.webhooks import configure_webhooks # noqa: E402
from app.services.extraction.preprocessing_queue import init_queue # noqa: E402
from app.services.supabase_check import wait_for_supabase # noqa: E402


@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup
print("LIFESPAN STARTING", flush=True)
supabase = await get_async_supabase()

await wait_for_supabase(supabase)

await configure_webhooks(supabase)

await init_queue(supabase)

yield
# Shutdown (if needed)


app = FastAPI(title="Cortex ETL API", lifespan=lifespan)

app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=False,
allow_methods=["*"],
allow_headers=["*"],
)

app.include_router(api_router)


@app.get("/")
def read_root():
return {"message": "Cortex ETL Backend"}
Empty file.
4 changes: 4 additions & 0 deletions archive/backend/example.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DATABASE_URL=postgresql://postgres:password@localhost:5432/cortex
SECRET_KEY=your-secret-key-change-this-in-production
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
28 changes: 28 additions & 0 deletions archive/backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[tool.ruff]
line-length = 88
target-version = "py312"

[tool.ruff.lint]
select = [
"E",
"W",
"F",
"I",
"B",
"C4",
"UP",
]
ignore = [
"E501",
"B008",
"UP007"
]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[tool.pytest.ini_options]
pythonpath = ["."]
File renamed without changes.
41 changes: 41 additions & 0 deletions archive/backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Web Framework & Server
fastapi==0.119.0
uvicorn[standard]==0.37.0

# Supabase Client
supabase>=2.7.0
gotrue>=2.5.0

# Configuration
python-dotenv==1.0.1

# Data Validation
pydantic[email]>=2.0.0

# Code Quality
ruff==0.8.4

# LLM Integration
litellm>=1.52.0
openai>=1.0.0

# Data Analysis
umap-learn==0.5.7
scikit-learn==1.5.2
numpy==2.1.3
sentence-transformers==3.3.1

# Classification
hdbscan>=0.8.33

# docling==2.55.1
# docling-core==2.48.4
# docling-ibm-models==3.9.1
# docling-parse==4.5.0
# pdfplumber==0.11.7
# google-ai-generativelanguage==0.6.15
# google-api-core==2.25.2
# google-api-python-client==2.184.0
# google-auth==2.41.1
# google-auth-httplib2==0.2.0
# google-generativeai==0.8.5
8 changes: 8 additions & 0 deletions archive/backend/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
max-line-length = 88
extend-ignore = E203, W503
exclude = .git,__pycache__,alembic

[mypy]
python_version = 3.11
ignore_missing_imports = True
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"scripts": {
"init-dev": "npm install && node init-dev.js",
"build": "docker-compose build --no-cache",
"up": "npm run init-dev && docker-compose up -d",
"down": "npx supabase stop && docker-compose down",
"rebuild": "docker-compose down -v && npm run build && npm run up",
"reset": "npx supabase db reset && npm run types:generate && docker-compose restart backend",
"hard-clean": "npx supabase stop --no-backup && docker-compose down -v && docker container prune -f && docker network prune -f",
"build": "docker compose build --no-cache",
"up": "npm run init-dev && docker compose up -d",
"down": "npx supabase stop && docker compose down",
"rebuild": "docker compose down -v && npm run build && npm run up",
"reset": "npx supabase db reset && npm run types:generate && docker compose restart backend",
"hard-clean": "npx supabase stop --no-backup && docker compose down -v && docker container prune -f && docker network prune -f",
"fresh": "npm run hard-clean && npm run build && npm run up && npm run types:generate",
"types:generate": "npm run types:frontend",
"types:frontend": "npx supabase gen types typescript --local > frontend/src/types/database.types.ts"
Expand Down
Loading