8000 GitHub - arfanadam/my-shop: Astro-based e-commerce store with product management, search functionality, and admin dashboard · GitHub
[go: up one dir, main page]

Skip to content
arfanadamPublic

About

Astro-based e-commerce store with product management, search functionality, and admin dashboard

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

My Shop

An Astro-based shop API with SQLite backend and Zod validation.

🚀 Getting Started

npm install
npm run dev

📦 Project Structure

/
├── data/                 # SQLite database (auto-created)
│   └── shop.db
├── public/
├── src/
│   ├── lib/
│   │   ├── db.ts          # SQLite connection & schema
│   │   ├── errors.ts      # Error response helpers
│   │   └── schema.ts      # Zod validation schemas
│   └── pages/
│       ├── api/
│       │   └── products.ts # Products CRUD API
│       └── index.astro
├── seed.ts               # Database seeding script
└── package.json

🗄️ Database

SQLite with better-sqlite3 (WAL mode enabled).

  • Default path: ./data/shop.db
  • Override: Set DATABASE_PATH env variable

Products Table

Column Type Constraints
id INTEGER PRIMARY KEY AUTOINCREMENT
name TEXT NOT NULL
description TEXT DEFAULT ''
price REAL NOT NULL, CHECK > 0
category TEXT DEFAULT 'uncategorized'
image_url TEXT DEFAULT ''
stock INTEGER DEFAULT 0, CHECK >= 0
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP

Seed Database

npx tsx seed.ts

🔌 API Endpoints

All endpoints return JSON. Base URL: http://localhost:4321/api/products

Method Description Query Params Body (JSON)
GET List all products page, limit —
GET Search products q, category, page, limit —
POST Create product — name, price, stock, description, category, image_url
PUT Update product id Partial product fields
DELETE Delete product id —

🧞 Commands

All commands run from the root of the project:

Command Action
npm install Installs dependencies
npm run dev Starts local dev server at localhost:4321
npm run build Build your production site to ./dist/
npm run preview Preview your build locally, before deploying
npm run astro ... Run CLI commands like astro add, astro check

About

Astro-based e-commerce store with product management, search functionality, and admin dashboard

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0