A powerful Node.js Express backend for AI-powered jersey design analysis and search 🚀
| Feature | Description | Status |
|---|---|---|
| 🖼️ Image Upload | Secure file upload with validation | ✅ Ready |
| 🎯 Polygon Detection | YOLO-powered object detection | ✅ Ready |
| 🔍 AI Search | DINO + FAISS for similar designs | ✅ Ready |
| ✂️ Smart Cropping | Intelligent area extraction | ✅ Ready |
| 🚀 High Performance | Optimized for production | ✅ Ready |
| 🔒 CORS Security | Cross-origin request handling | ✅ Ready |
GET /api/testResponse:
{
"message": "Server is working!",
"timestamp": "2024-01-15T10:30:00.000Z",
"endpoints": ["/api/upload-image", "/api/generate-jersey", "/api/test"]
}POST /api/upload-image
Content-Type: multipart/form-data
Body: { image: File }Response:
{
"imageUrl": "/uploads/1234567890-image.jpg",
"polygons": [[[x1,y1], [x2,y2], ...]]
}POST /api/generate-jersey
Content-Type: multipart/form-data
Body: {
image: File,
area?: [[x,y], [x,y], ...],
isPolygon?: boolean
}Response:
{
"imageUrl": "/uploads/processed-image.jpg",
"message": "Similar designs found!",
"similarDesigns": [...],
"features": [...]
}git clone https://github.com/Devam0311/Server-backend.git
cd Server-backend
pnpm installCreate .env file:
# Frontend URL
FRONTEND_URL=https://localhost:8081
# FastAPI Services
FASTAPI_YOLO_URL=http://0.0.0.0:8000/yolo
FASTAPI_DINO_URL=http://0.0.0.0:8000/dino
FASTAPI_FAISS_URL=http://0.0.0.0:8000/faissnode server.cjs🌐 Server running at: http://localhost:3001
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Frontend │ │ Backend │ │ FastAPI │
│ (React) │◄──►│ (Express) │◄──►│ Services │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ File System │
│ (uploads/) │
└─────────────────┘
backend/
├── 🚀 server.cjs # Main Express server
├── 📦 package.json # Dependencies & scripts
├── 📁 uploads/ # Uploaded images (auto-created)
├── 📁 profiles/ # User profiles (auto-created)
├── 📁 catalogue/ # Design catalogue
├── 📁 src/ # Source code
│ ├── 📁 lib/ # Utilities
│ └── 📁 pages/ # API routes
└── 📄 README.md # This file
- Express - Web framework
- Multer - File upload handling
- CORS - Cross-origin resource sharing
- Axios - HTTP client
- Sharp - Image processing
- Form-data - Multipart form handling
- Node.js ≥ 18.0.0
- pnpm ≥ 8.0.0
- TypeScript support
- ESLint + Prettier
# Install dependencies
pnpm install
# Run development server
node server.cjs
# Lint code
pnpm lint
# Format code
pnpm format
# Type checking
pnpm type-check| Variable | Description | Default |
|---|---|---|
FRONTEND_URL |
Frontend application URL | https://localhost:8081 |
FASTAPI_YOLO_URL |
YOLO detection service | http://0.0.0.0:8000/yolo |
FASTAPI_DINO_URL |
DINO feature extraction | http://0.0.0.0:8000/dino |
FASTAPI_FAISS_URL |
FAISS search service | http://0.0.0.0:8000/faiss |
We love contributions! Here's how you can help:
- 🍴 Fork the repository
- 🌿 Create a feature branch (
git checkout -b feature/amazing-feature) - 💾 Commit your changes (
git commit -m 'Add amazing feature') - 📤 Push to the branch (
git push origin feature/amazing-feature) - 🔄 Open a Pull Request
Found a bug? Open an issue with:
- Bug description
- Steps to reproduce
- Expected vs actual behavior
- Environment details