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

Current ongoing issues and requests after releasing v1.0.1. #1

Closed KnightChaser closed 3 weeks ago

KnightChaser commented 1 month ago

Issue Summary

This issue addresses several problems and feature requests related to the Docker setup, code imports, and enhancements for user experience and platform statistics. Let's fix the issues step by step... for the stable release I dream.

Detailed Description

  1. Persistent Storage for Databases in Docker:

    • Currently, docker-compose.yml includes SQLite3 and Redis, but lacks volume settings for these services. This results in the inability to store database files permanently, leading to data loss upon container restart.
    • Solution: Add volume settings to docker-compose.yml to ensure persistent storage of database files.
  2. Import Typing Error in /src/route/exchange/main.svelte:

    • There is a typing error in the import statement where CenterPanel should be changed to centerPanel. This causes an error when running in Docker.
    • Solution: Correct the import statement in /src/route/exchange/main.svelte to use the appropriate case.
  3. Profile Picture Customization:

    • Implement a feature that allows users to set and customize their profile pictures.
    • Solution: Develop a user interface for uploading and setting profile pictures, and ensure backend support for storing and retrieving these images.
  4. User Ranking Feature:

    • Display a ranking of the top X users based on their total assets on the main page.
    • Solution: Create a leaderboard component that fetches and displays user rankings dynamically.
  5. Total Transactions Display:

    • Show the total amount of all transactions made on the platform on the main page.
    • Solution: Implement a real-time counter or summary that aggregates and displays the total transaction value.
  6. Toggle Setting for Enabling/Disabling Balance Modifications:

    • Add a toggle setting to enable or disable the actions that allow users to modify their balances. This is to prevent abuse.
    • Solution: Introduce a configuration setting and associated logic to control the ability to modify user balances.
  7. Deployment configuration

    • In the deployment environments, there should be some points to be modified such as API_URL is localhost to YOUR_AWS_PUBLIC_IP
    • Solution: Documentation on readme.MD or writing a script to automatically apply by referring .env or other environmental settings attached to this project.\
  8. Crypto sell issues

    • There are some uncomfortable issues about floating points. The crypto price varies a lot, so adjusting the floating number amount by manually is annoying.
    • Solution: Adjust the way to buy and sell. The slider is just a slider, not a 20% fixed movement. When buying, calculate by the fiat currency. When selling, calculate the crypto amount. By processing transactions by what the user exactly has, there is no mismatch point when the amount is near 100%. How about adding some buttons about 25%, 50%, 75%, and 100% instead? Sliders are just freely adjustable.

Steps to Reproduce

  1. For Persistent Storage Issue:

    • Deploy the application using the current docker-compose.yml.
    • Observe the data loss in SQLite3 and Redis after restarting the containers.
  2. For Import Typing Error:

    • Deploy the application and navigate to the exchange route.
    • Observe the import error in the console.

Suggested Improvements

  1. Docker Configuration:

    services:
     sqlite:
       image: sqlite:latest
       volumes:
         - sqlite_data:/var/lib/sqlite
     redis:
       image: redis:latest
       volumes:
         - redis_data:/data
    
    volumes:
     sqlite_data:
     redis_data:
  2. Correcting Import in Svelte File:

    import centerPanel from './CenterPanel.svelte';

Additional Notes

KnightChaser commented 1 month ago

About the order placing UI matters, the UI has been fully refurbished again.

image

KnightChaser commented 1 month ago

About the database, this system for two types of databases;

# database_session.py
import os
import redis
from database import SessionLocal

# Return the SQLite3 database session
def get_sqlite3_db():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()

# Return the Redis database session
def get_redis_db():
    # Check if the current environment is in Docker
    is_docker = os.getenv("IS_IN_KCX_BACKEND_DOCKER", "false").lower() == "true"

    redis_host = "db-redis" if is_docker else "localhost"
    os.environ["REDIS_HOST"] = redis_host

    redis_port = int(os.getenv("REDIS_PORT", 6379))
    redis_database = int(os.getenv("REDIS_DB", 0))

    redis_client = redis.Redis(host=redis_host, 
                               port=redis_port, 
                               db=redis_database)

    return redis_client

For code reusability and structural consistency, there were major changes that the redis client objects are obtained by the getter function. However, I couldn't find the advantages of using generators like SQLite3, so I decided to return the redis_client object directly, which is more convenient.

KnightChaser commented 1 month ago

Looks like Redis is not backed up in the docker environment since reloading docker means rebuilding the entire system. Some measures are needed....

(Some useful or fun statistics visited frequently are also stored in redis for performance)

image

KnightChaser commented 1 month ago

About the order placing UI matters, the UI has been fully refurbished again.

  • Quick select of 20%/40%/60%/80%/100%(ALL IN) via click
  • Freely adjustable slider (actually, 1%)
  • Number formatting(Limit the number of decimal points, comma...) and right-align
  • Bugfix; there were some issues about inconsistencies about the slider

    • When the user is trying to buy the crypto, the percentage should be considered by how much money(fiat currency) that the user has, and the slider should be synchronized accordingly.
    • When the user is trying to sell the crypto, the percentage should be considered by how much cryptocurrencies(cryptos) that the user has, and the slider should be synchronized accordingly.

image

When the user changes the button, the slider bar should be reset. When the user moves an asset to another asset, the availability of information should vary. However, the current status is not responsive to this issue.

KnightChaser commented 1 month ago

The issue has been (initially) resolved in the Release 2.1.0. This issue will be closed if there is no more further issues for few days later.

KnightChaser commented 1 month ago

Image upload feature isn't working. It seems that any new image from any source is overlapping the previous one and the images are managed as one in bug. What the actual fuck

Here is some crazy picture

image

KnightChaser commented 3 weeks ago

No further issues confirmed. Issue closed.