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:
0
src/backend/app/api/__init__.py
Normal file
0
src/backend/app/api/__init__.py
Normal file
BIN
src/backend/app/api/__pycache__/__init__.cpython-314.pyc
Normal file
BIN
src/backend/app/api/__pycache__/__init__.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/backend/app/api/__pycache__/auth.cpython-314.pyc
Normal file
BIN
src/backend/app/api/__pycache__/auth.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/backend/app/api/__pycache__/backtest.cpython-314.pyc
Normal file
BIN
src/backend/app/api/__pycache__/backtest.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/backend/app/api/__pycache__/bots.cpython-314.pyc
Normal file
BIN
src/backend/app/api/__pycache__/bots.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/backend/app/api/__pycache__/config.cpython-314.pyc
Normal file
BIN
src/backend/app/api/__pycache__/config.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/backend/app/api/__pycache__/simulate.cpython-314.pyc
Normal file
BIN
src/backend/app/api/__pycache__/simulate.cpython-314.pyc
Normal file
Binary file not shown.
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"
|
||||
)
|
||||
36
src/backend/app/api/backtest.py
Normal file
36
src/backend/app/api/backtest.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
|
||||
from ..core.database import get_db
|
||||
from ..db.schemas import BacktestCreate, BacktestResponse
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/bots/{bot_id}/backtest", response_model=BacktestResponse)
|
||||
def start_backtest(bot_id: str, config: BacktestCreate, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/bots/{bot_id}/backtest/{run_id}", response_model=BacktestResponse)
|
||||
def get_backtest(bot_id: str, run_id: str, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/bots/{bot_id}/backtests", response_model=List[BacktestResponse])
|
||||
def list_backtests(bot_id: str, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.post("/bots/{bot_id}/backtest/{run_id}/stop")
|
||||
def stop_backtest(bot_id: str, run_id: str, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
57
src/backend/app/api/bots.py
Normal file
57
src/backend/app/api/bots.py
Normal file
@@ -0,0 +1,57 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
|
||||
from ..core.database import get_db
|
||||
from ..db.schemas import BotCreate, BotUpdate, BotResponse
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("", response_model=List[BotResponse])
|
||||
def list_bots(db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.post("", response_model=BotResponse)
|
||||
def create_bot(bot: BotCreate, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{bot_id}", response_model=BotResponse)
|
||||
def get_bot(bot_id: str, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.put("/{bot_id}", response_model=BotResponse)
|
||||
def update_bot(bot_id: str, bot: BotUpdate, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.delete("/{bot_id}")
|
||||
def delete_bot(bot_id: str, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.post("/{bot_id}/chat")
|
||||
def chat(bot_id: str, message: dict, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{bot_id}/history")
|
||||
def get_history(bot_id: str, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
13
src/backend/app/api/config.py
Normal file
13
src/backend/app/api/config.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/chains")
|
||||
def get_chains():
|
||||
return {"chains": []}
|
||||
|
||||
|
||||
@router.get("/tokens")
|
||||
def get_tokens():
|
||||
return {"tokens": []}
|
||||
38
src/backend/app/api/simulate.py
Normal file
38
src/backend/app/api/simulate.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
|
||||
from ..core.database import get_db
|
||||
from ..db.schemas import SimulationCreate, SimulationResponse
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/bots/{bot_id}/simulate", response_model=SimulationResponse)
|
||||
def start_simulation(
|
||||
bot_id: str, config: SimulationCreate, db: Session = Depends(get_db)
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/bots/{bot_id}/simulate/{run_id}", response_model=SimulationResponse)
|
||||
def get_simulation(bot_id: str, run_id: str, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/bots/{bot_id}/simulations", response_model=List[SimulationResponse])
|
||||
def list_simulations(bot_id: str, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
|
||||
|
||||
@router.post("/bots/{bot_id}/simulate/{run_id}/stop")
|
||||
def stop_simulation(bot_id: str, run_id: str, db: Session = Depends(get_db)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED, detail="Not implemented"
|
||||
)
|
||||
Reference in New Issue
Block a user