# crud-operations-fullstack > Complete CRUD (Create, Read, Update, Delete) operations implementation across frontend, backend, and database layers. Provides a comprehensive workflow for building full-stack CRUD applications with proper data flow, validation, and error handling. - Author: Bashar Sheikh - Repository: bashartech/Local_Deployment - Version: 20260207130827 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-07 - Source: https://github.com/bashartech/Local_Deployment - Web: https://mule.run/skillshub/@@bashartech/Local_Deployment~crud-operations-fullstack:20260207130827 --- --- name: "crud-operations-fullstack" description: "Complete CRUD (Create, Read, Update, Delete) operations implementation across frontend, backend, and database layers. Provides a comprehensive workflow for building full-stack CRUD applications with proper data flow, validation, and error handling." version: "1.0.0" --- # Full-Stack CRUD Operations Skill ## When to Use - Building full-stack applications with data management capabilities - Implementing Create, Read, Update, Delete operations for entities - Setting up frontend-backend communication for data operations - Creating database-backed applications with user interfaces - Establishing proper data validation and error handling across layers ## Procedure ### 1. Frontend Implementation 1. Create data models and TypeScript interfaces for entities 2. Implement API client for backend communication 3. Build reusable UI components for CRUD operations 4. Create forms with validation and error handling 5. Implement data fetching and state management 6. Add loading states and user feedback mechanisms ### 2. Backend Implementation 1. Design RESTful API endpoints for CRUD operations 2. Implement request validation and sanitization 3. Create service layer for business logic 4. Implement proper authentication and authorization 5. Add error handling and logging 6. Set up database connection and query execution ### 3. Database Implementation 1. Design database schema with proper relationships 2. Create migration files for schema changes 3. Implement database models/entities 4. Set up connection pooling and optimization 5. Add indexes for performance optimization 6. Implement data validation at database level ### 4. Integration and Testing 1. Connect frontend to backend API 2. Test all CRUD operations end-to-end 3. Implement proper error handling across layers 4. Add security measures and input validation 5. Set up monitoring and logging 6. Document API endpoints and data structures ## Output Format ### Frontend Components Structure ``` components/ ├── forms/ │ ├── EntityCreateForm.tsx │ ├── EntityEditForm.tsx │ └── EntityDeleteModal.tsx ├── lists/ │ └── EntityList.tsx ├── items/ │ └── EntityItem.tsx └── shared/ ├── LoadingSpinner.tsx └── ErrorMessage.tsx ``` ### Backend API Structure ``` routes/ ├── entities/ │ ├── create.py │ ├── read.py │ ├── update.py │ └── delete.py services/ ├── entity_service.py └── validation_service.py models/ ├── entity_model.py └── request_models.py ``` ### Database Schema Structure ``` tables/ ├── entities ├── relationships └── indexes migrations/ ├── 001_create_entities_table.sql ├── 002_add_indexes.sql └── 003_add_relationships.sql ``` ## Complete CRUD Implementation Guide ### Frontend CRUD Implementation #### 1. Entity Model Definition ```typescript // types/entity.ts export interface BaseEntity { id: number; createdAt: Date; updatedAt: Date; } export interface Entity extends BaseEntity { title: string; description?: string; status: 'active' | 'inactive' | 'archived'; priority: 'low' | 'medium' | 'high'; dueDate?: Date; tags: string[]; } export interface CreateEntityRequest { title: string; description?: string; status?: 'active' | 'inactive'; priority?: 'low' | 'medium' | 'high'; dueDate?: Date; tags?: string[]; } export interface UpdateEntityRequest { title?: string; description?: string; status?: 'active' | 'inactive' | 'archived'; priority?: 'low' | 'medium' | 'high'; dueDate?: Date; tags?: string[]; } ``` #### 2. API Client Implementation ```typescript // lib/api-client.ts import axios from 'axios'; const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api'; interface ApiResponse { data: T; message?: string; error?: string; } class ApiClient { private client = axios.create({ baseURL: API_BASE_URL, headers: { 'Content-Type': 'application/json', }, }); // Add authentication token to requests setAuthToken(token: string) { this.client.defaults.headers.common['Authorization'] = `Bearer ${token}`; } removeAuthToken() { delete this.client.defaults.headers.common['Authorization']; } // Create Entity async createEntity(entity: CreateEntityRequest): Promise> { try { const response = await this.client.post('/entities', entity); return { data: response.data }; } catch (error: any) { return { data: {} as Entity, error: error.response?.data?.message || error.message }; } } // Read All Entities async getEntities( page: number = 1, limit: number = 10, filters?: { status?: string; priority?: string; search?: string } ): Promise> { try { const params = new URLSearchParams({ page: page.toString(), limit: limit.toString(), ...(filters?.status && { status: filters.status }), ...(filters?.priority && { priority: filters.priority }), ...(filters?.search && { search: filters.search }), }); const response = await this.client.get(`/entities?${params}`); return { data: response.data }; } catch (error: any) { return { data: { entities: [], total: 0, page: 1, pages: 1 }, error: error.response?.data?.message || error.message }; } } // Read Single Entity async getEntity(id: number): Promise> { try { const response = await this.client.get(`/entities/${id}`); return { data: response.data }; } catch (error: any) { return { data: {} as Entity, error: error.response?.data?.message || error.message }; } } // Update Entity async updateEntity(id: number, entity: UpdateEntityRequest): Promise> { try { const response = await this.client.put(`/entities/${id}`, entity); return { data: response.data }; } catch (error: any) { return { data: {} as Entity, error: error.response?.data?.message || error.message }; } } // Delete Entity async deleteEntity(id: number): Promise> { try { await this.client.delete(`/entities/${id}`); return { data: undefined }; } catch (error: any) { return { data: undefined, error: error.response?.data?.message || error.message }; } } } export const apiClient = new ApiClient(); ``` #### 3. Form Components with Validation ```tsx // components/forms/EntityCreateForm.tsx import React, { useState } from 'react'; import { CreateEntityRequest, Entity } from '@/types/entity'; import { apiClient } from '@/lib/api-client'; interface EntityCreateFormProps { onSuccess?: (entity: Entity) => void; onCancel?: () => void; } export const EntityCreateForm: React.FC = ({ onSuccess, onCancel }) => { const [formData, setFormData] = useState({ title: '', description: '', status: 'active', priority: 'medium', dueDate: undefined, tags: [], }); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [tagInput, setTagInput] = useState(''); const handleChange = (e: React.ChangeEvent) => { const { name, value } = e.target; setFormData(prev => ({ ...prev, [name]: value })); }; const handleAddTag = () => { if (tagInput.trim() && !formData.tags.includes(tagInput.trim())) { setFormData(prev => ({ ...prev, tags: [...prev.tags, tagInput.trim()] })); setTagInput(''); } }; const handleRemoveTag = (tag: string) => { setFormData(prev => ({ ...prev, tags: prev.tags.filter(t => t !== tag) })); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(null); try { const result = await apiClient.createEntity(formData); if (result.error) { setError(result.error); } else if (result.data) { onSuccess?.(result.data); } } catch (err) { setError('Failed to create entity'); } finally { setLoading(false); } }; return (