Skip to content

feat: add backend API and solana challenge flows#2

Open
aster2333 wants to merge 3 commits into
masterfrom
codex/determine-tech-stack-for-full-stack-project
Open

feat: add backend API and solana challenge flows#2
aster2333 wants to merge 3 commits into
masterfrom
codex/determine-tech-stack-for-full-stack-project

Conversation

@aster2333

Copy link
Copy Markdown
Owner

Summary

  • add a FastAPI backend with challenge CRUD endpoints, bet verification, and Solana RPC health checks
  • wire the React app to the backend API for listing challenges, creating new ones, and submitting verified bets
  • replace react-i18next usage with lightweight shims and update translations, shared DTOs, and configuration to support the new workflow

Testing

  • npm run build
  • python -m compileall backend

https://chatgpt.com/codex/tasks/task_e_68f704fbaff48326add3ac0539c0eb69

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/app/database.py
Comment on lines +18 to +24
@contextmanager
def get_session() -> Iterator[Session]:
session = Session(engine)
try:
yield session
finally:
session.close()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Return actual Session object from dependency

The database dependency is wrapped in @contextmanager, so FastAPI receives a _GeneratorContextManager instead of a Session. Every route that depends on get_session calls methods like .exec on the returned value and will raise AttributeError at runtime, making all challenge/bet endpoints unusable. Remove the decorator and implement the usual yield session pattern so the dependency returns a live Session instance.

Useful? React with 👍 / 👎.

Comment thread backend/app/models.py
Comment on lines +43 to +59
class BetBase(SQLModel):
challenge_id: UUID = Field(foreign_key="challenge.id")
bettor_public_key: str
amount: float = Field(ge=0)
side: str = Field(regex="^(yes|no)$")
signature: str
destination: str


class Bet(BetBase, table=True):
id: UUID = Field(default_factory=uuid4, primary_key=True, index=True)
recorded_at: datetime = Field(default_factory=datetime.utcnow)
status: str = Field(default="confirmed")


class BetCreate(BetBase):
pass

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Align bet payload with path parameter

BetCreate inherits challenge_id, but the create bet API already takes challenge_id from the URL and the client request body (see CreateBetPayload) does not include this field. FastAPI will reject every bet submission with a 422 validation error before the transaction is recorded, even though the UI sends the SOL transfer first. The DTO should omit challenge_id or the route should not require it in the body so bets can be persisted after sending funds.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant