Add new Bambu Lab colors and update documentation
Add three new filament colors to support Wood and Matte finishes: - Classic Birch (PLA Wood) - #E8D5B7 - Rosewood (PLA Wood) - #472A22 - Desert Tan (PLA Matte) - #E8DBB7 Update CLAUDE.md with improved documentation: - Enhanced architecture details - Added color requests schema - Expanded deployment and database sections - Added testing and security details
This commit is contained in:
88
CLAUDE.md
88
CLAUDE.md
@@ -1,6 +1,6 @@
|
|||||||
# CLAUDE.md
|
# CLAUDE.md
|
||||||
|
|
||||||
This file provides guidance for AI-assisted development in this repository.
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
|
||||||
## Project Overview
|
## Project Overview
|
||||||
|
|
||||||
@@ -22,20 +22,19 @@ Filamenteka is a 3D printing filament inventory management system for tracking B
|
|||||||
```bash
|
```bash
|
||||||
# Development
|
# Development
|
||||||
npm run dev # Start Next.js development server (port 3000)
|
npm run dev # Start Next.js development server (port 3000)
|
||||||
npm run build # Build static export to /out directory
|
npm run build # Build static export to /out directory
|
||||||
npm run lint # Run ESLint
|
npm run lint # Run ESLint
|
||||||
npm test # Run Jest tests
|
npm test # Run Jest tests
|
||||||
|
npm run test:watch # Run Jest in watch mode
|
||||||
|
|
||||||
# Security & Quality
|
# Security & Quality
|
||||||
npm run security:check # Check for credential leaks
|
npm run security:check # Check for credential leaks
|
||||||
npm run test:build # Test if build succeeds
|
npm run test:build # Test if build succeeds
|
||||||
|
./scripts/pre-commit.sh # Runs security, build, and test checks (use before commits)
|
||||||
|
|
||||||
# Database Migrations
|
# Database Migrations
|
||||||
npm run migrate # Run pending migrations
|
npm run migrate # Run pending migrations
|
||||||
npm run migrate:clear # Clear migration history
|
npm run migrate:clear # Clear migration history
|
||||||
|
|
||||||
# Pre-commit Hook
|
|
||||||
./scripts/pre-commit.sh # Runs security, build, and test checks
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
@@ -47,18 +46,26 @@ npm run migrate:clear # Clear migration history
|
|||||||
- `/page.tsx` - Admin login
|
- `/page.tsx` - Admin login
|
||||||
- `/dashboard/page.tsx` - Filament CRUD operations
|
- `/dashboard/page.tsx` - Filament CRUD operations
|
||||||
- `/colors/page.tsx` - Color management
|
- `/colors/page.tsx` - Color management
|
||||||
|
- `/requests/page.tsx` - Customer color requests
|
||||||
|
- `/src` - Source files
|
||||||
|
- `/components` - React components
|
||||||
|
- `/services/api.ts` - Axios instance with auth interceptors
|
||||||
|
- `/data` - Color definitions (bambuLabColors.ts, bambuLabColorsComplete.ts)
|
||||||
|
- `/types` - TypeScript type definitions
|
||||||
|
|
||||||
### API Structure
|
### API Structure
|
||||||
- `/api` - Node.js Express server (runs on EC2)
|
- `/api` - Node.js Express server (runs on EC2, port 80)
|
||||||
- `/server.js` - Main server file
|
- `/server.js` - Main Express server with all routes inline
|
||||||
- `/routes` - API endpoints for filaments, colors, auth
|
|
||||||
- Database: PostgreSQL on AWS RDS
|
- Database: PostgreSQL on AWS RDS
|
||||||
|
- Endpoints: `/api/login`, `/api/filaments`, `/api/colors`, `/api/sale/bulk`, `/api/color-requests`
|
||||||
|
|
||||||
### Key Components
|
### Key Components
|
||||||
- `FilamentTableV2` - Main inventory display with sorting/filtering
|
- `FilamentTableV2` - Main inventory display with sorting/filtering
|
||||||
- `SaleManager` - Bulk sale management interface
|
- `SaleManager` - Bulk sale management interface
|
||||||
- `ColorCell` - Smart color rendering with gradient support
|
- `ColorCell` - Smart color rendering with gradient support
|
||||||
- `EnhancedFilters` - Advanced filtering system
|
- `EnhancedFilters` - Advanced filtering system
|
||||||
|
- `ColorRequestForm` - Customer color request form
|
||||||
|
- `ColorRequestModal` - Modal for color requests
|
||||||
|
|
||||||
### Data Models
|
### Data Models
|
||||||
|
|
||||||
@@ -90,22 +97,41 @@ colors: {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Color Requests Schema
|
||||||
|
```sql
|
||||||
|
color_requests: {
|
||||||
|
id: UUID,
|
||||||
|
color_name: VARCHAR(255), # Requested color name
|
||||||
|
message: TEXT, # Customer message
|
||||||
|
contact_name: VARCHAR(255), # Customer name (required)
|
||||||
|
contact_phone: VARCHAR(50), # Customer phone (required)
|
||||||
|
status: VARCHAR(20), # Status: pending, reviewed, fulfilled
|
||||||
|
created_at: TIMESTAMP
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
### Frontend (AWS Amplify)
|
### Frontend (AWS Amplify)
|
||||||
- Automatic deployment on push to main branch
|
- Automatic deployment on push to main branch
|
||||||
- Build output: Static files in `/out` directory
|
- Build output: Static files in `/out` directory
|
||||||
- Config: `amplify.yml`, `next.config.js` (output: 'export')
|
- Config: `amplify.yml`, `next.config.js` (output: 'export')
|
||||||
|
- Security check runs during build (amplify.yml preBuild phase)
|
||||||
|
|
||||||
### API Server (EC2)
|
### API Server (EC2)
|
||||||
- Manual deployment via `scripts/deploy-api.sh`
|
- Manual deployment via `scripts/deploy-api.sh` or `scripts/deploy-api-update.sh`
|
||||||
- Server: `3.71.161.51`
|
- Server: `3.71.161.51`
|
||||||
- Domain: `api.filamenteka.rs`
|
- Domain: `api.filamenteka.rs`
|
||||||
|
- Service: `node-api` (systemd)
|
||||||
|
- IMPORTANT: When deploying API, remember to build for AMD64 Linux (not ARM macOS)
|
||||||
|
|
||||||
### Database (RDS PostgreSQL)
|
### Database (RDS PostgreSQL)
|
||||||
- Host: `filamenteka.ci7fsdlbzmag.eu-central-1.rds.amazonaws.com`
|
- Host: `filamenteka.ci7fsdlbzmag.eu-central-1.rds.amazonaws.com`
|
||||||
|
- User: `filamenteka_admin`
|
||||||
|
- Database: `filamenteka`
|
||||||
- Migrations in `/database/migrations/`
|
- Migrations in `/database/migrations/`
|
||||||
- Schema in `/database/schema.sql`
|
- Schema in `/database/schema.sql`
|
||||||
|
- Use `scripts/update-db-via-aws.sh` for running migrations on production
|
||||||
|
|
||||||
## Important Patterns
|
## Important Patterns
|
||||||
|
|
||||||
@@ -127,7 +153,10 @@ colors: {
|
|||||||
### Testing
|
### Testing
|
||||||
- Jest + React Testing Library
|
- Jest + React Testing Library
|
||||||
- Tests in `__tests__/` directory
|
- Tests in `__tests__/` directory
|
||||||
|
- Config: `jest.config.js`, `jest.setup.js`
|
||||||
- Coverage goal: >80%
|
- Coverage goal: >80%
|
||||||
|
- Run with `npm test` or `npm run test:watch`
|
||||||
|
- Tests include: component tests, API integration tests, data consistency checks
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
@@ -135,27 +164,38 @@ colors: {
|
|||||||
# Frontend (.env.local)
|
# Frontend (.env.local)
|
||||||
NEXT_PUBLIC_API_URL=https://api.filamenteka.rs/api
|
NEXT_PUBLIC_API_URL=https://api.filamenteka.rs/api
|
||||||
|
|
||||||
# API Server
|
# API Server (.env in /api directory)
|
||||||
DATABASE_URL=postgresql://...
|
DATABASE_URL=postgresql://filamenteka_admin:PASSWORD@filamenteka.ci7fsdlbzmag.eu-central-1.rds.amazonaws.com:5432/filamenteka
|
||||||
JWT_SECRET=...
|
JWT_SECRET=...
|
||||||
|
ADMIN_PASSWORD=...
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
PORT=80
|
||||||
```
|
```
|
||||||
|
|
||||||
## Security Considerations
|
## Security Considerations
|
||||||
|
|
||||||
- Admin routes protected by JWT authentication
|
- Admin routes protected by JWT authentication (24h expiry)
|
||||||
- Password hashing with bcrypt
|
- Password hashing with bcrypt (for future multi-user support)
|
||||||
- SQL injection prevention via parameterized queries
|
- SQL injection prevention via parameterized queries
|
||||||
- Credential leak detection in pre-commit hooks
|
- Credential leak detection in pre-commit hooks (`scripts/security/security-check.js`)
|
||||||
- CORS configured for production domains only
|
- CORS configured to allow all origins (update for production hardening)
|
||||||
|
- Auth token interceptors handle 401/403 automatically
|
||||||
|
- Pre-commit hook runs security checks, build tests, and unit tests
|
||||||
|
|
||||||
## Database Operations
|
## Database Operations
|
||||||
|
|
||||||
When modifying the database:
|
When modifying the database:
|
||||||
1. Create migration file in `/database/migrations/`
|
1. Create migration file in `/database/migrations/` with sequential numbering
|
||||||
2. Test locally first
|
2. Test locally first
|
||||||
3. Run migration on production via scripts
|
3. Run migration on production:
|
||||||
4. Update corresponding TypeScript types
|
- Use `scripts/update-db-via-aws.sh` for remote execution
|
||||||
|
- Or use `npm run migrate` for local/scripted execution
|
||||||
|
4. Update corresponding TypeScript types in `/src/types/`
|
||||||
|
|
||||||
|
Important database constraints:
|
||||||
|
- `filaments.boja` has foreign key to `colors.name` (ON UPDATE CASCADE)
|
||||||
|
- `filaments.kolicina` has check constraint: `kolicina = refill + spulna`
|
||||||
|
- Always update `colors` table first before adding filaments with new colors
|
||||||
|
|
||||||
## Terraform Infrastructure
|
## Terraform Infrastructure
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export const bambuLabColors: Record<string, ColorMapping> = {
|
|||||||
'Charcoal': { hex: '#000000' },
|
'Charcoal': { hex: '#000000' },
|
||||||
'Cherry Pink': { hex: '#E9B6CC' },
|
'Cherry Pink': { hex: '#E9B6CC' },
|
||||||
'Chocolate': { hex: '#4A3729' },
|
'Chocolate': { hex: '#4A3729' },
|
||||||
|
'Classic Birch': { hex: '#E8D5B7' },
|
||||||
'Clay Brown': { hex: '#8E621A' },
|
'Clay Brown': { hex: '#8E621A' },
|
||||||
'Clear': { hex: '#FAFAFA' },
|
'Clear': { hex: '#FAFAFA' },
|
||||||
'Clear Black': { hex: '#5A5161' },
|
'Clear Black': { hex: '#5A5161' },
|
||||||
|
|||||||
Reference in New Issue
Block a user