Commit Graph

147 Commits

Author SHA1 Message Date
Oleg Proskurin b7801ef528 fix: mobile hero 2025-12-16 00:34:31 +07:00
Oleg Proskurin d9781ae3fc feat: add analytics 2025-12-16 00:24:33 +07:00
Oleg Proskurin 9679934bb8 feat: add sitemap and robots 2025-12-15 23:34:06 +07:00
Oleg Proskurin f433f59e6b feat: setup trailing slashes 2025-12-15 23:32:01 +07:00
Oleg Proskurin 9c4dd35782 feat: update description 2025-12-15 13:04:09 +07:00
Oleg Proskurin 93defca7d2 feat: add og image 2025-12-15 12:42:39 +07:00
Oleg Proskurin d746a57fa0 fix: styles 2025-12-15 12:33:13 +07:00
Oleg Proskurin ccf44af93f fix 2025-12-15 00:39:28 +07:00
Oleg Proskurin ce705efd10 remove prettier 2025-12-15 00:34:54 +07:00
Oleg Proskurin 59874d9437 fix docker 2025-12-15 00:34:45 +07:00
Oleg Proskurin 5e899419a4 fix: remove old metatags 2025-12-15 00:19:15 +07:00
Oleg Proskurin 1f4766a33d fix: viewport 2025-12-15 00:12:58 +07:00
Oleg Proskurin d1d9517926 feat: add metadata 2025-12-15 00:11:11 +07:00
Oleg Proskurin c66a82d736 feat: set homepage 2025-12-15 00:02:55 +07:00
Oleg Proskurin b5e25eacf1 chore: remove wrong files 2025-12-15 00:01:57 +07:00
Oleg Proskurin 257131c12d secure: bump next version 2025-12-14 23:55:47 +07:00
Oleg Proskurin d798faec41 ts fix 2025-12-14 18:11:20 +07:00
Oleg Proskurin 77006e8f47 fix: email storing 2025-12-14 15:02:33 +07:00
Oleg Proskurin 98d8e31373 fix: prod build 2025-12-14 14:17:25 +07:00
Oleg Proskurin 1aa7687dc9 chore: upd scripts 2025-12-14 13:39:38 +07:00
Oleg Proskurin 41f00aa352 feat: store emails 2025-12-14 13:36:34 +07:00
Oleg Proskurin 6650c03188 feat: improve input style 2025-12-14 12:14:33 +07:00
Oleg Proskurin 4a47c53a0a feat: update cards styles 2025-12-14 12:07:31 +07:00
Oleg Proskurin 986a3063bb feat: better card styles 2025-12-14 11:53:32 +07:00
Oleg Proskurin 9c428383d7 feat: styles 2025-12-05 01:38:10 +07:00
Oleg Proskurin 84b34f0115 feat: add images 2025-12-05 01:18:05 +07:00
Oleg Proskurin 3feaed33c8 feat: update hero spacing 2025-12-05 00:10:47 +07:00
Oleg Proskurin 2190a2f55f fix: width 2025-12-04 23:06:36 +07:00
Oleg Proskurin c8d6214322 refactor: split by components 2025-12-04 20:15:35 +07:00
Oleg Proskurin 988c7946b9 feat: add metal effect 2025-12-04 15:08:34 +07:00
Oleg Proskurin b2cab168bc feat: add styles to shape section 2025-12-04 14:40:42 +07:00
Oleg Proskurin 0c656d21a2 fix: ts 2025-12-04 13:18:57 +07:00
Oleg Proskurin 4f59f775ae chore: styles 2025-12-04 13:13:51 +07:00
Oleg Proskurin 7f37a5667b feat: use gloweffect 2025-12-04 13:12:16 +07:00
Oleg Proskurin d688c5890a feat: working glow 2025-12-04 12:56:12 +07:00
Oleg Proskurin 21ac410780 fix: page 2025-12-03 15:08:36 +07:00
Oleg Proskurin 7588817803 feat: add homepage v1 2025-12-03 13:09:11 +07:00
Oleg Proskurin 504b1f8395 fix: api & docs 2025-11-28 00:07:06 +07:00
Oleg Proskurin 0ca1a4576e fix: api 2025-11-26 23:32:13 +07:00
Oleg Proskurin beedac385e fix: basic 2025-11-26 00:22:34 +07:00
Oleg Proskurin 6803a23aa3 fix: basic 2025-11-26 00:11:48 +07:00
Oleg Proskurin 8623442157 fix: aliases 2025-11-25 22:47:54 +07:00
Oleg Proskurin 88cb1f2c61 fix: upload 2025-11-24 00:14:46 +07:00
Oleg Proskurin 191a745133 fix: remove url field 2025-11-23 21:28:31 +07:00
Oleg Proskurin 5e52d4ff9c fix: show image dimentions 2025-11-23 21:03:55 +07:00
Oleg Proskurin e3ddf1294f fix: prompts storage 2025-11-23 20:47:48 +07:00
Oleg Proskurin 6235736f4f fix: flow creation 2025-11-23 14:34:54 +07:00
Oleg Proskurin a92b1bf482 docs: phase 3 part 4 - comprehensive JSDoc documentation for all v1 API endpoints
Add complete JSDoc documentation to all API v1 endpoints with detailed descriptions,
parameters, returns, error codes, and usage examples (Section 12).

**Generation Endpoints (generations.ts):**
- POST / - Create generation with references, aliases, and enhancement
- GET / - List with flow/status filtering and pagination
- GET /:id - Get single generation with full relations
- PUT /:id - Update with auto-regeneration on prompt/aspectRatio change
- POST /:id/regenerate - Regenerate with exact same parameters
- POST /:id/retry - Legacy endpoint (deprecated, delegates to regenerate)
- DELETE /:id - Delete with alias protection rules

**Flow Endpoints (flows.ts):**
- GET / - List flows with computed counts and pagination
- GET /:id - Get single flow with generationCount and imageCount
- GET /:id/generations - List flow's generations with pagination
- GET /:id/images - List flow's images with pagination
- PUT /:id/aliases - Update flow-scoped aliases (JSONB merge)
- DELETE /:id/aliases/:alias - Remove specific flow alias
- POST /:id/regenerate - Regenerate most recent generation in flow
- DELETE /:id - Hard delete flow (generations/images remain)

**Image Endpoints (images.ts):**
- POST /upload - Upload with flowId logic (undefined=auto, null=none, string=specific)
- GET / - List with flow/source/alias filtering and pagination
- GET /resolve/:alias - 3-tier resolution (technical → flow → project)
- GET /:id - Get single image with complete details
- PUT /:id - Update focal point and metadata
- PUT /:id/alias - Assign project-scoped alias (Section 6.1)
- DELETE /:id - Hard delete with MinIO cleanup and cascades

**CDN Endpoints (cdn.ts):**
- GET /:orgSlug/:projectSlug/img/:filenameOrAlias - Public image serving
  - Supports filename and @alias access
  - Long-term browser caching (1 year)
  - No authentication required
- GET /:orgSlug/:projectSlug/live/:scope - Live URL generation
  - Automatic prompt-based caching
  - IP rate limiting (10/hour, cache hits excluded)
  - Lazy scope creation
  - Scope generation limits
  - Cache key from prompt + params
  - X-Cache-Status: HIT|MISS headers

**Scope Management Endpoints (scopes.ts):**
- POST / - Create scope manually with settings
- GET / - List with currentGenerations stats and pagination
- GET /:slug - Get single scope by slug with stats
- PUT /:slug - Update settings (allowNewGenerations, limits)
- POST /:slug/regenerate - Regenerate specific image or all in scope
- DELETE /:slug - Delete scope with cascading image deletion

**JSDoc Standards Applied:**
- Complete function descriptions with use cases
- @route method and path
- @authentication requirements and key types
- @rateLimit specifications where applicable
- @param detailed parameter descriptions with types and optionality
- @returns status codes with response descriptions
- @throws error codes with explanations
- @example realistic usage examples with request/response samples
- @deprecated tags for legacy endpoints

**Documentation Features:**
- Comprehensive parameter descriptions
- Default values clearly indicated
- Type information for all parameters
- Error code documentation
- Multiple examples per complex endpoint
- Response header documentation
- Cache behavior explanations
- Flow logic documentation
- Alias resolution precedence details
- Rate limiting specifics

All JSDoc follows standardized format for consistent API documentation
across the entire v1 API surface. Zero new TypeScript errors introduced.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 23:32:13 +07:00
Oleg Proskurin fa65264410 feat: phase 3 part 3 - scope management and IP rate limiting
Implement comprehensive live scope management API and IP-based rate limiting
for live URL generation endpoints (Sections 8.5 and 8.6).

**Scope Management CRUD Endpoints:**
- POST /api/v1/live/scopes - Create scope manually with slug validation
- GET /api/v1/live/scopes - List scopes with pagination and stats
- GET /api/v1/live/scopes/:slug - Get single scope by slug with stats
- PUT /api/v1/live/scopes/:slug - Update scope settings
- POST /api/v1/live/scopes/:slug/regenerate - Regenerate scope images
- DELETE /api/v1/live/scopes/:slug - Delete scope with cascading image deletion

**Scope Management Features:**
- Slug format validation (alphanumeric, hyphens, underscores)
- Duplicate slug prevention with 409 Conflict response
- Scope statistics (currentGenerations, lastGeneratedAt)
- Settings management (allowNewGenerations, newGenerationsLimit)
- Regeneration support (single image or all images in scope)
- Hard delete with image cleanup following alias protection rules
- All endpoints require Project Key authentication

**IP-Based Rate Limiting:**
- In-memory rate limit store with automatic cleanup
- Limits: 10 new generations per hour per IP address
- Only cache MISS (new generation) counts toward limit
- Cache HIT does NOT count toward limit
- X-Forwarded-For header support for proxy/load balancer setups
- Rate limit headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
- Retry-After header on 429 Too Many Requests response
- Automatic cleanup of expired entries every 5 minutes

**IP Rate Limiter Middleware:**
- ipRateLimiterMiddleware attaches to live URL endpoint
- getClientIp() extracts IP from X-Forwarded-For or req.ip
- checkIpRateLimit() validates and increments counter
- getRemainingRequests() returns available request count
- getResetTime() returns seconds until reset
- Middleware attaches checkIpRateLimit function to request
- Rate limit check executed AFTER cache check (only for cache MISS)

**Type System Updates:**
- Added LiveScopeResponse interface with all scope fields
- Added LiveScopeWithImagesResponse with images array
- Added response type aliases for all CRUD operations
- Added toLiveScopeResponse() converter function
- Added CreateLiveScopeRequest, UpdateLiveScopeRequest interfaces
- Added ListLiveScopesQuery with pagination parameters
- Added RegenerateScopeRequest with optional imageId

**Route Integration:**
- Mounted scopes router at /api/v1/live/scopes
- Applied ipRateLimiterMiddleware to live URL endpoint
- Rate limit increments only on cache MISS (new generation)
- Cache HIT bypasses rate limit check entirely

**Technical Notes:**
- All scope endpoints return toLiveScopeResponse() format
- Pagination using buildPaginationMeta helper
- Bracket notation for meta field access (TypeScript strict mode)
- Proper number parsing with fallback defaults
- All Phase 3 Part 3 code is fully type-safe with zero TypeScript errors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 23:15:29 +07:00
Oleg Proskurin 1f768d4761 feat: phase 3 part 2 - CDN endpoints with live URL caching system
Implement public CDN endpoints for serving images and live URL generation
with intelligent caching based on prompt hashing.

**CDN Routes (Section 8):**
- **GET /cdn/:orgSlug/:projectSlug/img/:filenameOrAlias**
  - Public endpoint (no authentication)
  - Serve images by filename or project-scoped alias
  - Resolves org and project from slugs
  - Supports @alias syntax or filename lookup
  - Returns image bytes with 1-year cache headers
  - Headers: Content-Type, Content-Length, Cache-Control, X-Image-Id

- **GET /cdn/:orgSlug/:projectSlug/live/:scope**
  - Public endpoint (no authentication)
  - Live URL generation with caching
  - Query params: prompt, aspectRatio, autoEnhance, template
  - Cache key: SHA-256(projectId + scope + prompt + params)
  - Cache HIT: Returns cached image immediately
  - Cache MISS: Generates new image, caches, returns
  - Scope management: auto-create or check limits
  - Image meta tracking: scope, isLiveUrl, cacheKey
  - Headers: X-Cache-Status (HIT/MISS), X-Scope, X-Image-Id, X-Generation-Id

**Cache Key Helper:**
- computeLiveUrlCacheKey() - SHA-256 hash for live URL caching
- computePromptHash() - SHA-256 hash for prompt caching
- Normalized parameters for consistent cache keys

**Live URL Flow (Section 8.3):**
1. Validate prompt and scope format (alphanumeric + hyphens + underscores)
2. Resolve org, project from slugs
3. Compute cache key from params
4. Check cache via images.meta.cacheKey
5. If HIT: serve cached image
6. If MISS: check scope limits, generate, cache, serve
7. Lazy scope creation with project defaults
8. Enforce newGenerationsLimit per scope

**Service Exports:**
- Added LiveScopeService to core services index
- Available for dependency injection

**App Routing:**
- Mounted CDN router at /cdn (public, before auth routes)
- CDN endpoints are completely public (no API key required)

**Technical Notes:**
- Images tagged with meta: { scope, isLiveUrl: true, cacheKey }
- Scope statistics computed from images with matching meta
- Cache controlled via Cache-Control: public, max-age=31536000
- System generations use apiKeyId: null
- All code compiles with zero new TypeScript errors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 22:57:44 +07:00