How decred/dcrdex works
Project’s Main Components
• Client Applications:
• The “client” directory houses Bison Wallet (both desktop “bisonw” and additional client commands) along with modules for trading logic and asset-specific implementations.
• The “companionapp” folder includes an Android application that provides a mobile front-end.
• Webserver components (e.g. “client/webserver” and “client/websocket”) indicate a browser-based interface or additional API layers.
• Server:
• The “server” directory contains the DEX server components including matching, order book management, swap settlement, and order processing.
• API endpoints, admin functions, authentication, and database access layers are clearly organized under “server/auth”, “server/book”, “server/asset”, “server/db” and others.
• Protocol and Core Exchange Logic:
• The “dex” directory holds the protocol code, atomic swap logic, and supporting tests to implement the DEX messaging and matching protocols (including detailed testing and specification support).
• P2P/Decentralized Mesh Component:
• The “tatanka” directory includes the Tatanka Mesh code which is designed to replace the centralized order book model with a decentralized peer-to-peer alternative.
• Additional Infrastructure:
• “internal”, “docs”, and “spec” directories provide internal utilities, developer documentation, and the official specification which underscores the protocol design.
• There are also configuration and deployment files (e.g. Dockerfiles, GitHub workflows, build scripts) which are important when considering how components are built and deployed.
Relationships and Interactions
• How the front-end clients (Bison Wallet desktop, web client components, Android companion app) interact with the DEX server over defined API and RPC channels.
• That the server uses modules in “server/asset” for asset-specific operations (atomic swaps, SPV, coin selection, etc.) that integrate with blockchain networks.
• Exchange “dex” module which formalizes the protocols and handles the message flow for order matching.
• Connections from the server to external blockchain nodes (on-chain settlement) as well as interactions with databases (both the bolt DB in “client/db/bolt” and the PostgreSQL-based driver in “server/db”).
• For Tatanka Mesh, illustrate a peer-to-peer network where nodes collectively manage order routing, reputation, and oracle services.
Architectural Patterns and Design Principles
• The system separates concerns very well – presentation (client UI and web layers), application logic (DEX matching, order book handling), asset modules (atomic swap, blockchain connectors), and infrastructure (database, network communication).
• The architecture also emphasizes a client–server division (with additional decentralized P2P mesh in Tatanka) and follows micro-modular design to cope with cross-chain atomic swaps.
• Representing error-handling, testing harnesses, and simulation (e.g. “simnet-trade-tests” and “localetest”) as supportive elements for robustness.
Relevant Technologies, Frameworks, and Libraries
• Golang is the primary programming language, indicated by the go.mod and .go files.
• Docker containers are used for deployment or testing, as indicated by Dockerfiles and related workflows.
• Additional build and test scripts are included (see GitHub workflows under “.github/workflows”).
• The web interface (built with JavaScript/TypeScript, Node, webpack, etc.) is located in “client/webserver/site”.
• For Android development in the companion app, see the Gradle files and AndroidManifest.xml in the “companionapp/android” folder.
• The system leverages atomic swap protocols, SPV (Simplified Payment Verification) techniques, and decentralized reputation/oracle mechanisms.
General Advice
• Be very detailed: include all essential components and microservices.
• Do not shy away from showing sub-components such as asset modules, orderbook subsystems, or even test harnesses if they impact the overall architecture.
• Use clear annotations to indicate the technology stacks (e.g. “Golang”, “Docker”, “Webpack/JS”) and architectural motifs (e.g. client–server, microservices, P2P overlay).