Base URL
All API requests should be made to:The API is configured to run on port 5002 by default. Ensure the API server is running before making requests.
API documentation
Interactive API documentation is available through Swagger UI when running in development mode:CORS configuration
The API is configured with a permissive CORS policy called “ElectronPolicy” to support the Electron frontend application:- Allowed Origins: Any origin
- Allowed Methods: Any HTTP method
- Allowed Headers: Any header
This CORS configuration is intended for local development. Consider restricting origins in production environments.
Health checks
The API provides health check endpoints for monitoring system status:General health
Readiness check
Liveness check
Response format
All API responses follow a consistent format using theApiResponse<T> wrapper:
Success response
Error response
Features
Logging and monitoring
The API includes comprehensive logging using Serilog:- Console logging: Real-time logs in the terminal
- File logging: JSON-formatted logs in
logs/comprehensive-{date}.json - Request logging: All HTTP requests are logged via
RequestLoggingMiddleware - Global exception handling: Centralized error handling via
GlobalExceptionMiddleware
Database migrations
The API automatically applies Entity Framework migrations on startup, ensuring the database schema is always up to date.Static file serving
The API serves static files from theuploads directory at /uploads/*. This is used for product images and other uploaded content.
The uploads directory is automatically created if it doesn’t exist when the API starts.
Key services
The API includes several core services:- User Activity Service: Tracks all user actions and maintains an audit log
- PIN Security Service: Handles PIN hashing and verification with automatic migration from legacy plaintext PINs
- Metrics Service: Collects business intelligence metrics for analytics
- Supabase Backup Service: Manages database backups to Supabase
- Secure Configuration Service: Handles secure environment variable management
Default credentials
On first run, the API creates a default manager account:- Employee ID: 0001
- PIN: 1234
- Role: Manager
Change the default PIN immediately after first login for security purposes.