feat: initialize full-stack architecture with backend routes, database schema, and glassmorphic frontend UI

This commit is contained in:
2026-05-13 00:12:19 +03:00
parent bd73f18d5c
commit 0732acbda5
21 changed files with 1937 additions and 307 deletions

View File

@@ -2,30 +2,75 @@ import os
from flask import Flask
from flask_cors import CORS
from dotenv import load_dotenv
from flasgger import Swagger
from flask_socketio import SocketIO, emit
# Load environment variables from .env
load_dotenv()
app = Flask(__name__)
CORS(app)
socketio = SocketIO(app, cors_allowed_origins="*")
# Swagger setup
# ... (keeping existing swagger config)
app.config['SWAGGER'] = {
'title': 'AutoMarket API',
'uiversion': 3,
'specs_route': '/api/docs/',
'securityDefinitions': {
'APIKeyHeader': {
'type': 'apiKey',
'name': 'Authorization',
'in': 'header',
'description': 'Введите токен в формате: Bearer <ваш_токен>'
}
}
}
swagger = Swagger(app)
# Ensure upload folder exists
# ...
UPLOAD_FOLDER = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'uploads')
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
# Register blueprints (routes)
# Register blueprints
from .routes.cases import cases_blueprint
from .routes.credentials import credentials_blueprint
from .routes.auth import auth_blueprint
from .routes.dashboard import dashboard_blueprint
from .routes.reports import reports_blueprint
from .routes.ai import ai_blueprint
from .routes.seo import seo_blueprint
from .routes.content import content_blueprint
from .routes.finance import finance_blueprint
app.register_blueprint(cases_blueprint, url_prefix='/api')
app.register_blueprint(credentials_blueprint, url_prefix='/api')
app.register_blueprint(auth_blueprint, url_prefix='/api')
app.register_blueprint(dashboard_blueprint, url_prefix='/api')
app.register_blueprint(reports_blueprint, url_prefix='/api')
app.register_blueprint(ai_blueprint, url_prefix='/api')
app.register_blueprint(seo_blueprint, url_prefix='/api')
app.register_blueprint(content_blueprint, url_prefix='/api')
app.register_blueprint(finance_blueprint, url_prefix='/api')
import threading
import time
def background_scanner():
"""Фоновая задача для имитации сканирования маркетплейсов."""
while True:
# Здесь в будущем будет вызов api.ozon_api и т.д.
print("--- [Scanner] Checking marketplaces for price dumping... ---")
# Эмитируем событие для примера (что сканер что-то нашел)
# socketio.emit('scanner_update', {'message': 'Сканер проверил 10 товаров...'}, namespace='/')
time.sleep(60)
# Start background thread
scanner_thread = threading.Thread(target=background_scanner, daemon=True)
scanner_thread.start()
if __name__ == '__main__':
# Use host 0.0.0.0 for Docker compatibility, port 5000
app.run(host='0.0.0.0', port=5000, debug=True)
# Use socketio.run instead of app.run
socketio.run(app, host='0.0.0.0', port=5000, debug=True, allow_unsafe_werkzeug=True)