KnightChaser / kcx

A Free-From-Risk crypto trading simulation named KCX(Knightchaser's Cryptocurrency eXchange), built with Svelte + FastAPI + Docker + α
https://kcx.knightchaser.com
3 stars 0 forks source link
cryptocurrency fastapi redis simulated-trading simulation sqlite3 svelte trading

KCX

Knightchaser's Cryptocurrency eXchange

TECH STACK

sveltekit_lgo vite_logo nodejs_logo jwt_logo fastapi_logo sqlite_logo redis_logo nginx_logo

docker_logo aws_logo

windows_logo ubuntu_logo

A Free-From-Risk cryptocurrency exchange simulation web application

You can try KCX at https://kcx.knightchaser.com/, which is hosted via AWS Lightsail by the repository owner. Note that the specifications, service status, and other things might be changed depending on the development contexts and situations. (Try only for fun! :D)

Service environmental variables

Currently, there are environment variables to set up the services as you need. Read the next chapter(Deployment) for complete contextual information.

SQLALCHEMY_DB_SQLITE3_FILENAME="kcx.db"

TEST_ACCOUNT_ID="test"
TEST_ACCOUNT_PW="test"
TEST_ACCOUNT_EMAIL="test@kcx.org"
COMMON_STARTING_BALANCE_IN_KRW=20000000000 # 20 billion KRW

# An example SECRET KEY for JWT. Change this to a random in production!
JWT_SECRET_KEY="KCXU$3R$3CR3T4JWT_"
JWT_TOKEN_EXPIRES_MINUTES=360 # 6 hours

# A custom API server built with Redis
REDIS_PORT=6379
REDIS_DB=0
REDIS_UDPATE_INTERVAL_IN_SECONDS=1
USER_RANKING_UPDATE_INTERVAL_IN_SECONDS=10

# Service configuration
# - Money balance (Disable(false) this if you want to use a fixed starting balance for all users)
ALLOW_ARBITRARY_BALANCE_DEPOSIT=false
ALLOW_ARBITRARY_BALANCE_WITHDRAW=false

Deployment

Note about TLS/SSL

http { server { listen 80; server_name kcx.knightchaser.com; return 301 https://$host$request_uri; }

server {
    listen 443 ssl;
    server_name kcx.knightchaser.com;

    ssl_certificate /etc/letsencrypt/live/knightchaser.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/knightchaser.com/privkey.pem;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;

    location / {
        proxy_pass http://frontend:5173;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location /api/ {
        proxy_pass http://backend:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

}

- In the **Docker compsure file(`docker-compose-server-deploy.yml`)**, adjust the `volumes` part of **`nginx`** to yours(if it's needed). If you follow the standard `letsencrypt`'s  TLS/SSL issuing procedure with Certbot, this adjustment won't be necessary. 
```yml
  ...
  nginx:
    image: nginx:latest
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - /etc/letsencrypt:/etc/letsencrypt
    depends_on:
      - frontend
      - backend
    networks:
      - kcx-network