- FastAPI backend with SQLAlchemy ORM and SQLite - AI chatbot with OpenAI-compatible LLM integration (SSE streaming) - Admin panel for content management, LLM config, token management - Anonymous access with 3-question limit, token-based access control - Recruiter intent detection with admin notification - Resume generator (JD-based, Markdown to Word export) - Chinese localized public interface Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
import os
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from app.config import settings
|
|
from app.database import init_db, SessionLocal
|
|
from app.models import AdminUser, Profile
|
|
from app.routers import auth, public, admin, chat
|
|
from app.routers.auth import hash_password
|
|
|
|
app = FastAPI(title="CareerBot", description="Personal Career Showcase with AI Assistant")
|
|
|
|
# Mount static files and uploads
|
|
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
|
os.makedirs(settings.UPLOAD_DIR, exist_ok=True)
|
|
app.mount("/uploads", StaticFiles(directory=settings.UPLOAD_DIR), name="uploads")
|
|
|
|
# Include routers
|
|
app.include_router(auth.router)
|
|
app.include_router(public.router)
|
|
app.include_router(admin.router)
|
|
app.include_router(chat.router)
|
|
|
|
|
|
@app.on_event("startup")
|
|
def startup():
|
|
init_db()
|
|
db = SessionLocal()
|
|
try:
|
|
# Ensure admin user exists
|
|
admin_user = db.query(AdminUser).filter(AdminUser.email == "ln0422@gmail.com").first()
|
|
if not admin_user:
|
|
admin_user = AdminUser(
|
|
email="ln0422@gmail.com",
|
|
password_hash=hash_password("qshs123456"),
|
|
)
|
|
db.add(admin_user)
|
|
db.commit()
|
|
|
|
# Ensure profile exists
|
|
profile = db.query(Profile).first()
|
|
if not profile:
|
|
db.add(Profile())
|
|
db.commit()
|
|
finally:
|
|
db.close()
|