mercredi 11 janvier 2023

Should a Serverless Cloud Function Be Implemented Inside UI Layer (DDD)?

I'm currently implementing a trading bot using Python and I have the following design:

DAL:
  • StocksRepository
Domain:
  • RecommendationService
  • StocksDataCollectionService
UI:
  • bot.py: a function that buys recommended stock every day at specific time
  • simulator.py # simulating trading stocks on historical data

My questions are:

- Should I place the bot and the simulator in the same layer?
- Should I call this layer UI layer, or should I call it Application?
- What are the flaws of my design and things that could be named better?

** the bot and the simulator could even be separate projects, however they still use the same business logic
and share a lot of commonalities so I'm wondering what is the best way to design a system that allows
multiple projects to use it.

For the sake of simplicity, the design above does not contain every component.
The full design is:

DAl:
  • SqlStocksRepository
  • SqlSymbolsRepository
Domain:
  • services:
    • StocksDataCollectionService:
      • external_market_api_1
      • external_market_api_2
    • RecommendationService:
      • trading_strategy_1
      • trading_strategy_2
  • entities:
    • Stock
    • Symbols
  • interfaces:
    • IStocksRepository
    • ISymbolsRepository
UI:
  • trading_bot:
    • main.py
  • trading_simulator:
    • main.py
    • simulator.py # Feels like if it's in the domain layer it's an ISP violation, correct me if I'm wrong

Aucun commentaire:

Enregistrer un commentaire