Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 34 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.cursorrules
You are a Senior Front-End Developer and an Expert in ReactJS, NextJS, JavaScript, TypeScript, HTML, CSS and modern UI/UX frameworks (e.g., TailwindCSS, Shadcn, Radix). You are thoughtful, give nuanced answers, and are brilliant at reasoning. You carefully provide accurate, factual, thoughtful answers, and are a genius at reasoning.

- Follow the user’s requirements carefully & to the letter.
- First think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.
- Confirm, then write code!
- Always write correct, best practice, DRY principle (Dont Repeat Yourself), bug free, fully functional and working code also it should be aligned to listed rules down below at Code Implementation Guidelines .
- Focus on easy and readability code, over being performant.
- Fully implement all requested functionality.
- Leave NO todo’s, placeholders or missing pieces.
- Ensure code is complete! Verify thoroughly finalised.
- Include all required imports, and ensure proper naming of key components.
- Be concise Minimize any other prose.
- If you think there might not be a correct answer, you say so.
- If you do not know the answer, say so, instead of guessing.

### Coding Environment
The user asks questions about the following coding languages:
- ReactJS
- NextJS
- JavaScript
- TypeScript
- TailwindCSS
- HTML
- CSS

### Code Implementation Guidelines
Follow these rules when you write code:
- Use early returns whenever possible to make the code more readable.
- Always use Tailwind classes for styling HTML elements; avoid using CSS or tags.
- Use β€œclass:” instead of the tertiary operator in class tags whenever possible.
- Use descriptive variable and function/const names. Also, event functions should be named with a β€œhandle” prefix, like β€œhandleClick” for onClick and β€œhandleKeyDown” for onKeyDown.
- Implement accessibility features on elements. For example, a tag should have a tabindex=β€œ0”, aria-label, on:click, and on:keydown, and similar attributes.
- Use consts instead of functions, for example, β€œconst toggle = () =>”. Also, define a type if possible.
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Ignore the functions directory when building the frontend Docker image
functions/

# Ignore node_modules (these are installed inside the Docker image)
node_modules/

# Ignore .pnpm-store (pnpm's global cache, not needed in build context)
.pnpm-store/

# Ignore Vite's cache
.vite/

# Ensure dist is NOT ignored (it contains your built frontend)
!dist/

# Other common ignores for frontend projects
.git/
.env
.env.*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.DS_Store
19 changes: 19 additions & 0 deletions Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Use a lean Nginx image
FROM nginx:alpine

# Copy your built React app from the dist folder into Nginx's public directory
# Ensure this command points to where your 'dist' folder is relative to the Dockerfile.
# Since Dockerfile.frontend is in 'testproject' and 'dist' is also in 'testproject',
# './dist' is correct.
COPY ./dist /usr/share/nginx/html

# Copy a custom Nginx configuration to ensure single-page application routing
# This is crucial for React Router to work correctly on refreshes or direct URL access
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Expose port 80 for the Nginx server
EXPOSE 80

# Command to start Nginx
CMD ["nginx", "-g", "daemon off;"]

9 changes: 5 additions & 4 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# KuCoin API Configuration
KUCOIN_API_KEY=your_kucoin_api_key_here
KUCOIN_API_SECRET=your_kucoin_api_secret_here
KUCOIN_API_PASSPHRASE=your_kucoin_api_passphrase_here
KUCOIN_API_KEY=683e3b32965ac1000180c4bc
KUCOIN_API_SECRET=21f95591-0c0c-445d-b6ce-d72c740d5a5f

KUCOIN_API_PASSPHRASE=337819em
KUCOIN_SANDBOX=true

# Social Media APIs
Expand All @@ -21,4 +22,4 @@ TAKE_PROFIT_PERCENTAGE=0.15

# API Server Configuration
API_HOST=0.0.0.0
API_PORT=8000
API_PORT=8000
181 changes: 181 additions & 0 deletions build_log.txt

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions cloudbuild.frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# cloudbuild.frontend.yaml
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/hybridbot-fe281/hybridbot-frontend', '-f', 'Dockerfile.frontend', '.']
images:
- 'gcr.io/hybridbot-fe281/hybridbot-frontend'

177 changes: 177 additions & 0 deletions complete-backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
import uvicorn
from datetime import datetime, timedelta
import random

app = FastAPI(title="HybridBot API", version="1.0.0")

# Add CORS middleware to allow browser requests
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allow all origins including file://
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

# Data models
class LoginRequest(BaseModel):
email: str
password: str

class RegisterRequest(BaseModel):
email: str
password: str
name: str

# Mock data
users_db = {
"test@test.com": {"password": "test123", "name": "Test User", "id": "1"},
"demo@demo.com": {"password": "demo123", "name": "Demo User", "id": "2"}
}

mock_bots = [
{"id": "1", "name": "BTC Scalper", "status": "running", "profit": 2.5, "trades": 15},
{"id": "2", "name": "ETH Grid Bot", "status": "paused", "profit": -0.8, "trades": 8},
{"id": "3", "name": "Multi-Pair Bot", "status": "running", "profit": 5.2, "trades": 23}
]

mock_prices = [
{"symbol": "BTCUSDT", "price": 43250.50 + random.uniform(-100, 100), "change": round(random.uniform(-5, 5), 2)},
{"symbol": "ETHUSDT", "price": 2580.25 + random.uniform(-50, 50), "change": round(random.uniform(-3, 3), 2)},
{"symbol": "ADAUSDT", "price": 0.485 + random.uniform(-0.01, 0.01), "change": round(random.uniform(-2, 2), 2)}
]

mock_trades = [
{"id": "1", "symbol": "BTCUSDT", "side": "buy", "amount": 0.01, "price": 43200, "timestamp": datetime.now().isoformat()},
{"id": "2", "symbol": "ETHUSDT", "side": "sell", "amount": 0.5, "price": 2590, "timestamp": datetime.now().isoformat()}
]

# Root endpoint
@app.get("/")
async def root():
return {"message": "HybridBot API is running!", "version": "1.0.0", "endpoints": [
"/auth/login", "/auth/register", "/bots", "/portfolio", "/prices", "/trades", "/signals"
]}

# Authentication endpoints
@app.post("/auth/login")
async def login(request: LoginRequest):
user = users_db.get(request.email)
if not user or user["password"] != request.password:
raise HTTPException(status_code=401, detail="Invalid email or password")

return {
"access_token": f"fake_token_{user['id']}",
"token_type": "bearer",
"user": {
"id": user["id"],
"email": request.email,
"name": user["name"],
"isEmailVerified": True
}
}

@app.post("/auth/register")
async def register(request: RegisterRequest):
if request.email in users_db:
raise HTTPException(status_code=400, detail="Email already registered")

new_id = str(len(users_db) + 1)
users_db[request.email] = {
"password": request.password,
"name": request.name,
"id": new_id
}

return {
"access_token": f"fake_token_{new_id}",
"token_type": "bearer",
"user": {
"id": new_id,
"email": request.email,
"name": request.name,
"isEmailVerified": False
}
}

@app.get("/auth/me")
async def get_profile():
return {
"id": "1",
"email": "test@test.com",
"name": "Test User",
"isEmailVerified": True
}

# Trading endpoints
@app.get("/bots")
async def get_bots():
return {"bots": mock_bots}

@app.get("/portfolio")
async def get_portfolio():
return {
"balance": 12450.75,
"pnl": 6.9,
"trades": 46,
"last_updated": datetime.now().isoformat()
}

@app.get("/prices")
async def get_prices():
# Update prices with small random changes
for price in mock_prices:
price["price"] = round(price["price"] + random.uniform(-5, 5), 2)
price["change"] = round(random.uniform(-3, 3), 2)

return {"prices": mock_prices}

@app.get("/trades")
async def get_trades():
return {"trades": mock_trades}

@app.get("/signals")
async def get_signals():
return {
"signals": [
{"symbol": "BTCUSDT", "signal": "BUY", "strength": 0.8, "timestamp": datetime.now().isoformat()},
{"symbol": "ETHUSDT", "signal": "HOLD", "strength": 0.6, "timestamp": datetime.now().isoformat()}
]
}

# Additional endpoints for completeness
@app.post("/bots")
async def create_bot():
return {"message": "Bot creation feature coming soon!"}

@app.get("/analytics")
async def get_analytics():
return {"message": "Analytics feature coming soon!"}

@app.get("/settings")
async def get_settings():
return {"message": "Settings feature coming soon!"}

if __name__ == "__main__":
print("πŸš€ Starting Complete HybridBot API...")
print("πŸ“ API will be available at: http://localhost:8000")
print("🌐 Frontend should connect successfully!")
print("πŸ“Š Available endpoints:")
print(" - GET /")
print(" - POST /auth/login")
print(" - POST /auth/register")
print(" - GET /auth/me")
print(" - GET /bots")
print(" - GET /portfolio")
print(" - GET /prices")
print(" - GET /trades")
print(" - GET /signals")
print("\nπŸ’‘ Test credentials:")
print(" Email: test@test.com")
print(" Password: test123")
print("\nπŸ”§ CORS enabled for all origins")

uvicorn.run(app, host="0.0.0.0", port=8000, log_level="info")
Loading