Features: - Complete .NET client SDK for LittleShop API - JWT authentication with automatic token management - Catalog service for products and categories - Order service with payment creation - Retry policies using Polly for resilience - Error handling middleware - Dependency injection support - Comprehensive documentation and examples SDK Components: - Authentication service with token refresh - Strongly-typed models for all API responses - HTTP handlers for retry and error handling - Extension methods for easy DI registration - Example console application demonstrating usage Test Updates: - Fixed test compilation errors - Updated test data builders for new models - Corrected service constructor dependencies - Fixed enum value changes (PaymentStatus, OrderStatus) Documentation: - Complete project README with features and usage - Client SDK README with detailed examples - API endpoint documentation - Security considerations - Deployment guidelines Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
7.8 KiB
7.8 KiB
LittleShop E-Commerce Platform
A complete e-commerce platform built with ASP.NET Core 9.0, featuring multi-cryptocurrency payment support and a privacy-focused design.
🎯 Features
Core Functionality
- Product Management: Categories, products with photos, weight-based pricing
- Order Management: Complete order workflow from creation to delivery
- Multi-Cryptocurrency Payments: Bitcoin, Monero, USDT, Litecoin, Ethereum, Zcash, Dash, Dogecoin
- Shipping Management: Weight-based shipping rates with Royal Mail integration
- Admin Panel: Full administrative interface for managing the store
- API: RESTful API with JWT authentication for client applications
Security & Privacy
- No KYC Requirements: Privacy-focused design with minimal data collection
- Dual Authentication: Cookie-based for admin panel, JWT for API
- Self-Hosted Payments: BTCPay Server integration for cryptocurrency processing
- Secure Password Storage: PBKDF2 with 100,000 iterations
🚀 Quick Start
Prerequisites
- .NET 9.0 SDK
- SQLite (included)
- BTCPay Server instance (for payments)
Installation
- Clone the repository:
git clone https://github.com/yourusername/littleshop.git
cd littleshop
- Restore dependencies:
dotnet restore
- Run the application:
dotnet run --project LittleShop/LittleShop.csproj
- Access the application:
- Admin Panel: https://localhost:5001/Admin
- API Documentation: https://localhost:5001/swagger
- Default credentials:
admin/admin
📁 Project Structure
LittleShop/
├── LittleShop/ # Main web application
│ ├── Areas/Admin/ # Admin panel MVC
│ ├── Controllers/ # API controllers
│ ├── Services/ # Business logic
│ ├── Models/ # Database entities
│ ├── DTOs/ # Data transfer objects
│ └── Data/ # Entity Framework context
├── LittleShop.Client/ # .NET client SDK
│ ├── Services/ # API client services
│ ├── Models/ # Client models
│ └── Http/ # HTTP handlers
└── LittleShop.Tests/ # Test suite
├── Unit/ # Unit tests
├── Integration/ # API integration tests
├── Security/ # Security tests
└── UI/ # UI automation tests
💻 Using the Client SDK
Installation
dotnet add reference LittleShop.Client/LittleShop.Client.csproj
Basic Usage
using LittleShop.Client.Extensions;
// Configure services
services.AddLittleShopClient(options =>
{
options.BaseUrl = "https://localhost:5001";
options.TimeoutSeconds = 30;
options.MaxRetryAttempts = 3;
});
// Use the client
var client = serviceProvider.GetRequiredService<ILittleShopClient>();
// Authenticate
await client.Authentication.LoginAsync("admin", "admin");
// Get products
var products = await client.Catalog.GetProductsAsync();
// Create order
var order = await client.Orders.CreateOrderAsync(new CreateOrderRequest
{
IdentityReference = "CUST001",
ShippingName = "John Doe",
ShippingAddress = "123 Main St",
ShippingCity = "London",
ShippingPostCode = "SW1A 1AA",
ShippingCountry = "United Kingdom",
Items = new[] { new CreateOrderItem { ProductId = productId, Quantity = 1 } }
});
🔌 API Endpoints
Authentication
POST /api/auth/login- Login with username/passwordPOST /api/auth/refresh- Refresh JWT token
Catalog (Requires Authentication)
GET /api/catalog/categories- Get all categoriesGET /api/catalog/categories/{id}- Get category by IDGET /api/catalog/products- Get products with filteringGET /api/catalog/products/{id}- Get product by ID
Orders (Requires Authentication)
POST /api/orders- Create new orderGET /api/orders/by-identity/{id}- Get orders by customer identityGET /api/orders/{id}- Get order by IDPOST /api/orders/{id}/payments- Create crypto paymentPOST /api/orders/payments/webhook- BTCPay webhook endpoint
🗄️ Database Schema
Core Tables
- Users: Staff/admin accounts only
- Categories: Product categories
- Products: Product catalog with pricing and weight
- ProductPhotos: Product images with sorting
- Orders: Customer orders with shipping details
- OrderItems: Individual items in orders
- CryptoPayments: Cryptocurrency payment records
- ShippingRates: Weight-based shipping calculations
🧪 Testing
Run all tests:
dotnet test
Run specific test categories:
# Unit tests only
dotnet test --filter Category=Unit
# Integration tests
dotnet test --filter Category=Integration
# Security tests
dotnet test --filter Category=Security
Test Coverage
- ✅ Unit tests for all services
- ✅ Integration tests for all API endpoints
- ✅ Security tests for authentication enforcement
- ✅ UI automation tests with Playwright
🔧 Configuration
appsettings.json
{
"ConnectionStrings": {
"DefaultConnection": "Data Source=littleshop.db"
},
"Jwt": {
"Key": "YourSuperSecretKeyThatIsAtLeast32CharactersLong!",
"Issuer": "LittleShop",
"Audience": "LittleShop",
"ExpiryMinutes": 60
},
"BTCPayServer": {
"Url": "https://your-btcpay.com",
"StoreId": "your-store-id",
"ApiKey": "your-api-key"
}
}
🚢 Deployment
Production Checklist
- Update connection strings
- Configure BTCPay Server
- Set strong JWT secret key
- Enable HTTPS only
- Configure CORS for your domain
- Set up SSL certificates
- Configure logging
- Set up database backups
Docker Support
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 80 443
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet build -c Release
RUN dotnet publish -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "LittleShop.dll"]
📊 Sample Data
The application includes sample data seeder that creates:
- 3 Categories (Electronics, Clothing, Books)
- 5 Products with various prices
- 5 Shipping rates (Royal Mail options)
- 5 Sample orders in different statuses
- 3 Crypto payments demonstrating payment flow
🛡️ Security Considerations
- Authentication Required: All API endpoints require JWT authentication
- No Public Endpoints: Client applications must authenticate first
- Password Security: PBKDF2 with salt and 100,000 iterations
- Input Validation: FluentValidation on all inputs
- SQL Injection Protection: Entity Framework Core with parameterized queries
- XSS Protection: Razor view encoding and validation
- CORS: Configured for specific domains in production
📝 License
This project is proprietary software. All rights reserved.
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
📞 Support
For issues, questions, or suggestions:
- Open an issue on GitHub
- Contact: support@littleshop.com
🏗️ Built With
- ASP.NET Core 9.0 - Web framework
- Entity Framework Core - ORM
- SQLite - Database
- Bootstrap 5 - UI framework
- JWT - API authentication
- BTCPay Server - Cryptocurrency payments
- xUnit - Testing framework
- Playwright - UI automation
- Serilog - Logging
📈 Version History
- v1.0.0 - Initial release with core e-commerce functionality
- Product catalog management
- Order processing workflow
- Multi-cryptocurrency payments
- Admin panel and API
- Client SDK library
- Comprehensive test coverage