How oxen-io/session-android works
Project Layers and Components
• User Interface / Presentation Layer – Represented by the “app” module. This includes Android activities, fragments, custom views, and UI components (e.g., in app/src/main/java/org/thoughtcrime/securesms/ui/*, components, home, conversation, preferences, etc.).
• Business Logic / Application Layer – This layer incorporates messaging and conversation handling, onboarding, preferences, and other core application logic. Some parts inside “app” are clearly used for handling events, notifications, and dependency injection (look at the “dependencies” folder inside app).
• Core Communication & Cryptography – Several libraries (libsession, libsession-util, libsignal, liblazysodium) contain the backbone for secure messaging, cryptographic operations, key management, and message processing. They incorporate cryptographic primitives, protocols, background jobs, network polling, and file/attachment handling.
• Networking & Service Integration – The app indirectly interfaces with Oxen Service Nodes that provide offline message storage and onion routing. Classes in libraries (for example, in libsession and libsignal) that deal with “messaging”, “pollers”, “network” and “jobs” will be responsible for connectivity, push notifications, and processing incoming/outgoing messages.
• Shared and Common Resources – Modules like “common” and “content-descriptions” also exist to provide shared resources, translations, and possibly reusable code across different parts of the application.
• Build and Configuration – Gradle build files (including build.gradle at various levels and buildSrc) hint that the application is built with a modular, multi-project setup. This should be shown as a separate side component in your architecture for compilation, dependency management, and testing.
Interactions and Data Flow
• The UI layer sends user interactions (like starting a new conversation or sending a message) to controllers or view models in the business layer.
• The business logic in turn calls into the secure messaging libraries (libsession, libsession-util, libsignal) to process messages, encrypt/decrypt data, manage attachments, and interact with the persistent storage (databases and content providers in app and libraries).
• The networking components (embedded in the lower-level libraries) perform background polling, request management, and interact with external Oxen Service Nodes – these should be represented as external system components.
• There are also testing modules (androidTest, test, sharedTest) that verify behavior at every layer.
Architectural Patterns and Design Principles
• Modularization: The project is clearly broken into multiple Gradle modules (app, common, content-descriptions, libsession, libsignal, etc.) which encapsulates responsibilities.
• Dependency injection: Many “Module” classes in the app (e.g., AppModule.kt, CallModule.kt) suggest DI to decouple modules – represent this with annotations or lines indicating dependency injection.
• Robust use of external libraries for cryptography and media handling.
Technologies, Frameworks, and External Systems
• Android SDK components for UI, activities, fragments, and testing (androidTest, test).
• Gradle as the build system, with custom buildSrc plugins.
• Cryptographic libraries: liblazysodium and libsignal.
• Networking protocols for push notifications, WebRTC, and request controllers (websocket, polling, etc.).
• Oxen Service Nodes as external decentralized servers that provide message storage and onion routing services.
Putting It All Together
– At the top, the “User Interface” layer (activities, fragments, views).
– In the middle, the “Business/Application Logic” layer (controllers, view models, dependency modules).
– Below, the “Core Messaging and Cryptography” modules (libsession, libsignal, liblazysodium) interfacing with a “Network/Service Node” external system.
– To one side, show “Shared Modules & Build Infrastructure” that connect all modules.
• Then, for a more detailed view, break down the UI layer into activities that lead into feature-specific modules (e.g., conversation handling, onboarding, media handling) and indicate how they call into the shared libraries.
• Testing modules (unit tests, instrumentation tests) off to the side, indicating that every layer is subject to rigorous testing.
• The separation between the front-end Android UI and the underlying secure messaging libraries.
• The interactions between components (data flows, network requests, dependency injection).
• Important architectural patterns like modularization and layered design.
• All the relevant technologies/frameworks (Android SDK, Gradle, external cryptographic libraries, and connections to Oxen Service Nodes).