How adguardteam/adguardforandroid works
Project Type and Purpose
• This is a mobile (Android) application whose primary purpose is filtering out online ads, tracking scripts, and malvertising. It also provides additional privacy features by blocking unwanted content via VPN or proxy modes and supports custom DNS settings (with DNSCrypt).
• Although the repository is used primarily as a bug tracker and community engagement hub (with GitHub’s issue templates and contribution guidelines), the README gives clear insights into the product’s architecture and functionality.
Key Components
a. User Interface (UI) Layer:
• The graphical interface that users interact with. This includes the home screen, protection status display, settings menu, and notifications (as shown in the screenshots in the README).
• That the UI facilitates control such as enabling/disabling ad blocking, configuring DNS options, and switching between VPN or HTTP proxy modes.
b. Core Ad-Blocking Engine:
• The central service that applies filtering rules to block ads and trackers.
• This engine needs to intercept network traffic (leveraging Android VPN Service APIs) and process it according to the rules list.
• It should interact with both the UI (to receive configuration changes) and the system’s network layer.
c. Network Interception & VPN/Proxy Service:
• The component that implements the virtual private network (VPN) or HTTP proxy mode.
• Responsible for redirecting and managing network traffic and ensuring that ad/trackers are effectively filtered out without requiring root.
• Dependencies to the Android framework APIs (VPN Service) and any third-party libraries used for DNSCrypt.
d. DNS Management & Filtering:
• A dedicated module (or integrated portion within the core engine) that handles custom DNS settings.
• This component may include DNSCrypt capabilities and integrates closely with the filtering engine to prevent malicious ads at the DNS resolution level.
e. Data Storage & Configuration Persistence:
• A layer to store user settings, filter lists, logs (if any; as privacy policy indicates only limited information is used), and possibly locally cached rules.
• It might be using SQLite, SharedPreferences, or a custom lightweight database according to Android conventions.
f. Remote Updates & Rule Management:
• An element responsible for fetching or updating filter lists and application rules.
• Often involves RESTful API interactions to download configurations or updates from external servers.
• This component is typically modular to allow for seamless updates without interfering with the live filtering engine.
g. External Services Integration:
• Although not directly in the source tree, the README and app ecosystem hint at interactions with external services:
• License checking and (possibly) telemetry updates (only minimal and in line with the privacy policy).
• Contribution and feedback systems accessible through GitHub issues or the reporting tool mentioned in the README.
Relationships and Interactions
• That the core engine interacts with:
• The VPN/Proxy service for real-time network interception.
• The DNS management module for routes that affect resolution of network domains.
• The data layer for storing / retrieving current settings, rules, and filter lists.
• Also, the remote update & rule management component should be shown fetching data from external servers and updating both the core engine and the data storage.
Architectural Patterns and Design Principles
• Modular design: Break down the system into clearly defined modules (UI, engine, VPN service, DNS manager, data storage, networking), facilitating easier maintenance and extension (for instance, the addition of a new protocol or filtering mechanism).
• Separation of concerns: The architecture should segregate the presentation layer (UI) from business logic (filtering engine) and system integration layers (VPN, DNS, networking).
• Event-driven or observer patterns: Use events or callbacks to update UI based on changes in filtering status, network conditions, or updates from the remote service.
• Security principles: Since this deals with network traffic and user privacy, also highlight secure communications (e.g., when downloading filter updates) and strict access controls.
Instructing the Principal Software Engineer
• Rectangles for application components.
• Ovals or other symbols for external services.