How polygant/opencex-backend works
Main Components
• User Interfaces & APIs:
• Public Website and Web UI: Represented by the public_api module (with templates, static assets) and parts of “exchange” handling basic site routes and documentation.
• Admin Panel & Admin REST: Depicted as separate components. The “admin_panel” provides a web-based admin interface (with dashboard, menus, forms, templates) while “admin_rest” exposes REST endpoints for administrative operations.
• Core Business Logic:
• Core Module: This is the heart of the exchange, handling authentication, order book management, wallet management, API URL routing, and more (as seen in the “core” directory with its views, models, serializers, and websockets).
• Exchange Module: Manages environment-specific settings (e.g., database, logging, celery, and task management) that tie together configuration and operational orchestration.
• Bots: A dedicated module (in the “bots” directory) for trading bots, automated order processing, and exchange interactions featuring tasks, migrations, and integrations with external coin exchanges.
• Cryptocurrency & Blockchain Integration:
• Cryptocoins: This module handles coin-specific behaviors. It contains submodules for various coins (like BTC, ETH, MATIC, TRX, and USDT), wallet management, connections to blockchain nodes, and interfaces with external APIs.
• External Integration & Services: Lib/Services and parts of “cryptocoins” (especially under interface, evm, and data_sources) represent communication with external blockchain nodes, third-party APIs, and other exchange-related integrations.
• Supporting Components & Auxiliary Services:
• Notifications: Manages alerts, email templates, and communication for actions such as order changes or withdrawals.
• Dashboard REST and SEO: Modules that provide additional API endpoints (for dashboards) and SEO functionality.
• Sci, lib, and other utilities: These modules or libraries provide helper functions, caching utilities, and scheduled tasks (e.g., via Celery) to support the exchange’s dynamic operations.
Detail Relationships and Interactions
• Users interact with the Public Website and Admin interfaces.
• Requests (both UI and API calls) flow from the front end into the Core and Exchange modules.
• Core business processes call the Cryptocoins module for wallet or coin-specific actions (e.g., handling deposits, withdrawals, and real-time order book updates).
• Bots operate either independently or are triggered by the Core to perform automated trading, updating orders and executing strategies.
• Notifications and the Public API serve data externally, including displaying exchange stats and real-time market information.
Architectural Patterns & Design Principles
• Modular Django Structure: Each top-level directory (admin_panel, admin_rest, core, cryptocoins, etc.) corresponds to a Django “app” following the separation of concerns. Show how each app connects to the central DB.
• RESTful API design in admin_rest and public_api: Highlight API gateways that handle external requests.
• Asynchronous Task Processing: Illustrate components using Celery (located in the “exchange” directory) for background processing and scheduled tasks.
• Real-time Communications: Represent the use of websockets (in core/websockets) for live order book updates or notifications.
• Integration Layer for External Services: Indicate modules handling blockchain connections (coins, data_sources, lib/services, etc.) and third-party integrations for notifications and scoring.