A full-stack web application that uses artificial intelligence to detect faces in images. Built with React.js frontend, Node.js/Express backend, and powered by Clarifai's face detection API.
- AI-Powered Face Detection: Detect multiple faces in uploaded images or URLs
- Real-time Processing: Instant face detection with visual bounding boxes
- File Upload Support: Upload images directly or provide image URLs
- Image Compression: Automatic optimization for large images (5MB+ handling)
- User Authentication: Firebase-based sign up/sign in system
- Responsive Design: Modern UI with animated particle backgrounds
- Glass-morphism Effects: Beautiful gradient animations and modern styling
- RESTful API: Clean backend architecture with Express.js
The application serves both frontend and backend on a single port for easy deployment.
- React.js (18.2.0) - UI framework
- React Router - Client-side routing
- Firebase - Authentication
- OGL - WebGL particles background
- Tachyons - CSS framework
- Node.js - Runtime environment
- Express.js - Web framework
- Clarifai API - AI face detection
- CORS - Cross-origin resource sharing
- Body-parser - Request parsing
- Docker - Containerization
- Docker Compose - Multi-container orchestration
- Multi-stage builds - Optimized production images
SmartBrain_Project/
βββ facerecognitionbrain/ # React frontend
β βββ src/
β β βββ components/ # Reusable components
β β βββ routes/ # Page components
β β βββ contexts/ # React contexts
β β βββ utils/ # Utility functions
β βββ public/ # Static assets
β βββ build/ # Production build
βββ server/ # Express backend
β βββ server.js # Main server file
β βββ package.json # Server dependencies
β βββ .env # Environment variables
βββ docker-compose.yml # Production Docker setup
βββ docker-compose.dev.yml # Development Docker setup
βββ Dockerfile # Production container
βββ package.json # Root project scripts
- Node.js 18+
- npm or yarn
- Clarifai API account
-
Clone the repository
git clone https://github.com/dev-sam17/SmartBrain_Project.git cd SmartBrain_Project -
Install all dependencies
npm run install-all
-
Set up environment variables Create
.envfile in theserver/directory:CLARIFAI_USER_ID=your_user_id CLARIFAI_APP_ID=your_app_id CLARIFAI_PAT=your_personal_access_token CLARIFAI_MODEL_ID=face-detection
-
Run in development mode
npm run dev
- Frontend: http://localhost:3000
- Backend: http://localhost:3001
-
Build and run production
npm run build-and-start
- Full app: http://localhost:3001
-
Using Docker Compose (Recommended)
docker-compose up --build -d
-
Using Docker directly
docker build -t smartbrain . docker run -p 3001:3001 --env-file server/.env smartbrain
docker-compose -f docker-compose.dev.yml up --buildThis runs frontend and backend in separate containers with hot reload.
http://localhost:3001/api
| Method | Endpoint | Description |
|---|---|---|
| GET | /api |
Get all users |
| GET | /api/profile/:id |
Get user profile |
| POST | /api/signin |
User authentication |
| POST | /api/signup |
User registration |
| POST | /api/imageurl |
Face detection |
| PUT | /api/image |
Update user entry count |
POST /api/imageurl
{
"input": "image_url_or_base64_data"
}Response:
{
"outputs": [
{
"data": {
"regions": [
{
"region_info": {
"bounding_box": {
"top_row": 0.123,
"left_col": 0.456,
"bottom_row": 0.789,
"right_col": 0.012
}
}
}
]
}
}
]
}- Supports both image URLs and file uploads
- Automatic image compression for files >5MB
- Real-time bounding box visualization
- Multiple face detection in single image
- Animated particle background using WebGL
- Glass-morphism design elements
- Responsive layout for all devices
- Loading states and error handling
- Image compression and resizing
- Lazy loading components
- Optimized Docker builds
- Static file serving from Express
Required environment variables for Clarifai API:
CLARIFAI_USER_ID=your_clarifai_user_id
CLARIFAI_APP_ID=your_clarifai_app_id
CLARIFAI_PAT=your_personal_access_token
CLARIFAI_MODEL_ID=face-detectionnpm run build-and-startdocker-compose up -dThe application includes health check endpoints for monitoring:
- Container health check on
/api - 30-second intervals with 3 retries
- 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
| Script | Description |
|---|---|
npm run install-all |
Install dependencies for all packages |
npm run build |
Build React app for production |
npm start |
Start production server |
npm run dev |
Run both frontend and backend in development |
npm run build-and-start |
Build and start production server |
-
Port 3001 already in use
lsof -ti:3001 | xargs kill -9
-
Clarifai API errors
- Verify environment variables
- Check API key permissions
- Ensure sufficient API credits
-
Docker build fails
- Check Docker daemon is running
- Verify .dockerignore excludes node_modules
- Ensure sufficient disk space
This project is licensed under the ISC License.
dev-sam17
- GitHub: @dev-sam17
- Clarifai for face detection API
- React team for the amazing framework
- Firebase for authentication services
- OGL for WebGL particle effects
β Star this repository if you found it helpful!