Skip to content

adamhill/ArchitecturalKatas-2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TABLE OF CONTENTS

1. Welcome to Wonderous Toys

This is the GitHub repository for a solution created by team Wonderous Toys during the 2023 O'Reilly Architectural Kata. It contains a proposed architecture for Wildlife.ai project for an open-source, AI assisted wildlife camera that will enable more efficient species conservation efforts worldwide.

This solution emphasizes:

  • Simplicity: Mobile first, simple Pub/Sub for Notifications, significant control for local camera owners
  • Frugality: Few and small recurring infrastructure charges, Modular monolith when we need it. Pre-existing use of users' mobile devices.
  • Autonomy: Mobile app and Event-driven pieces could be lifted and shifted into contaners and could be hosted locally (Bring-Your-Own-Cloud) by the user if needed (100% email Notification or Mesh networking if needed)

2. Problem Space

Wildlife Watcher

Wildlife.ai is a charitable trust that utilizes artificial intelligence to expedite wildlife conservation. Collaborating with grassroots wildlife conservation projects, they develop open-source solutions employing machine learning to accelerate conservation efforts. Additionally, they organize community events, seminars, and educational activities aimed at creating and maintaining machine-learning solutions to reduce the current rate of species extinction.

Objective

The project aims to build an open-source wildlife camera that:

  • Triggers based on the movement of target animals,
  • Employs an AI model to identify captured species,
  • Reports observations in near real-time to biologists or other users.

Users

The intended users of the project include:

  • Biologists
  • Nature Enthusiasts

System Requirements

  • Users should be able to communicate with the camera using a mobile app,
    • To set the cameras on/off,
    • Adjust settings without opening the cameras
  • Users should be able to analyze the videos using common camera trap labelling platforms.
  • Users should be able to publish frames from the videos to iNaturalist for experts to help identify the species.
  • Users should be able to train edge models easily
  • Users should be able to publish the species occurrences to
  • Cameras should be able to process the footage on the device and send a small alert message to the users via
    • LoraWan, 3G or satellite.

Constraints and Assumptions

The project operates within specific constraints:

  1. Wildlife ai operates as a charitable trust

Assumption: Wildlife ai being a charitable trust we assume there will be budgetary constraints for this project. Financial limitations necessitate cost-effective solutions and careful allocation of resources to ensure the project's sustainability and success.

  1. Wildlife AI wants to build an open-source camera integrated with artificial intelligence for species conservation efforts.

Assumption: The software solution serves as an add-on to the camera, facilitating data sharing with various platforms, enthusiasts, and biologists. Both the camera and the accompanying software will be open-source, catering to users with varying levels of technical expertise.

  1. Camera hardware specifications:
  • Ultra-low-power microcontrollers (up to 512KB Flash)
  • Comprising of interchangeable modules (e.g., optical sensor, IR lights, transceiver module, batteries) within a watertight 3D-printed enclosure.
  1. Camera Acquisition:

Assumption: Camera could be purchased from Wildlife.ai, a manufacturing partner, or the user could build it themselves using Wildlife.ai open source hardware plans and firmware.

  1. Mobile App Installation:

Assumption: Users can download Mobile App from the app stores or build it directly from the open source repository and load it on their mobile device.

  1. Integrations with Wildlife Insights, iNaturalist, Roboflow, GBIF etc.,:

Assumption: Any integrations with partners and vendors applications can be configured in the application.

  1. Internet Access Uncertainty:

Assumption: Internet access cannot be guaranteed in the locations where the cameras will operate. This implies that the data (e.g. videos and models) can only be accessed while in proximity of the camera.

  1. User Base: The user base comprises only a few hundred users and is spread globally.

Assumption: Each user will only have a small number of cameras. Given this relatively small user community, deploying and maintaining a hosted solution could prove burdensome and financially inefficient.

  1. User skill sets:

Assumption: Biologists, enthusiasts, and volunteers have different levels of technical know-how. Since many tasks are done by volunteers, it would be great if the solution is simple for anyone to use.

  1. User Device capability:

Assumption: Mobile devices possessed by the users have sufficient processing power and internet connectivity to handle essential tasks like edit & process images, data uploading and remote camera control.

3. Solution Space

Context - Key Drivers

In the pursuit of the charity's success, several critical factors stand out as the driving forces propelling Wildlife AI's operations forward. These key drivers encompass the core principles and objectives behind our team's technical solution to guide Wildlife AI's strategies and actions.

Prototype Testing

One of the foremost drivers is the ability to introduce Wildlife AI's product for the testing of prototypes and ideas. This imperative arises from the desire to observe how Wildlife AI's innovations resonate with a wide spectrum of life forms inhabiting diverse ecosystems, including forests, oceans, and avian habitats. By quickly immersing Wildlife AI's solutions in these diverse environments, invaluable insights are gained into what works and what doesn't. This agile approach enables Wildlife AI to respond promptly to feedback, refining the product based on real-world usage and ensuring its suitability for various species and ecosystems across the globe.

Species Conservation With Community/Government Collaboration

Another pivotal driver of Wildlife AI is the commitment to species conservation. Wildlife AI actively monitors the well-being and potential endangerment of various species, taking proactive measures when necessary. These actions may include engaging with local communities and collaborating with governmental authorities to protect and preserve threatened species. This reflects their dedication to sustainable practices and environmental protection, aligning core objectives with broader societal and ecological goals.

Future-ready Integration Support

In an ever-evolving technological landscape, the ability to adapt and evolve is paramount. Recognizing this, our solutions team is dedicated to enabling Wildlife AI's users to gear towards supporting future growth and innovation through robust integrations. This forward-thinking approach ensures that Wildlife AI's systems remain flexible and adaptable, accommodating emerging trends and technologies. By doing so, Wildlife AI can position itself to stay ahead of the curve and continue providing state-of-the-art solutions to support its mission.

Summary

In summary, focusing on prototype testing the product, ecological conservation, and future-proofing systems that allow to shape the core values and actions of Wildlife AI the solution our team proposes should meet the needs of Wildlife AI's business today but also anticipate and address the challenges and opportunities of tomorrow.

Architecture Characteristics

After conducting a thorough analysis of Wildlife AI's requirements and key business drivers, we have identified the primary architectural characteristics that the system should incorporate. These key characteristics include Feasibility, Simplicity, Domain Part Abstraction and Interoperability.

  1. Feasibility/Cost-effective: This architectural attribute ensures that the system's design aligns with the practicality of implementation within the available resources, budget, and time constraints.

Based on the financial constraints of being a charitable trust and to support the open-source initiative we want to propose a cost-effective solution. #charity #open source initiative

  1. Simplicity: Highlights the value of a clear and efficient system design. It advocates for an architecture that is easily comprehensible, user-friendly, maintainable and ultimately improving overall usability and reducing operational complexity.

The users who will be interacting with the system can have limited technical skillset, and given Wildlife AI support open-source initiative, we have preferred to design a solution that is simple to use and maintain. #technical skill set #open source initiative

  1. Domain Part Abstraction: The abstraction of domain components paves a path for a straightforward and intelligible foundation when building the software solution for open-source users. Each module is self-contained and easily comprehensible.

Although not explicitly specified in the requirements, the abstraction of domain components has emerged as an implicit necessity to facilitate future scalability for the intended user base.

For those seeking a solution that can be built upon existing functionalities, the abstraction of domain components provides a robust groundwork.

In the event the community's requirements (Wildlife ai or its open-source users) surpass the initial setup, these domains can be extracted and implemented as services to accommodate scalability.

  1. Interoperability: Interoperability ensures that our system can seamlessly communicate with and function alongside the tools and services deployed by Wildlife's partners and vendors. It helps Wildlife AI users to work well together with partners, vendors, and other ecosystem members to enhance wildlife conservation efforts.

Based on the requirements, the system should be able to interact with the third party applications. #system requirements #open source initiative

Furthermore, we aim to provide the following additional architectural features:

  1. Security: Being an implicit characteristic, it is a crucial part of any software system design. We are determined to put strong protections in place to keep all data in our systems safe, making sure data stays private and shielding it from any possible threats.

  2. Workflow: With the need to integrate with multiple third party applications, the system could incorporate workflow capabilities to support complex processes, optimizes the flow of data and actions. This ensures that tasks are automated and well-coordinated within the solution

By prioritizing these architectural characteristics, we aim to develop a system that not only aligns with Wildlife AI's current requirements but also offers adaptability for future growth and evolution. Our approach is geared towards delivering a feasible, user-friendly, and secure system that seamlessly interacts with external services and optimizes workflow processes where necessary.

Architecture Style Proposed

Based on the architectural characteristics we've identified, we suggest a combination of Modular Monolith, Micro kernel, and Event-Driven architectures to build the application. See the image below with the mapping between architecture characteristics mentioned above and the Architecture Styles proposed in this solution. In this approach, we organize the different aspects of the functionalities into modules and one of these modules uses micro-kernel design. Each of these modules has its own well defined API's that serve as a way for them to communicate with one another and the user interface components. In addition, to address the near-real time communication request of this problem and its constraint of uncertain internet access, the event-driven architecture can successfully address the needs. This setup makes sure that the application is well-structured and can efficiently work with different integrations to support the business requirements.

Architecture Style

Other Considerations

Additionally, we recognize the importance of the system's ability to adapt and grow, especially when some users in the Wildlife AI's open-source community require more resources than others. In situations like these, as business needs change, the system should be capable of supporting growth by seamlessly scaling, potentially moving one or more services outside of the (modular-monolithic) application ecosystem to microservices. This flexibility guarantees that Wildlife AI's technical setup stays in sync with user's growth and operational requirements.

4. Domain Design

Overview

Using domain-driven design at the simplest level, we identified the domains and user flows essential for meeting the requirements of Wildlife AI.

Identification Of Domains

Domain identification exercise

Domain Capabilities In-depth

This exercise helped us identify crucial components that must be developed to create a comprehensive solution. Each component is designed to support a specific functionality, aligning with the Single Responsibility Principle (SRP). This approach ensures that each component within the system has a clearly defined and singular purpose, contributing to a more modular design.

User Domain places users at the forefront of the system, incorporating features like user registration, profile management and authentication. Manages storing and retrieving user profile information, ensures secure authentication procedures, and stores user preferences.

Camera Domain acts as an interface to connect to the Wildlife AI cameras with our mobile app, letting the app control the camera settings.

Multimedia Domain enables collecting and keeping photos and videos from Wildlife AI cameras. This domain allows the mobile app to save and organize the pictures and videos taken by the cameras smoothly. It makes it easy for users to store, find, and look at the images and videos captured by the Wildlife AI cameras through the app.

Notification Domain is crucial in receiving notifications from various system domains, including the camera and third-party systems. It serves as the central hub for aggregating and managing alerts within the system.

Integration Domain serves as a crucial bridge connecting the Wildlife AI business with a diverse spectrum of 3rd party services and platforms.

Summary

Through this iterative domain identification and user flow analysis, we established a robust foundation for developing the core features of the Wildlife AI system.

5. System Architecture

Our application is designed to meet the needs specified by Wildlife AI, which includes managing users, handling cameras, sending notifications, working with multimedia like photos and videos, and sharing data with our partners and vendors. To make it organized, we've assigned each domain to its own module in our proposed solution.

In addition to these domain modules, we've created a special module called the workflow module. This module can help us do complicated tasks automatically. For example, when we need to send media data to a third-party partner for their edge modeling work, it involves lots of steps like making multiple API calls and preparing the data in a specific way.

System Architecture Overview

Core Components of System Architecture

User module

The primary responsibility of the user module is managing user accounts and information that's specific to each user. People using the application can create their accounts, log in (optionally), and view their profiles, which makes the whole experience more personalized for them. Additionally, within this module, users can choose their notification preferences to decide how they want to be notified about things in the app. This way, users have control over their interaction with the application. Additionally, they can invite other users who would like to participate in the project.

Camera module

The Camera Module within our modular monolith architecture primarily serves as the interface to connect with the API provided by the Wildlife AI cameras. This allows users to adjust camera settings while they are using our application when they are physically close to the camera location. In this module, we keep very little information about the user essentially retaining only a unique user identifier associated with the camera's owner. Furthermore, this module provides the functionality to configure where notifications should be sent when the camera detects a wildlife species. Users can set their preferred notification endpoint, ensuring they are promptly informed when wildlife is spotted.

Camera module use case

Notification module

The Notification Module serves as a vital component within the Wildlife AI system, facilitating the seamless delivery of near real-time and relevant notifications to users. It plays a crucial role in timely camera notifications and ensuring that users stay informed about significant events detected by the Wildlife AI cameras. This module is responsible for sending instant alert notifications to users when a Wildlife AI camera detects the presence of target wildlife species. The notifications are designed to be concise, providing users with essential information about the detected species. In addition, users can configure to receive important camera notifications such as battery alerts and other similar issues.

Notification module use case

Multimedia module

Multimedia module encompasses handling image and video data once they are retrieved from a camera. In our application, this means that users can upload, store, retrieve, and take notes about the wildlife species they spotted in the images or videos. This module is essential because it deals with the core media files that our application relies on for integrations with other partners and vendors. If necessary, we can use CDN and other caching methods to bring data closer to the user to speed things up and make the data load faster.

Multimedia module use case

Integration module

The Integrations module allows Wildlife AI camera users to connect with various services, like camera trap labelling and expert platforms, and data sharing with the community. It achieves this by making individual plugins for each integration, making it adaptable and future-ready for adding more plugins. These plugins connect with partner APIs and help manage data interchange among partner APIs. This module uses a micro kernel architecture to support the interoperability characteristic.

Integration module use case

Workflow module

The Workflow module exposes APIs designed to efficiently manage and coordinate tasks across all the above modules within the Wildlife AI application to support certain expensive use cases.

Solution Overview

Business and system Overview

Long Term Expansions

As we envision the future evolution of the Wildlife.ai solution, we anticipate several long-term expansions that aim to enhance user experience, community collaboration, and overall system effectiveness.

  • Over time, additional features and integrations can be introduced through mobile app plugins. These plugins will utilize REST APIs to seamlessly connect with third-party services, providing users with a broader range of functionalities and options.
  • Introducing a user portal for purchasing allows users to conveniently acquire additional features, plugins, or even hardware components. This portal serves as a centralized hub for users to manage their subscriptions, make purchases, and explore new offerings.
  • A dedicated portal for creating and coordinating projects fosters community togetherness. Users can collaborate on wildlife conservation initiatives, share insights, and collectively contribute to the success of specific projects.
  • Implementing a system to track and analyze success metrics of the wildlife cameras enhances the monitoring and evaluation process. Metrics such as species identification accuracy, camera uptime, and data contribution to conservation databases can be measured.
  • Future focus on evolving the open-source ecosystem by encouraging community contributions, fostering developer engagement, and actively seeking partnerships with other open-source projects with wildlife conservation interests.

These long-term expansions align with our commitment to continuous improvement, adaptability to user needs, and the promotion of a collaborative and user-centric ecosystem within the Wildlife.ai project.

ADR's

The linked ADRs contain the primary architectural decisions regarding the proposed design, including their context and rationale.

ADR 001 Event-Driven Camera Alerts proposes implementing an event-driven architecture for camera alerts to address challenges with limited internet access and email delivery, utilizing a service similar to Google's GCP Pub/Sub for reliable and cost-effective alert communication

ADR 002 Modular monolith architecture proposes using the modular monolith architecture style to develop the application, ensuring ease of understanding, building, deploying, and modifying while being cost-effective and flexible in design.

ADR 003 Processing with 3rd Parties and Edge Computing proposes moving data processing to 3rd parties and leveraging edge computing for the Wildlife.ai project to enhance cost efficiency, sustainability, scalability, and data security while simplifying the architecture.

ADR 004 Easy of Use proposes the use of a mobile app as the primary interaction model for Wildlife.ai.

ADR 005 MicroKernel architecture to is used to provide a standard facade to connect with other partners and vendors API's and external resources.

ADR 006 To align with the ethos of transparency, sharing of code and hardware designs, building strong community involvement, and enabling a broader impact on conservation efforts.

References

  1. Software Architecture Patterns, 2nd Edition by Mark Richards
  2. Modular monolith: domain-centric design
  3. Architecture style worksheet
  4. Domain-Driven Hexagon

About

Repo for O'Reilly's Architecture Kata Competition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •