feat: backend project setup with FastAPI structure and dependencies
- Create directory structure per IMPLEMENTATION_PLAN.md Section 12 - Add requirements.txt with FastAPI, SQLAlchemy, CrewAI, etc. - Add core/config.py for environment variable configuration - Add core/database.py for SQLite connection - Add core/security.py for password hashing and JWT - Add FastAPI app entry point (main.py) with all API routers - Add Uvicorn runner (run.py) - Add API route stubs (auth, bots, backtest, simulate, config) - Add db/models.py with SQLAlchemy models - Add db/schemas.py with Pydantic schemas - Add service stubs (ai_agent, backtest, simulate engines) - Add .env.example with all required environment variables - Verify server starts correctly
This commit is contained in:
52
src/backend/app/api/auth.py
Normal file
52
src/backend/app/api/auth.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
|
||||
from sqlalchemy.orm import Session
|
||||
from datetime import timedelta
|
||||
from typing import Annotated
|
||||
|
||||
from ..core.database import get_db
|
||||
from ..core.security import (
|
||||
get_password_hash,
|
||||
verify_password,
|
||||
create_access_token,
|
||||
verify_token,
|
||||
)
|
||||
from ..core.config import get_settings
|
||||
from ..db.schemas import UserCreate, UserResponse, Token
|
||||
|
||||
router = APIRouter()
|
||||
settings = get_settings()
|
||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/api/auth/token")
|
||||
|
||||
|
||||
@router.post("/register", response_model=UserResponse)
|
||||
def register(user: UserCreate, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.post("/login")
|
||||
def login(
|
||||
form_data: Annotated[OAuth2PasswordRequestForm, Depends()],
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.post("/logout")
|
||||
def logout(token: Annotated[str, Depends(oauth2_scheme)]):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/me", response_model=UserResponse)
|
||||
def get_me(
|
||||
token: Annotated[str, Depends(oauth2_scheme)], db: Session = Depends(get_db)
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
Reference in New Issue
Block a user