Phase 0 Complete by ClaudeCode

This commit is contained in:
2026-02-16 20:21:20 +02:00
parent 30bcd2f9cd
commit 19c069949d
73 changed files with 3950 additions and 2 deletions
+10
View File
@@ -0,0 +1,10 @@
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
View File
+1
View File
@@ -0,0 +1 @@
# TODO: JWT verification, role checks
+1
View File
@@ -0,0 +1 @@
# TODO: User/token Pydantic schemas
+1
View File
@@ -0,0 +1 @@
# TODO: Login / token endpoints
+1
View File
@@ -0,0 +1 @@
# TODO: Password hashing, token creation
+33
View File
@@ -0,0 +1,33 @@
from pydantic_settings import BaseSettings
from typing import List
import json
class Settings(BaseSettings):
# Firebase
firebase_service_account_path: str = "./firebase-service-account.json"
# JWT
jwt_secret_key: str = "change-me-in-production"
jwt_algorithm: str = "HS256"
jwt_expiration_minutes: int = 480
# MQTT
mqtt_broker_host: str = "localhost"
mqtt_broker_port: int = 1883
mqtt_admin_username: str = "admin"
mqtt_admin_password: str = ""
mosquitto_password_file: str = "/etc/mosquitto/passwd"
# App
backend_cors_origins: str = '["http://localhost:5173"]'
debug: bool = True
@property
def cors_origins(self) -> List[str]:
return json.loads(self.backend_cors_origins)
model_config = {"env_file": ".env", "extra": "ignore"}
settings = Settings()
View File
+1
View File
@@ -0,0 +1 @@
# TODO: Device Pydantic schemas
+1
View File
@@ -0,0 +1 @@
# TODO: CRUD endpoints for devices
+1
View File
@@ -0,0 +1 @@
# TODO: Device Firestore operations
View File
+1
View File
@@ -0,0 +1 @@
# TODO: Equipment Pydantic schemas
+1
View File
@@ -0,0 +1 @@
# TODO: Complementary devices / notes endpoints
+1
View File
@@ -0,0 +1 @@
# TODO: Equipment Firestore operations
+29
View File
@@ -0,0 +1,29 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from config import settings
from shared.firebase import init_firebase, firebase_initialized
app = FastAPI(
title="BellSystems Admin Panel",
version="0.1.0",
docs_url="/api/docs",
openapi_url="/api/openapi.json",
)
app.add_middleware(
CORSMiddleware,
allow_origins=settings.cors_origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.on_event("startup")
async def startup():
init_firebase()
@app.get("/api/health")
async def health_check():
return {"status": "ok", "firebase": firebase_initialized}
View File
+1
View File
@@ -0,0 +1 @@
# TODO: Melody Pydantic schemas
+1
View File
@@ -0,0 +1 @@
# TODO: CRUD endpoints for melodies
+1
View File
@@ -0,0 +1 @@
# TODO: Melody Firestore operations
View File
+1
View File
@@ -0,0 +1 @@
# TODO: MQTT client wrapper (paho-mqtt)
+1
View File
@@ -0,0 +1 @@
# TODO: Log storage and retrieval
+1
View File
@@ -0,0 +1 @@
# TODO: Mosquitto password file management
+1
View File
@@ -0,0 +1 @@
# TODO: Command endpoints + WebSocket for live data
+9
View File
@@ -0,0 +1,9 @@
fastapi==0.115.6
uvicorn[standard]==0.34.0
pydantic-settings==2.7.1
python-dotenv==1.0.1
firebase-admin==6.6.0
paho-mqtt==2.1.0
python-jose[cryptography]==3.3.0
passlib[bcrypt]==1.7.4
python-multipart==0.0.20
View File
+1
View File
@@ -0,0 +1 @@
# TODO: Custom error handlers
+24
View File
@@ -0,0 +1,24 @@
import firebase_admin
from firebase_admin import credentials, firestore
from config import settings
db = None
firebase_initialized = False
def init_firebase():
"""Initialize Firebase Admin SDK. Call once at app startup."""
global db, firebase_initialized
try:
cred = credentials.Certificate(settings.firebase_service_account_path)
firebase_admin.initialize_app(cred)
db = firestore.client()
firebase_initialized = True
except Exception as e:
print(f"[WARNING] Firebase init failed: {e}")
firebase_initialized = False
def get_db():
"""Return the Firestore client. None if Firebase is not initialized."""
return db
View File
+1
View File
@@ -0,0 +1 @@
# TODO: User Pydantic schemas
+1
View File
@@ -0,0 +1 @@
# TODO: CRUD endpoints for users
+1
View File
@@ -0,0 +1 @@
# TODO: User Firestore operations