Tuesday, 2 June 2026

Build POS Application in PHP MySQL using Gemini CLI and GEMINI.md File

In this tutorial series, I have shown how to build a complete Point of Sale, or POS, web application using PHP, MySQL, Bootstrap 5, PDO, JavaScript, jQuery DataTables, Gemini CLI, and a powerful GEMINI.md instruction file.

The main purpose of this project is to show how we can use AI coding tools in a practical real-world workflow. Instead of writing long prompts again and again, we can write our project rules, coding style, folder structure, database rules, authentication rules, and module requirements inside a GEMINI.md file. After that, Gemini CLI can read those instructions and generate better project-specific output with shorter prompts.

In this POS application series, we started from the basic project setup and directory structure. Then we created the MySQL database structure, PHP PDO database connection, login system, role-based dashboard layout, category management, user management, product management, order management, print order, cancel order, and finally the POS analytics dashboard.

This project is beginner friendly but also follows a practical real project structure. The POS app includes Admin and Staff roles. Admin users can access dashboard, users, categories, products, orders, and analytics. Staff users can access only the order module and their own order analytics where required. This makes the project useful for learning authentication, access control, CRUD modules, server-side DataTables, order processing, and dashboard reporting.

The final part of this tutorial series is focused on building the POS analytics dashboard using Gemini CLI and GEMINI.md. In the analytics dashboard, we generate top summary cards, sales charts, category-wise sales chart, top selling products table, and recent orders DataTable. Admin users can view all analytics data, while Staff users can view only their own related order analytics.

If you are following my YouTube tutorial series, you can copy the GEMINI.md instruction file and all prompts from this article. Use them step by step inside Gemini CLI to build your own PHP MySQL POS application. This will help you understand how to guide AI properly using a context file, how to divide a big project into small prompts, and how to generate code module by module.

This article contains the complete GEMINI.md file instruction and all prompts used in the POS application tutorial series. You can copy each prompt and run it in Gemini CLI according to the video part you are following.

Before using these prompts, create your project folder, open it in terminal, add the GEMINI.md file in the root directory, and then run Gemini CLI from the same project directory. After that, use the prompts one by one to generate your POS application step by step.





GEMINI.md Instruction File


Add this as a separate section in your article. On most websites, code blocks automatically show a copy button if your theme or plugin supports it.

	
# POS Application Project

## Project Overview
This project is a Point of Sale (POS) web application.

## Tech Stack
- PHP 8
- MySQL
- PDO for database connection
- Bootstrap 5
- Vanilla JavaScript
- jQuery DataTables

## Goal
Build this POS project step by step.
For now, only focus on project setup and directory structure.

## Directory Structure Rules
Use a simple and clean folder structure.
Create folders for:
- config
- assets
- includes
- modules
- uploads

Inside assets, create:
- css
- js
- images

Inside modules, create:
- dashboard
- categories
- users
- products
- orders
- analytics

## Coding Style
- Keep code simple and beginner friendly
- Use clean and readable naming
- Keep structure suitable for real project use
- Do not generate full application code unless asked

## Response Style
- Keep output short and practical
- Explain only when needed
- Follow the project structure defined above

## Database Design Rules
- Design database only for current required modules
- Current modules: users, categories, products, orders
- Use MySQL table structure
- Use proper primary keys
- Use foreign keys where needed
- Add useful indexes for better performance
- Keep column names simple and readable
- Use created_at and updated_at fields where needed
- Keep structure suitable for real project usage
- Do not create unnecessary tables unless required

## Authentication and Access Rules
- Use PHP 8 with PDO
- Use session for login state
- Store logged-in user data in session
- Support two roles: Admin and Staff
- Admin can access Dashboard, User, Category, Product, and Order modules
- Staff can access only Order module
- Protect internal pages from direct access without login
- Redirect logged-in users based on role
- Keep authentication code simple, clean, and beginner friendly
- Use Bootstrap 5 for UI

## Category Module Rules
- Category module is accessible only by Admin users
- Use jQuery DataTables with server-side processing for category listing
- Use Bootstrap 5 Modal for Add and Edit forms
- Category name is required
- Do not insert duplicate category name
- Do not update category name to an already existing value
- Keep code simple, clean, and beginner friendly

## User Module Rules
- User module is accessible only by Admin users
- Use jQuery DataTables with server-side processing for user listing
- Use Bootstrap 5 Modal for Add and Edit forms
- Name, Email, and Password are required while adding user
- Email must be unique
- Do not insert duplicate email
- Do not update email to an already existing value in another record
- Name, Email, and Password fields are required
- Keep code simple, clean, and beginner friendly

## Product Module Rules
- Product module is accessible only by Admin users
- Use jQuery DataTables with server-side processing for product listing
- Product add page path: modules/products/add.php
- Product edit page path: modules/products/edit.php
- Use separate pages for Add and Edit product
- Product fields: Category, Name, Description, Price, Quantity, Image
- All required fields must have frontend validation
- Product name must be unique within the selected category
- Upload image to uploads directory if image is provided
- Keep code simple, clean, and beginner friendly

## Order Module Rules
- Order module is accessible by Admin and Staff users
- All order module files must be inside modules/orders
- Use jQuery DataTables with server-side processing for order listing
- Order list columns: Order Number, Date, Amount, Status, Created By, Actions
- Actions: Cancel and Print
- Create New Order page should use POS-style layout
- Left side: categories and active products
- Right side: selected order items table
- Use Vanilla JavaScript for real-time quantity and total updates
- Save order data into orders and order_items tables
- Store logged-in user_id as created_by
- Print order should open in new tab as HTML view
- Keep code simple, clean, and beginner friendly

## Analytics Dashboard Rules
- Dashboard file path: modules/dashboard/index.php
- Admin can view all analytics data
- Staff can view only their own order analytics
- Use Bootstrap 5 for dashboard UI
- Use Chart.js for charts
- Use jQuery DataTables with server-side processing for recent orders
- Show clear summary cards, charts, and tables
- Keep code simple, clean, and beginner friendly
    

All Gemini CLI Prompts


Prompt 1: Make Working Directory Structure



Read GEMINI.md and generate only the project directory structure for this POS web application.

Do not generate application code.
Only create a clean beginner-friendly folder structure suitable for a real project.


Prompt 2: Make MySQL Table Structure



Read GEMINI.md and design the MySQL database structure for this POS web application.

Current modules to include:
- User
- Category
- Product
- Order

Requirements:
- Create a clean and optimized table structure
- Use proper primary keys
- Use foreign keys where needed
- Add useful indexes for better performance
- Keep column names simple and readable
- Include created_at and updated_at fields where needed
- Keep the structure beginner friendly and suitable for a real project

Output:
- Generate MySQL CREATE TABLE queries


Prompt 3: Make PHP PDO Database Connection File



Read GEMINI.md and generate a simple PHP PDO database connection file for this POS project.

Requirements:
- Create the file inside config directory
- Use PHP 8 and PDO
- Keep code simple and beginner friendly
- Add basic try catch error handling
- Use clean variable names
- Do not generate extra files


Prompt 4: Generate Login System



Read GEMINI.md and use the existing database structure from config/database.sql.

Now Create Login System for this POS application.

Requirements:
- index.php in root should show login form first
- validate user from users table using email, password, role, and status
- store logged-in user data in session
- Admin should access Dashboard, User, Category, Product, and Order modules
- Staff should access only Order module
- Dashboard should have header, sidebar, and main content area
- sidebar links should be shown based on logged-in user role


Prompt 5: Generate Dashboard Layout



Based on GEMINI.md and login flow, now generate the POS Dashboard code.

Requirements:
- Use Bootstrap 5 responsive UI
- Top header:
  - Left side: POS Application name
  - Right side: logged-in username and logout option
- Left sidebar:
  - show module links based on logged-in user role
- Main content area:
  - load selected module content
- Admin should see Dashboard, User, Category, Product, and Order links
- Staff should see only Order link
- Keep dashboard layout simple, clean, and practical for a real project


Prompt 6: Insert Sample User Data



Read GEMINI.md and review the users table from config/database.sql.

Generate MySQL sample INSERT statements for the users table to add:
- one Admin record
- one Sub User record

Requirements:
- Use realistic demo data
- Use unique email addresses
- Set correct role for each record
- Set status as active
- Include all required fields from the users table
- Keep output simple and ready to run in MySQL
- Do not generate CREATE TABLE query
- Do not generate explanation, only SQL


Prompt 7: Make Category Module



Read GEMINI.md and use the existing POS project structure.

Requirements:
- Module path: modules/categories/
- Category list page: modules/categories/index.php
- Admin only access
- Use jQuery DataTables with server-side processing
- Add Category with Bootstrap Modal
- Edit Category with Bootstrap Modal
- Include frontend and backend validation


Prompt 8: Make User Module



Read GEMINI.md and use the existing POS project structure.

Requirements:
- Create user list page at modules/users/index.php
- Load user data using jQuery DataTables
- Use server-side processing
- Show name, email, role, status, and action buttons
- Add Edit button in each row
- Restrict page access to Admin only
- Use Bootstrap 5 UI
- Name, Email, and Password fields are required
- Keep code simple and beginner friendly

Provide code file by file with file names clearly mentioned.


Prompt 9: Generate Product List with DataTables



Read GEMINI.md and use the existing POS project structure.

Requirements:
- Create product list page at modules/products/index.php
- Load product data using jQuery DataTables
- Use server-side processing
- Show category, product name, price, quantity, status, and action buttons
- Add Edit button in each row
- Restrict page access to Admin only
- Use Bootstrap 5 UI
- Keep code simple and beginner friendly
- Do not create code for add and Edit product data

Provide code file by file with file names clearly mentioned.


Prompt 10: Generate Add Product Page and Insert Logic



Now generate the Add Product feature for this POS application.

Requirements:
- Create add product page at modules/products/add.php
- Use a clean Bootstrap 5 form
- Fields: Category, Name, Description, Price, Quantity, Image
- Add frontend validation for required fields
- Add backend validation to check that product name is unique within the selected category
- Upload image to uploads directory if provided
- Insert data into products table
- Restrict this feature to Admin only
- Keep code simple, clean, and beginner friendly
- Do not create code for Edit product data

Provide code file by file with file names clearly mentioned.





Prompt 11: Generate Edit Product Page and Update Logic



Now generate the Edit Product feature for this POS application.

Requirements:
- Add Edit button in each product row
- Redirect to modules/products/edit.php?id=:product_id
- Load existing product data in pre-filled form
- Use Bootstrap 5 form UI
- Apply frontend validation
- Apply backend validation
- Do not update if product name already exists in the same category for another record
- Update product data in MySQL table
- Support image update if a new image is uploaded
- Restrict this feature to Admin only
- Keep code simple and beginner friendly

Provide code file by file with file names clearly mentioned.


Prompt 12: Generate Order List with DataTables



Read GEMINI.md and use the existing POS project structure.

Requirements:
- Create order list page inside modules/orders
- Load order data using jQuery DataTables
- Use server-side processing
- Columns: Order Number, Date, Amount, Status, Created By, Actions
- Actions should include Cancel and Print
- Allow access to Admin and Staff users
- Use Bootstrap 5 UI
- Keep code simple and beginner friendly

Provide code file by file with file names clearly mentioned.


Prompt 13: Generate Create New Order POS UI



Now generate the Create New Order page for this POS application.

Requirements:
- Create POS-style order page inside modules/orders
- Left side:
  - show categories for filtering products
  - show active products with image, name, and price
  - on product click, add product to order table on right side
- Right side:
  - order table columns: Product Name, Quantity, Unit Price, Total
  - increase and decrease quantity
  - remove item option
  - show final total amount
- Use Vanilla JavaScript for real-time updates
- Allow access to Admin and Staff users
- Keep UI simple, clean, and beginner friendly

Provide code file by file with file names clearly mentioned.







Prompt 14: Save Order into Orders and Order Items



Now generate the backend logic to save a new order in this POS application.

Requirements:
- Save order data into orders table
- Save order item data into order_items table
- Store logged-in user_id as created_by
- Save total amount in orders table
- Save product, quantity, unit price, and total in order_items table
- Keep code simple, clean, and beginner friendly
- Allow access to Admin and Staff users

Provide code file by file with file names clearly mentioned.


Prompt 15: Generate Cancel Order Feature



Now generate the Cancel Order feature for this POS application.

Requirements:
- Add Cancel option in order list
- Update order status in MySQL table
- Keep feature simple and practical
- Allow access to Admin and Staff users
- Keep code beginner friendly

Provide code file by file with file names clearly mentioned.


Prompt 16: Generate Print Order Feature



Now generate the Print Order feature for this POS application.

Requirements:
- Add Print button in order list
- Open order details in new tab as HTML view
- Show order number, date, items, quantity, price, and total
- Add browser print button support
- Keep layout simple, clean, and printable
- Allow access to Admin and Staff users
- Keep code beginner friendly

Provide code file by file with file names clearly mentioned.


Prompt 17: Generate Top Summary Cards



Read GEMINI.md and use the existing POS project structure.

now generate the top summary cards for the analytics dashboard.

Requirements:
- Dashboard file: modules/dashboard/index.php
- Use Bootstrap 5 responsive cards
- Show:
  - Today’s Sales
  - Total Orders Today
  - Total Revenue This Month
  - Total Products
  - Total Categories
  - Total Users
- Admin should see all analytics data
- Staff should see only their own order analytics where applicable
- Keep code simple and beginner friendly

Provide code file by file with file names clearly mentioned.


Prompt 18: Generate Sales Chart



Now generate the sales chart for the analytics dashboard.

Requirements:
- Use Chart.js
- Display last 30 days sales day-wise
- Use bar chart
- Dashboard file: modules/dashboard/index.php
- Admin should see all sales data
- Staff should see only their own sales data
- Keep code simple, clean, and beginner friendly

Provide code file by file with file names clearly mentioned.


Prompt 19: Generate Category-Wise Sales Chart



Now generate the category-wise sales chart for the analytics dashboard.

Requirements:
- Use Chart.js doughnut chart
- Show total sales per category
- Dashboard file: modules/dashboard/index.php
- Admin should see all category sales data
- Staff should see only their own related sales data
- Keep code simple, clean, and beginner friendly

Provide code file by file with file names clearly mentioned.


Prompt 20: Generate Top Selling Products Table



Now generate the Top Selling Products section for the analytics dashboard.

Requirements:
- Show top 5 products in table format
- Include product name and total sales
- Dashboard file: modules/dashboard/index.php
- Admin should see all product sales data
- Staff should see only their own related sales data
- Use Bootstrap 5 table UI
- Keep code simple and beginner friendly

Provide code file by file with file names clearly mentioned.


Prompt 21: Generate Recent Orders DataTable



Now generate the Recent Orders section for the analytics dashboard.

Requirements:
- Use jQuery DataTables
- Use server-side processing
- Columns: Order Number, Date, Amount, Status
- Dashboard file: modules/dashboard/index.php
- Admin should see all recent orders
- Staff should see only their own recent orders
- Keep code simple, clean, and beginner friendly

Provide code file by file with file names clearly mentioned.



0 comments:

Post a Comment