A modern, high-performance backend API built with Bun and Hono for managing products and users in an admin dashboard system. This project showcases a robust architecture using cutting-edge technologies for building scalable SAAS applications.
-
Authentication System
- User registration with email validation
- Secure login with session management
- Password hashing using Argon2id
- Role-based access control (Admin/User)
-
Product Management
- CRUD operations for products
- Category-based organization
- Stock tracking and alerts
- Advanced product statistics
- Multi-type product support (Electronics, Clothing, Furniture, Food)
-
Data Validation & Security
- Request validation using Zod
- Type-safe database operations with DrizzleORM
- SQLite with WAL mode for better concurrency
- CORS protection
- Bun - Ultra-fast JavaScript runtime and package manager
- Hono - Lightweight, ultrafast web framework
- DrizzleORM - TypeScript ORM with great developer experience
- SQLite - Reliable, embedded database
- Zod - TypeScript-first schema validation
-
Clone the repository:
git clone https://github.com/yourusername/admin-dashboard-api.git cd admin-dashboard-api -
Install dependencies:
bun install
-
Generate and apply database migrations:
bun drizzle-kit generate bun drizzle-kit migrate
Start the development server:
bun run serverThe API will be available at http://localhost:5000.
-
POST
/signup{ "email": "admin@admin.com", "password": "Admin345678.", "username": "admin" }
-
POST
/signin{ "email": "admin@admin.com", "password": "Admin345678." }
-
POST
/signout -
GET
/me
-
POST
/products/create{ "name": "Product Name", "type": "electronics" | "clothing" | "furniture" | "food", "price": 999.99, "description": "Product description", "category": "smartphones" | "laptops" | "accessories" | ..., "stock": 100 }
-
GET
/products- List all products -
GET
/products/summary- Get product statistics -
GET
/products/:id- Get product details -
PUT
/products/:id- Update product -
DELETE
/products/:id- Delete product
admin-dashboard-api/
├── db/
│ ├── migrations/ # Database migrations
│ ├── schema.ts # Database schema definitions
│ └── index.ts # Database configuration
├── routes/
│ ├── products.ts # Product routes
│ └── users.ts # User routes
├── schema/
│ ├── product-schema.ts # Product validation
│ └── user-schema.ts # User validation
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
├── index.ts # Application entry point
└── drizzle.config.ts # DrizzleORM configuration
-
View database contents:
bun drizzle-studio
-
Generate new migrations:
bun drizzle-kit generate
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Built with ❤️ by Adrian Beria