Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
107 changes: 107 additions & 0 deletions .cursor/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Scissors Project Rules

## Product Overview

Scissors is an application for versatile image formatting and processing with the following capabilities:

- Convert images between formats (PNG, JPEG/JPG, WEBP, AVIF, GIF)
- Manipulate images with features like rotation, resizing, extending, and trimming
- Apply visual effects such as grayscale, gamma adjustment, and tint
- Control output quality
- Dark/light mode and customizable theme color
- Save and restore settings (export/import)
- Built-in gallery and documentation

The product consists of multiple services:

- Frontend application (@apps/frontend) - Next.js based UI
- Processor service (@apps/processor) - Backend service for image processing
- AI service (@apps/ai) - AI-related functionality
- S3-Bridge service (@apps/s3-bridge) - Integration with S3 storage

## Project Structure

- This is a monorepo managed by Turborepo
- Applications are located in `@apps/*` directory
- Shared packages are located in `@packages/*` directory
- Each application/package should have its own package.json and tsconfig.json

## Common Rules

### General

- Node.js version: >=20 (see .nvmrc)
- Package manager: pnpm (v10.10.0)
- TypeScript is used across all packages and applications
- Follow the commitlint conventions for commit messages

### Code Style

- Use single quotes for strings
- No semicolons
- Tab width: 2 spaces
- Maximum line length: 100 characters
- Arrow function parentheses: avoid when possible
- Trailing commas: none
- Use camelCase for variables and properties

### TypeScript

- Explicit types for function parameters and return types are recommended
- Avoid using `any` when possible, but not strictly forbidden
- Use TypeScript's strict mode

## Frontend Applications (e.g., @apps/frontend)

### Framework & Libraries

- React-based applications
- Vite for bundling
- Follow component-based architecture

### Styling

- CSS Modules or styled components should be used
- Follow BEM (Block Element Modifier) methodology for class naming
- Stylelint is used for CSS linting

### Folder Structure

- `/src/components/` - Reusable UI components
- `/src/pages/` - Page components
- `/public/` - Static assets
- `/types/` - TypeScript type definitions

## Backend Applications (e.g., @apps/processor, @apps/ai, @apps/s3-bridge)

### Framework & Libraries

- Bun runtime
- Follow RESTful API design principles
- Utilize shared packages from `@packages/`

### Error Handling

- Use proper error handling and status codes
- Log errors appropriately

### API Responses

- Consistent format for API responses
- Include appropriate status codes

## Development Workflow

- Use `pnpm dev` to start development environment
- Use `pnpm build` to build all packages and applications
- Use `pnpm lint` to lint all packages and applications

## Deployment

- Frontend apps may use Vercel for deployment
- Backend services are containerized with Docker

## Testing

- Use `@packages/test-utils` for common testing utilities
- Write unit tests for critical functionality
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/node_modules
**/dist
**/git
**/.gitignore
7 changes: 5 additions & 2 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Link Bun workspace dependencies
run: bun install

- name: Build
run: pnpm build

Expand All @@ -61,8 +64,8 @@ jobs:
- name: Check New rontend
run: pnpm --filter frontend-new test

- name: Test Backend
run: pnpm --filter backend test
# - name: Test Backend
# run: pnpm --filter backend test

- name: Lint
run: pnpm lint
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
.turbo

# Environment
.env.development
.env.production
.env
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.0
22.5.1
5 changes: 3 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/dist
**/node_modules
**/coverage/
**/dist
/.idea
/.vscode
/.git
Expand Down
5 changes: 3 additions & 2 deletions @apps/ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"main": "./src/index.ts",
"type": "module",
"scripts": {
"dev": "bun --env-file=../../.env.development run --watch ./src/index.ts",
"start": "bun --env-file=../../.env.production --bun ./src/index.ts",
"dev": "bun run --watch ./src/index.ts",
"start": "bun run ./src/index.ts",
"prebuild": "tsc --noEmit",
"build": "bun build --compile --minify --sourcemap ./src/index.ts --outfile=./.out/ai"
},
"dependencies": {
"@scissors/bun-cors": "workspace:*",
"@scissors/config": "workspace:*",
"@scissors/sharp": "workspace:*"
},
"devDependencies": {
Expand Down
13 changes: 6 additions & 7 deletions @apps/ai/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { serve } from 'bun'

import { config } from '@scissors/config'
import { injectCORS } from '@scissors/bun-cors'

import { getContextForPrompt } from './mcp/context'
import { parseSettingsFromGpt } from './utils/parseSettingsFromGpt'

const PORT = Bun.env.AI_SERVER_PORT || 4201
const YA_GPT_API_KEY = Bun.env.YANDEX_CLOUD_API_KEY
const YA_GPT_FOLDER_ID = Bun.env.YANDEX_CLOUD_FOLDER
const CLIENT_API = Bun.env.CLIENT_API ?? 'http://localhost:3000'
const YA_GPT_API_KEY = config.YANDEX_CLOUD_API_KEY
const YA_GPT_FOLDER_ID = config.YANDEX_CLOUD_FOLDER
const YA_GPT_MODEL = 'yandexgpt-lite'

if (!YA_GPT_API_KEY) {
Expand Down Expand Up @@ -37,7 +36,7 @@ setInterval(() => {
// TODO: Logger
// TODO: server.requestIP
serve({
port: PORT,
port: config.AI_SERVER_PORT,
routes: injectCORS(
{
'/api/v1/completion': {
Expand Down Expand Up @@ -152,7 +151,7 @@ serve({
}
},
{
origin: CLIENT_API,
origin: config.CLIENT_API,
methods: ['POST'],
credentials: false
}
Expand All @@ -163,4 +162,4 @@ serve({
})
})

console.log(`[AI] Server is running on port ${PORT}`)
console.log(`[AI] Server is running on port ${config.AI_SERVER_PORT}`)
8 changes: 0 additions & 8 deletions @apps/ai/types/bun.d.ts

This file was deleted.

37 changes: 0 additions & 37 deletions @apps/backend/Dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions @apps/backend/eslint.config.mjs

This file was deleted.

23 changes: 0 additions & 23 deletions @apps/backend/jest.config.ts

This file was deleted.

9 changes: 0 additions & 9 deletions @apps/backend/nest-cli.json

This file was deleted.

60 changes: 0 additions & 60 deletions @apps/backend/package.json

This file was deleted.

19 changes: 0 additions & 19 deletions @apps/backend/src/app.module.ts

This file was deleted.

10 changes: 0 additions & 10 deletions @apps/backend/src/config/configuration.ts

This file was deleted.

Loading
Loading