Skip to content
implementing-service-layer logo

Appwrite Service Layer Pattern

implementing-service-layer

Defines a pattern for abstracting Appwrite database calls into dedicated service files. Use to keep components clean and reusable.

itsmeAlee/Tourly20installs0stars

SKILL.md

Full skill instructions

Appwrite Service Layer Pattern

When to use this skill

  • Before writing database logic in a component.
  • When a database query needs to be reused across multiple pages or actions.

Folder Structure

  • services/​tours.ts
  • services/​bookings.ts
  • services/​auth.ts

Example Pattern

import { databases, DATABASE_ID, COLLECTIONS } from '@/​lib/​appwrite';
import { Query } from 'appwrite';
import { Tour } from '@/​types';

export const TourService = {
    async getAll(limit = 10) {
        return await databases.listDocuments<Tour>(
            DATABASE_ID,
            COLLECTIONS.TOURS,
            [Query.limit(limit), Query.orderDesc('$createdAt')]
        );
    },
    async getById(id: string) {
        return await databases.getDocument<Tour>(DATABASE_ID, COLLECTIONS.TOURS, id);
    }
};

Instructions

  • Abstraction: Components should call TourService.getAll() rather than the Appwrite SDK directly.
  • Error Handling: Catch errors in the service or re-throw them with descriptive messages.

More skills from itsmeAlee

optimizing-iconography logo
itsmeAlee/Tourly2

optimizing-iconography

Rules for using icons efficiently to maintain performance. Use when adding icons from Lucide React.

0 0
View
handling-data-fetching logo
itsmeAlee/Tourly2

handling-data-fetching

Strategy for fetching data using React Server Components (RSC) and managing cache. Use for initial page loads and SEO-optimized data.

0 0
View
managing-design-system logo
itsmeAlee/Tourly2

managing-design-system

Defines the core visual identity, color tokens, interaction patterns, and signature UI layouts for Tourly. Use when implementing or styling any frontend component to ensure brand consistency.

0 0
View

Advanced code-splitting and lazy-loading techniques. Use to reduce initial bundle size and speed up the homepage.

0 0
View
refactoring-codebase logo
itsmeAlee/Tourly2

refactoring-codebase

Guidelines for maintaining a clean codebase through limits and abstraction. Use when a file or component becomes difficult to read.

0 0
View

Advanced middleware logic for security and routing. Use for global rate limiting, security headers, and protection of admin routes.

0 0
View
managing-seo-metadata logo
itsmeAlee/Tourly2

managing-seo-metadata

Strategies for dynamic SEO using Next.js Metadata API. Use to generate social share cards and search-engine-friendly titles for tours.

0 0
View
handling-global-errors logo
itsmeAlee/Tourly2

handling-global-errors

Unified strategy for catching and displaying API and network errors. Use throughout the application logic.

0 0
View
managing-date-time logo
itsmeAlee/Tourly2

managing-date-time

Standardizes date handling and timezone logic (UTC/PKT) for travel bookings. Use when displaying or saving tour dates.

0 0
View

Subscribes to Appwrite Realtime events for live updates. Use when building dashboards or live booking counters.

0 0
View
architecting-components logo
itsmeAlee/Tourly2

architecting-components

Defines rules for Atomic Design and separating logic from UI. Use when creating new components in the src directory.

0 0
View

Guidelines for creating efficient database indexes in Appwrite. Use to ensure search and filter operations stay fast.

0 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View