Initial project structure: MarketScanner - Fear-to-Fortune Trading Intelligence

Features:
- FastAPI backend with stocks, news, signals, watchlist, analytics endpoints
- React frontend with TailwindCSS dark mode trading dashboard
- Celery workers for news fetching, sentiment analysis, pattern detection
- TimescaleDB schema for time-series stock data
- Docker Compose setup for all services
- OpenAI integration for sentiment analysis
This commit is contained in:
mindesbunister
2026-01-08 14:15:51 +01:00
commit 074787f067
58 changed files with 4864 additions and 0 deletions

114
backend/app/main.py Normal file
View File

@@ -0,0 +1,114 @@
"""
MarketScanner - Fear-to-Fortune Trading Intelligence
Main FastAPI Application
"""
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
import structlog
from app.core.config import settings
from app.core.database import init_db
from app.api import router as api_router
# Configure structured logging
structlog.configure(
processors=[
structlog.stdlib.filter_by_level,
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.JSONRenderer()
],
wrapper_class=structlog.stdlib.BoundLogger,
context_class=dict,
logger_factory=structlog.stdlib.LoggerFactory(),
)
logger = structlog.get_logger()
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Application lifespan events."""
# Startup
logger.info("Starting MarketScanner API", version=settings.VERSION)
await init_db()
logger.info("Database initialized")
yield
# Shutdown
logger.info("Shutting down MarketScanner API")
# Create FastAPI application
app = FastAPI(
title="MarketScanner API",
description="""
🚀 **MarketScanner** - Fear-to-Fortune Trading Intelligence
A system that identifies buying opportunities by analyzing how stocks
historically respond to panic-inducing news.
## Features
* **News Monitoring** - Real-time scanning of financial news
* **Sentiment Analysis** - NLP-powered sentiment scoring
* **Panic Detection** - Identify market fear events
* **Pattern Matching** - Historical recovery patterns
* **Buy Signals** - Confidence-scored opportunities
*"Buy when there's blood in the streets."* — Baron Rothschild
""",
version=settings.VERSION,
docs_url="/docs",
redoc_url="/redoc",
lifespan=lifespan,
)
# CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=settings.CORS_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include API routes
app.include_router(api_router, prefix="/api/v1")
@app.get("/", tags=["Root"])
async def root():
"""Root endpoint with API info."""
return {
"name": "MarketScanner API",
"version": settings.VERSION,
"description": "Fear-to-Fortune Trading Intelligence",
"docs": "/docs",
"health": "/health",
}
@app.get("/health", tags=["Health"])
async def health_check():
"""Health check endpoint for Docker/Kubernetes."""
return JSONResponse(
status_code=200,
content={
"status": "healthy",
"version": settings.VERSION,
}
)
if __name__ == "__main__":
import uvicorn
uvicorn.run(
"app.main:app",
host=settings.BACKEND_HOST,
port=settings.BACKEND_PORT,
reload=settings.DEBUG,
)