FINAL: WebSocket + DMs + Files - Backend Complete!
WebSocket Real-Time: - Socket.IO server integrated - Real-time message delivery - User online/offline status - Typing indicators - Channel room management - Auto-join on channel access Direct Messages: - 1-on-1 chat API - DM history and conversations - @grimlock in DMs (AI responds) - Read receipts - Unread count tracking - WebSocket notifications File Management: - Upload files to channels - Download with streaming - File metadata tracking - File listing by channel - Delete with permissions Integration: - Messages broadcast via WebSocket - DM notifications via WebSocket - All APIs updated for real-time BACKEND IS FEATURE COMPLETE! - Auth ✅ - Channels ✅ - Messages ✅ - DMs ✅ - Files ✅ - WebSocket ✅ - @grimlock AI ✅ Ready for frontend development in next session!
This commit is contained in:
@@ -9,15 +9,19 @@ from contextlib import asynccontextmanager
|
||||
import logging
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
import socketio
|
||||
|
||||
from api.chat import router as chat_router
|
||||
from api.auth import router as auth_router
|
||||
from api.channels import router as channels_router
|
||||
from api.messages import router as messages_router
|
||||
from api.direct_messages import router as dm_router
|
||||
from api.files import router as files_router
|
||||
from core.context_manager import ContextManager
|
||||
from core.ai_client import AIClient
|
||||
from core.database import engine
|
||||
from core.models import Base
|
||||
from core.websocket import sio, broadcast_new_message
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
@@ -59,6 +63,8 @@ async def lifespan(app: FastAPI):
|
||||
ai_client = AIClient(api_key=api_key)
|
||||
logger.info("AI client initialized")
|
||||
|
||||
logger.info("WebSocket server ready")
|
||||
|
||||
yield
|
||||
|
||||
# Cleanup
|
||||
@@ -68,10 +74,13 @@ async def lifespan(app: FastAPI):
|
||||
app = FastAPI(
|
||||
title="Grimlock",
|
||||
description="AI-Native Company Operating System",
|
||||
version="0.2.0",
|
||||
version="0.3.0",
|
||||
lifespan=lifespan
|
||||
)
|
||||
|
||||
# Mount Socket.IO
|
||||
socket_app = socketio.ASGIApp(sio, app)
|
||||
|
||||
# CORS middleware
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
@@ -85,6 +94,8 @@ app.add_middleware(
|
||||
app.include_router(auth_router, prefix="/api/auth", tags=["auth"])
|
||||
app.include_router(channels_router, prefix="/api/channels", tags=["channels"])
|
||||
app.include_router(messages_router, prefix="/api/channels", tags=["messages"])
|
||||
app.include_router(dm_router, prefix="/api/dms", tags=["direct-messages"])
|
||||
app.include_router(files_router, prefix="/api/files", tags=["files"])
|
||||
app.include_router(chat_router, prefix="/api/chat", tags=["chat"])
|
||||
|
||||
@app.get("/")
|
||||
@@ -93,8 +104,8 @@ async def root():
|
||||
return {
|
||||
"status": "online",
|
||||
"service": "Grimlock",
|
||||
"version": "0.2.0",
|
||||
"features": ["auth", "channels", "messages", "ai"]
|
||||
"version": "0.3.0",
|
||||
"features": ["auth", "channels", "messages", "dms", "files", "websocket", "ai"]
|
||||
}
|
||||
|
||||
@app.get("/api/health")
|
||||
@@ -104,7 +115,8 @@ async def health():
|
||||
"status": "healthy",
|
||||
"context_loaded": context_manager is not None and context_manager.is_loaded(),
|
||||
"ai_client_ready": ai_client is not None,
|
||||
"database": "connected"
|
||||
"database": "connected",
|
||||
"websocket": "ready"
|
||||
}
|
||||
|
||||
def get_context_manager() -> ContextManager:
|
||||
|
||||
Reference in New Issue
Block a user