Fix refill-only colors to have 0 spools instead of 1

- Add migration to correct 14 colors that should be refill-only
- Create helper script for applying the fix
- Add frontend tracking for refill-only colors
- Update README with current project state
- Add development guidance documentation
This commit is contained in:
DaX
2025-08-05 23:05:24 +02:00
parent 4020bb4ab8
commit 5d1d05574f
5 changed files with 423 additions and 16 deletions

View File

@@ -9,19 +9,24 @@ A web application for tracking Bambu Lab filament inventory with automatic color
- 📊 **Sortable Columns** - Click headers to sort by any column
- 🌈 **Gradient Support** - Special handling for gradient filaments like Cotton Candy Cloud
- 📱 **Responsive Design** - Works on desktop and mobile devices
- 💰 **Sale Management** - Bulk sale pricing with countdown timers
- 🔐 **Admin Panel** - Protected dashboard for inventory management
- 📦 **Spool Types** - Support for both regular and refill spools
## Technology Stack
- **Frontend**: React + TypeScript + Tailwind CSS
- **Backend**: Next.js API routes
- **Infrastructure**: AWS Amplify (Frankfurt region)
- **Frontend**: Next.js + React + TypeScript + Tailwind CSS
- **Backend**: Node.js API server (Express)
- **Database**: PostgreSQL (AWS RDS)
- **Infrastructure**: AWS Amplify (Frontend), EC2 (API), RDS (Database)
- **IaC**: Terraform
## Prerequisites
- Node.js 18+ and npm
- AWS Account
- Terraform 1.0+
- PostgreSQL (for local development)
- AWS Account (for deployment)
- Terraform 1.0+ (for infrastructure)
- GitHub account
## Setup Instructions
@@ -39,7 +44,15 @@ cd filamenteka
npm install
```
### 3. Deploy with Terraform
### 3. Environment Setup
Create a `.env.local` file for local development:
```bash
NEXT_PUBLIC_API_URL=http://localhost:4000/api
```
### 4. Deploy with Terraform
```bash
cd terraform
@@ -56,22 +69,30 @@ terraform apply
```bash
# Run development server
npm run dev
# Run tests
npm test
# Run linting
npm run lint
# Check for security issues
npm run security:check
```
Visit http://localhost:5173 to see the app.
Visit http://localhost:3000 to see the app.
## Table Format
The filament table should have these columns:
- **Brand** - Manufacturer (e.g., BambuLab)
The filament table displays these columns:
- **Tip** - Material type (e.g., PLA, PETG, ABS)
- **Finish** - Finish type (e.g., Basic, Matte, Silk)
- **Boja** - Color name (e.g., Mistletoe Green, Hot Pink)
- **Refill** - Whether it's a refill spool
- **Vakum** - Vacuum sealed status
- **Otvoreno** - Opened status
- **Količina** - Quantity
- **Cena** - Price
- **Refill** - Number of refill spools
- **Spulna** - Number of regular spools
- **Količina** - Total quantity (refill + spulna)
- **Cena** - Price per unit
- **Sale** - Active sale percentage and end date
## Color Mapping
@@ -95,9 +116,19 @@ git push origin main
Amplify will automatically build and deploy your changes.
## Admin Panel
Access the admin panel at `/upadaj` for:
- Managing filament inventory
- Adding/editing/deleting filaments
- Managing color definitions and pricing
- Bulk sale management
## Adding New Colors
To add new color mappings, edit `src/data/bambuLabColors.ts`:
Colors can be managed through:
1. **Admin Panel**: Navigate to `/upadaj/colors` to add colors via UI
2. **Code**: Edit `src/data/bambuLabColors.ts` for frontend color display:
```typescript
export const bambuLabColors: Record<string, ColorMapping> = {
@@ -106,13 +137,47 @@ export const bambuLabColors: Record<string, ColorMapping> = {
};
```
## Database Migrations
Run database migrations:
```bash
# Run all pending migrations
npm run migrate
# Clear migration history (development only)
npm run migrate:clear
```
## API Deployment
Deploy API server updates:
```bash
# Use the deployment script
./scripts/deploy-api.sh
# Or deploy manually to EC2 instance
```
## Troubleshooting
### Color Not Showing
- Check if the color name matches exactly
- Check if the color name matches exactly in the database
- Ensure color exists in `colors` table
- Add the color mapping to `bambuLabColors.ts`
- Colors are case-insensitive but spelling must match
### Build Errors
- Run `npm run test:build` to verify build succeeds
- Check TypeScript errors with `npx tsc --noEmit`
- Ensure all environment variables are set
### Database Connection Issues
- Verify PostgreSQL is running
- Check connection string in environment variables
- Ensure database migrations have been run
## License
MIT