Clean up obsolete resources and update documentation

- Remove all DynamoDB-related scripts and data files
- Remove AWS SDK dependencies from scripts
- Update environment files to remove DynamoDB/Lambda references
- Update PROJECT_STRUCTURE.md to reflect current architecture
- Clean up Terraform variables and examples
- Add PLA Matte to special pricing (3999 RSD / 3499 RSD refill)
- Make all table columns sortable
- Remove old Terraform state backups
- Remove temporary data import files
This commit is contained in:
DaX
2025-06-20 16:30:10 +02:00
parent 33a40072b7
commit b97032bf0c
14 changed files with 77 additions and 2386 deletions

View File

@@ -1,7 +1,7 @@
# Project Structure
## Overview
Filamenteka is organized with clear separation between environments, infrastructure, and application code.
Filamenteka is organized with clear separation between frontend, API, and infrastructure code.
## Directory Structure
@@ -10,53 +10,55 @@ filamenteka/
├── app/ # Next.js app directory
│ ├── page.tsx # Main page
│ ├── layout.tsx # Root layout
── admin/ # Admin pages
├── page.tsx # Admin login
── dashboard/ # Admin dashboard
└── globals.css # Global styles
── upadaj/ # Admin pages
├── page.tsx # Admin login
── dashboard/ # Filament management
└── colors/ # Color management
├── src/ # Source code
│ ├── components/ # React components
│ │ ├── FilamentTable.tsx
│ │ ├── FilamentForm.tsx
│ │ ── ColorCell.tsx
│ │ ├── FilamentTableV2.tsx
│ │ ├── EnhancedFilters.tsx
│ │ ── ColorSwatch.tsx
│ │ ├── InventoryBadge.tsx
│ │ └── MaterialBadge.tsx
│ ├── types/ # TypeScript types
│ │ ── filament.ts
├── data/ # Data and utilities
│ └── bambuLabColors.ts
│ │ ── filament.ts
│ └── filament.v2.ts
├── services/ # API services
│ │ └── api.ts
│ └── styles/ # Component styles
│ ├── index.css
│ └── select.css
├── lambda/ # AWS Lambda functions
│ ├── filaments/ # Filaments CRUD API
│ ├── index.js
│ └── package.json
│ └── auth/ # Authentication API
│ ├── index.js
│ └── package.json
├── api/ # Node.js Express API
│ ├── server.js # Express server
│ ├── migrate.js # Database migration script
── package.json # API dependencies
│ └── Dockerfile # Docker configuration
├── terraform/ # Infrastructure as Code
── environments/ # Environment-specific configs
│ │ ├── dev/
│ │ └── prod/
│ ├── main.tf # Main Terraform configuration
│ ├── dynamodb.tf # DynamoDB tables
│ ├── lambda.tf # Lambda functions
│ ├── api_gateway.tf # API Gateway
│ └── variables.tf # Variable definitions
├── database/ # Database schemas
── schema.sql # PostgreSQL schema
├── scripts/ # Utility scripts
│ ├── data-import/ # Data import tools
│ ├── import-pdf-data.js
│ └── clear-dynamo.js
│ ├── security/ # Security checks
├── terraform/ # Infrastructure as Code
│ ├── main.tf # Main configuration
│ ├── vpc.tf # VPC and networking
├── rds.tf # PostgreSQL RDS
│ ├── ec2-api.tf # EC2 for API server
│ ├── alb.tf # Application Load Balancer
│ ├── ecr.tf # Docker registry
│ ├── cloudflare-api.tf # Cloudflare DNS
│ └── variables.tf # Variable definitions
├── scripts/ # Utility scripts
│ ├── security/ # Security checks
│ │ └── security-check.js
│ └── build/ # Build scripts
│ └── pre-commit.sh # Git pre-commit hook
├── config/ # Configuration files
│ └── environments.js # Environment configuration
├── config/ # Configuration files
│ └── environments.js # Environment configuration
└── public/ # Static assets
└── public/ # Static assets
```
## Environment Files
@@ -64,23 +66,25 @@ filamenteka/
- `.env.development` - Development environment variables
- `.env.production` - Production environment variables
- `.env.local` - Local overrides (not committed)
- `.env.development.local` - Local dev overrides (not committed)
## Key Concepts
### Environments
- **Development**: Uses `dev` API Gateway stage and separate DynamoDB table
- **Production**: Uses `production` API Gateway stage and main DynamoDB table
### Architecture
- **Frontend**: Next.js static site hosted on AWS Amplify
- **API**: Node.js Express server running on EC2
- **Database**: PostgreSQL on AWS RDS
- **HTTPS**: Application Load Balancer with ACM certificate
### Data Flow
1. Frontend (Next.js) → API Gateway → Lambda Functions → DynamoDB
2. Authentication via JWT tokens stored in localStorage
3. Real-time data updates every 5 minutes
1. Frontend (Next.js) → HTTPS API (ALB) → Express Server (EC2) → PostgreSQL (RDS)
2. Authentication via JWT tokens
3. Real-time database synchronization
### Infrastructure
- Managed via Terraform
- Separate resources for dev/prod
- AWS services: DynamoDB, Lambda, API Gateway, Amplify
- AWS services: RDS, EC2, ALB, VPC, ECR, Amplify
- Cloudflare for DNS management
- Docker for API containerization
## Development Workflow
@@ -89,28 +93,27 @@ filamenteka/
npm run dev
```
2. **Deploy to Dev**
2. **Deploy Infrastructure**
```bash
cd terraform
terraform apply -var-file=environments/dev/terraform.tfvars
terraform apply
```
3. **Deploy to Production**
```bash
cd terraform
terraform apply -var-file=environments/prod/terraform.tfvars
```
3. **Deploy API Updates**
- API automatically pulls latest Docker image every 5 minutes
- Or manually: SSH to EC2 and run deployment script
## Data Management
## Database Management
### Import Data from PDF
### Run Migrations
```bash
node scripts/data-import/import-pdf-data.js
cd api
npm run migrate
```
### Clear DynamoDB Table
### Connect to Database
```bash
node scripts/data-import/clear-dynamo.js
psql postgresql://user:pass@rds-endpoint/filamenteka
```
## Security
@@ -118,4 +121,6 @@ node scripts/data-import/clear-dynamo.js
- No hardcoded credentials
- JWT authentication for admin
- Environment-specific configurations
- Pre-commit security checks
- Pre-commit security checks
- HTTPS everywhere
- VPC isolation for backend services