AI-Powered Dockerfile Generator Backend API
- 🤖 AI-powered Dockerfile generation for JavaScript frameworks (React, Next.js, Vue, Angular)
- 🐳 Automatic Docker image building with real Docker commands
- 🔍 GitHub repository analysis and tech stack detection
- 📝 Syntax validation and error handling
- 📊 Real-time progress tracking with status updates
- 💾 Generation history and result management
- Backend: Node.js + Express.js + TypeScript
- Database: MongoDB + Mongoose
- AI Agent: Google Gemini 2.0 Flash + LangChain.js ReAct Agent
- Containerization: Docker + Docker API
- Node.js (v18 or higher)
- MongoDB (running locally or cloud)
- Docker (for building images)
- Google Gemini API key
- GitHub Personal Access Token
# Install dependencies
npm install
# Create environment file
cp .env.example .envCreate a .env file in the backend directory:
# Google Gemini Configuration
GEMINI_API_KEY=your_gemini_api_key_here
# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017/dockgen
# GitHub Configuration
GITHUB_TOKEN=your_github_token_here
# Server Configuration
PORT=3001
NODE_ENV=development
# CORS Configuration
FRONTEND_URL=http://localhost:3000# Start development server
npm run dev
# Build for production
npm run build
# Start production server
npm startPOST /api/generation/generate- Start Dockerfile generationGET /api/generation/status/:id- Get generation statusGET /api/generation/history- Get generation historyPOST /api/generation/push-dockerfile- Push Dockerfile to repository
GET /health- Backend health check
- RESTful API with TypeScript
- MongoDB integration with Mongoose
- GitHub API integration for repository fetching
- Google Gemini 2.0 Flash for AI-powered analysis
- Docker API integration for image building
- Error handling and logging
- Repository Analysis - Fetch and analyze GitHub repository
- Tech Stack Detection - Identify frameworks and dependencies
- Dockerfile Generation - Create optimized Dockerfile
- Image Building - Build actual Docker image
- Result Storage - Save results to database
npm run build
npm startGEMINI_API_KEY=your_production_gemini_key
MONGODB_URI=your_production_mongodb_uri
GITHUB_TOKEN=your_github_token
PORT=3001
NODE_ENV=production
FRONTEND_URL=https://your-frontend-domain.com- Health checks at
/healthendpoint - Generation status tracking
- Error logging and debugging
- Performance metrics for AI operations
- GitHub token validation
- CORS configuration
- Input sanitization
- Error message sanitization
- Rate limiting (recommended for production)
# Test backend API
curl http://localhost:3001/health
# Test generation endpoint
curl -X POST http://localhost:3001/api/generation/generate \
-H "Content-Type: application/json" \
-d '{"githubUrl":"https://github.com/username/repo","githubToken":"your_token"}'- Routes: Add routes in
src/routes/ - Services: Add business logic in
src/services/ - Models: Add database models in
src/models/
- TypeScript for type safety
- ESLint for code quality
- Prettier for code formatting
- Conventional commits for version control