A full-stack CRUD application for managing Customers, Products, Orders, and Items.
- Customers: Create, read, update, and delete customer records
- Products: Manage product catalog with pricing and stock information
- Orders: Create and manage orders with multiple items
- Items: Manage order items with product relationships
- Backend: Node.js, Express.js, Prisma ORM, SQLite
- Frontend: React.js, React Router, Axios
- Database: SQLite (can be easily switched to PostgreSQL)
crud-app/
├── server/ # Backend Express server
│ ├── prisma/ # Database schema and migrations
│ ├── index.js # Express server and API routes
│ └── .env # Environment variables
├── client/ # React frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── api.js # API client functions
│ │ └── App.js # Main app component
│ └── public/
└── package.json # Root package.json
From the root directory, run:
npm run install-allOr install manually:
# Root dependencies
npm install
# Server dependencies
cd server
npm install
# Client dependencies
cd ../client
npm installNavigate to the server directory and initialize the database:
cd server
# Generate Prisma Client
npm run prisma:generate
# Run database migrations
npm run prisma:migrateThis will create a SQLite database file at server/prisma/dev.db.
From the root directory, you can start both the server and client simultaneously:
npm run devOr start them separately:
# Terminal 1 - Start backend server (runs on port 5000)
npm run server
# Terminal 2 - Start frontend (runs on port 3000)
npm run client- Frontend: http://localhost:3000
- Backend API: http://localhost:5000/api
GET /api/customers- Get all customersGET /api/customers/:id- Get customer by IDPOST /api/customers- Create a new customerPUT /api/customers/:id- Update a customerDELETE /api/customers/:id- Delete a customer
GET /api/products- Get all productsGET /api/products/:id- Get product by IDPOST /api/products- Create a new productPUT /api/products/:id- Update a productDELETE /api/products/:id- Delete a product
GET /api/orders- Get all ordersGET /api/orders/:id- Get order by IDPOST /api/orders- Create a new orderPUT /api/orders/:id- Update an orderDELETE /api/orders/:id- Delete an order
GET /api/items- Get all itemsGET /api/items/:id- Get item by IDPOST /api/items- Create a new itemPUT /api/items/:id- Update an itemDELETE /api/items/:id- Delete an item
The current API implementation is a basic CRUD API. The following features are not currently implemented:
- Swagger/OpenAPI Documentation: No API documentation is available
- Pagination: All list endpoints return all records without pagination support
- Optimistic Locking: No version field or conflict detection for concurrent updates
- Filtering: No query parameter support for filtering results (e.g.,
?name=John) - Sorting: No support for sorting results by field (e.g.,
?sort=name&order=asc)
- Customer: id, name, email, phone, address
- Product: id, name, description, price, stock
- Order: id, customerId, status, total
- Item: id, orderId, productId, quantity, price
To view and edit the database using Prisma Studio:
cd server
npm run prisma:studioThis will open a web interface at http://localhost:5555 where you can view and edit your database records.
The server uses a .env file located in the server/ directory:
DATABASE_URL="file:./dev.db"
PORT=5000
This application was developed using an AI-assisted development workflow. Based on the codebase structure and commit history, the development process appears to have followed this pattern:
The application was initially created from a basic prompt requesting a full-stack CRUD application for managing Customers, Orders, Items, and Products. This initial prompt generated:
- The core entity structure (Customers, Products, Orders, Items)
- Full-stack implementation with React frontend and Express backend
- Prisma ORM with SQLite database
- Complete CRUD API endpoints for all entities
- Basic React components for managing each entity type
- Database schema with proper relationships between entities
Initial application state (November 19, 2025)
Application during development (November 19, 2025)
Following the initial creation, the application underwent several iterations to fix bugs and improve functionality:
- Nested Items Fix: A bug fix was applied to address issues with nested items display or functionality
- Order Total Calculation: Server-side calculation logic was refined to properly compute order totals
- UI/UX Improvements: The user interface was refined for better usability and consistency
Bug fix for nested items issue
The application has evolved into a functional full-stack CRUD application with:
- Clean, consistent UI components with shared styling
- Proper entity relationships and data integrity
- Server-side order total calculations
- Complete CRUD operations for all entities
This development process demonstrates the iterative nature of AI-assisted development, where an initial comprehensive prompt creates the foundation, followed by targeted prompts to fix specific issues and refine functionality.
- The application uses SQLite for simplicity, but can be easily switched to PostgreSQL or MySQL by updating the Prisma schema and DATABASE_URL.
- When creating an order, you can add multiple items at once.
The Order Total is calculated server-side in the backend (server/index.js), not in the frontend. The total represents the sum of all item subtotals (item price × quantity) for all items in an order.
The calculation iterates through all items provided in the request, fetches the corresponding product from the database to get the current product price (unless a specific price is provided in the item data), and sums up itemPrice × quantity for each item. The calculated total is stored in the Order.total field in the database.
Implementation Details:
- Calculation happens in
POST /api/orders(lines 169-186) andPUT /api/orders/:idwhen items are included (lines 220-237) - For each item, the system fetches the product to retrieve its current price (unless overridden by
item.price) - The total is computed before creating/updating the order record
- All items from the request body are processed to calculate the total
The Order Total is automatically calculated and updated for the following operations:
- ✅ POST /api/orders: Total is calculated from all items provided in the request
- ✅ PUT /api/orders/:id (when
itemsarray is included): Total is recalculated from the new items array (existing items are deleted first, then new items are created)
Important Limitations:
The Order Total is NOT automatically updated for the following operations:
- ❌ PUT /api/orders/:id (when only
customerIdorstatusare updated withoutitems): Total remains unchanged - ❌ POST /api/items: Creating a new item does not update the parent order's total
- ❌ PUT /api/items/:id: Updating an item (quantity, price, etc.) does not update the parent order's total
- ❌ DELETE /api/items/:id: Deleting an item does not update the parent order's total
Note: To keep the order total accurate when using individual Item CRUD endpoints, you would need to manually recalculate and update the order total separately, or use the PUT /api/orders/:id endpoint with the complete items array instead.
Yes, updates to Order Total require reading/processing all items that will be associated with the order:
- When calculating the total in
POST /api/ordersorPUT /api/orders/:id, the system processes all items from the request body and performs a database query to fetch each product's price (one query per unique product in the items array) - For
PUT /api/orders/:idwith items, the system does not read existing items from the database - it deletes all existing items first, then calculates the total from the new items array provided in the request - The calculation is O(n) where n is the number of items, with additional O(m) database queries where m is the number of unique products