contrary to popular believe DDD is not DomainDrivenDesign. . . at least not in this case, it is this: D/D/D
- CardDispenser -> sends card info to
YuGiOh-Card-Queue
rabbitMQ bus thru the default exchange, - CardProcessor <- Read the card data from
YuGiOh-Card-Queue
- CardProcessor -- process the card
- CardProcessor -> Sends the processed cards to
YuGiOh-Processed-Queue
- Card_Saver <- Reads from
YuGiOh-Processed-Queue
- Card_Saver -- saves the cards into
postgres db
you have yugioh cards in a file which u got from: YgoProDeck ; get the cards like this and don't annoy their api
http GET https://db.ygoprodeck.com/api/v7/cardinfo.php > AllCards.json
if u don't have
httpie
install it viapython
,scoop
orpackage manager
i was sick and bored so my tired brain came up with this, it serves no practical purpose, think of it as an experiment
card info gotten from Ygoprodeck.com, i got all the cards as to not annoy their API
- get RabbitMQ started:
docker run --hostname YuGiOh-rabbit --name yugioh-bus -p 5672:5672 -p 15672:15672 rabbitmq:3-management
5672: to access the node 15672: to access the web interface
- start pubing the cards
cd cardDispenser
python -m venv venv
.\venv\Scripts\activate # source venv/bin/activate
pip install -r reqs.txt
uvicorn main:app --reload -p 4444 # or whatever u want
-
run the c# code
-
save the cards from the queueueueue to the database a. i. start a postgress instance
docker container run -p 5432:5432 --name testgres postgres
i. make sure it's correctly sat up either by dbeaver or thru the terminal i.docker exec -it <container name (docker ps helps)> psql -U admin
b. cd intocard_saver
->cargo build
->cargo run
- FastAPI as pythonAPI that will keep pumping RAW card info as JSON into rabbitMQ
queueName=YuGiOh-Card-Queue
, it has 2 endpoints:- Start. /start. ; will start populating the que
- Stop. /stop; will cease hostilites and declare peace. . . .
the way the inital plan was for the API to get either a
start
orstop
commands via REST and ivoke an event depending, at least that was the main idea, toggle switching, but as the data we have is finite, i didnt want duplication hence the way i did it.
-
RabbitMQ as the bus that will distribute the info between the apps
-
C# 7 as the cards proccessor, it takes the card from pyPi and removes some props and throws it again at the space rabbit this time onto a different queue
queueName=YuGiOh-Processed-Queue
-
rust as the database manager
-
postgress as the DB
-
Docker as the rich guy that provided the places to act
I would love to thank:
- Panadol for making me see ghosts
- lemon and honey
- windows for not crashing randomly
- git for saving me from windows
the
loop
is pointless as this should just run once and only once, if this was supposed to listen infinitly it should invoke events or something anyways i'm having fun used raw sql cause it's healthier than an ORM (you don't know what they put in there)