Sure thing! Here's a full-stack CRUD example—NestJS backend and React frontend using Axios—built around your original Express + Mongoose server.js setup. I’ve also included tips from real tutorials to make it smooth. Feel free to customize the data model to suit your needs (users, tasks, products, etc.). Backend: NestJS with Mongoose 1. Initialize and Set Up NestJS Project npm i -g @nestjs/cli nest new nest-backend cd nest-backend npm install @nestjs/mongoose mongoose In src/main.ts, enable CORS: import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); app.enableCors(); await app.listen(3000); } bootstrap(); Restack 2. Connect to MongoDB In src/app.module.ts: import { Module } from '@nestjs/common'; import { MongooseModule } from '@nestjs/mongoose'; import { ItemModule } from './item/item.module'; @Module({ imports: [ MongooseModule.forRoot('mongodb://localhost:27017/mydb'), ItemModule, ], }) export class AppModule {} 3. Create Item Module, Schema, Service & Controller Run: nest generate module item, nest generate service item, nest generate controller item. item.schema.ts: import { Schema, Document } from 'mongoose'; export type ItemDocument = Item & Document; export class Item { name: string; description: string; createdAt: Date; } export const ItemSchema = new Schema({ name: { type: String, required: true }, description: String, createdAt: { type: Date, default: Date.now }, }); item.module.ts: import { Module } from '@nestjs/common'; import { MongooseModule } from '@nestjs/mongoose'; import { Item, ItemSchema } from './item.schema'; import { ItemService } from './item.service'; import { ItemController } from './item.controller'; @Module({ imports: [ MongooseModule.forFeature([{ name: Item.name, schema: ItemSchema }]), ], providers: [ItemService], controllers: [ItemController], }) export class ItemModule {} item.service.ts: import { Injectable, NotFoundException } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { Item, ItemDocument } from './item.schema'; @Injectable() export class ItemService { constructor(@InjectModel(Item.name) private itemModel: Model) {} async create(data: Partial): Promise { const created = new this.itemModel(data); return created.save(); } async findAll(): Promise { return this.itemModel.find().exec(); } async findOne(id: string): Promise { const item = await this.itemModel.findById(id).exec(); if (!item) throw new NotFoundException('Item not found'); return item; } async update(id: string, data: Partial): Promise { const updated = await this.itemModel.findByIdAndUpdate(id, data, { new: true }).exec(); if (!updated) throw new NotFoundException('Item not found'); return updated; } async remove(id: string): Promise { const result = await this.itemModel.findByIdAndDelete(id).exec(); if (!result) throw new NotFoundException('Item not found'); } } item.controller.ts: import { Controller, Get, Post, Body, Param, Put, Delete } from '@nestjs/common'; import { ItemService } from './item.service'; import { Item } from './item.schema'; @Controller('items') export class ItemController { constructor(private readonly itemService: ItemService) {} @Post() create(@Body() dto: Partial) { return this.itemService.create(dto); } @Get() findAll() { return this.itemService.findAll(); } @Get(':id') findOne(@Param('id') id: string) { return this.itemService.findOne(id); } @Put(':id') update(@Param('id') id: string, @Body() dto: Partial) { return this.itemService.update(id, dto); } @Delete(':id') remove(@Param('id') id: string) { return this.itemService.remove(id); } } This gives you a working CRUD RESTful API using NestJS and Mongoose. You can refer to similar patterns at Restackio for NestJS + Mongoose CRUD examples Restack . Frontend: React + Axios 1. Create React App + Axios npx create-react-app frontend cd frontend npm install axios 2. API Service (src/services/itemService.js): import axios from 'axios'; const API = 'http://localhost:3000/items'; export const getItems = () => axios.get(API).then(res => res.data); export const createItem = (item) => axios.post(API, item).then(res => res.data); export const getItem = (id) => axios.get(`${API}/${id}`).then(res => res.data); export const updateItem = (id, item) => axios.put(`${API}/${id}`, item).then(res => res.data); export const deleteItem = (id) => axios.delete(`${API}/${id}`); 3. Components ItemForm.jsx — for create/update: import React, { useState, useEffect } from 'react'; import { createItem, updateItem, getItem } from '../services/itemService'; const ItemForm = ({ id, onSuccess }) => { const [name, setName] = useState(''); const [description, setDescription] = useState(''); useEffect(() => { if (id) { getItem(id).then(data => { setName(data.name); setDescription(data.description || ''); }); } }, [id]); const handleSubmit = async (e) => { e.preventDefault(); if (id) await updateItem(id, { name, description }); else await createItem({ name, description }); onSuccess(); setName(''); setDescription(''); }; return (
setName(e.target.value)} placeholder="Name" required />