Skip to content

[Architecture/Refactor]: Implement a Centralized Service Layer for Appwrite API Integration #180

@cannonerd007

Description

@cannonerd007

Is your feature request related to a problem?

  • Yes, it is related to a problem

Describe the feature you'd like

Problem Description While contributing to AOSSIE-Org/Resonate, I noticed that the current architecture in BabyNest has some technical debt regarding how it interacts with the backend. Currently, Appwrite client initialization and database logic are scattered across various function files and UI components. This leads to:

Tight Coupling: Business logic is mixed with database calls.

Inconsistent Responses: Error handling varies between functions, making it difficult for the frontend to parse errors predictably.

Maintenance Difficulty: Collection IDs and Environment variables are repeated in multiple files.

Proposed Solution I propose to refactor BabyNest to follow the Service-Repository Pattern utilized in other AOSSIE projects like Resonate. This will involve:

Centralized Provider: Create a singleton AppwriteProvider to manage the Client and Database instances.

Domain-Specific Services: Move logic into dedicated service files (e.g., src/services/authService.js, src/services/roomService.js).

Unified Response Wrapper: Implement a standard response format (e.g., { success: boolean, data: any, error: string }) to unify how the Appwrite functions return data.

Constants Management: Move all magic strings (Collection/Database IDs) into a central configuration file.

Expected Impact This refactor will bring BabyNest up to the organizational standard of AOSSIE. It will make the codebase significantly more scalable for the GSoC 2026 cycle and simplify the onboarding process for new contributors.

Record

  • I agree to follow this project's Code of Conduct
  • I want to work on implementing this feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions