A Spring-based web application for handling CAPTCHA functionality, built with modern Java technologies and React frontend.
This project is a full-stack web application that implements CAPTCHA functionality using Spring Framework 6.2.3 for the backend and React with Vite for the frontend. It's designed to provide secure user verification through CAPTCHA challenges.
- Framework: Spring Framework 6.2.3
- Database:
- MySQL (Driver: 9.1.0)
- PostgreSQL (Driver: 42.7.5)
- ORM: Hibernate 6.6.9.Final
- Connection Pool: C3P0 0.10.2
- Logging:
- SLF4J 2.0.16
- Log4j2 2.24.3
- Build Tool: Maven
- Java Version: Compatible with Jakarta EE 6.0.0
- Additional Libraries:
- Spring Security Core 6.4.4
- Lombok 1.18.36
- JSTL 3.0.0
- JSON-lib 2.4
- Framework: React 18.2.0
- Build Tool: Vite 5.0.0
- Styling: Tailwind CSS 3.4.1
- Routing: React Router DOM 7.6.0
- Icons: Lucide React 0.372.0
captcha-app/
├── backend/
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/ # Java source files
│ │ │ ├── resources/ # Configuration files
│ │ │ └── webapp/ # Web application files
│ │ └── test/ # Test files
│ ├── Dockerfile # Backend Docker configuration
│ └── pom.xml # Maven configuration
├── frontend/
│ ├── src/ # React source files
│ ├── Dockerfile # Frontend Docker configuration
│ ├── nginx.conf # Nginx configuration
│ └── package.json # NPM configuration
├── docker-compose.yml # Docker Compose configuration
├── .github/workflows/ # GitHub Actions CI/CD
└── README.md # Project documentation
- Docker and Docker Compose
- PostgreSQL RDS instance (for production)
- Domain name configured with Cloudflare
- EC2 instance with Docker installed
-
Clone the repository:
git clone <repository-url> cd captcha-app
-
Create environment file:
cp .env.example .env # Edit .env with your database credentials
-
Start the application for development:
docker compose -f docker-compose.dev.yml up --build
-
Access the application:
- Frontend: http://localhost (port 80)
- Backend API: http://localhost:8080
The application uses a CI/CD pipeline that builds Docker images and pushes them to Docker Hub, then deploys to EC2.
- Backend:
melihemreguler/captcha-backend:latest
- Frontend:
melihemreguler/captcha-frontend:latest
- Install Docker and Docker Compose on EC2
- Clone the repository to
/home/ec2-user/captcha-app
- Set up GitHub Secrets for CI/CD:
DOCKER_HUB_USERNAME
: Your Docker Hub usernameDOCKER_HUB_ACCESS_TOKEN
: Your Docker Hub access tokenEC2_SSH_KEY
: Your EC2 private keyEC2_HOST
: Your EC2 public IPEC2_USER
: ec2-userDB_HOST
: Your RDS endpointDB_PORT
: 5432DB_NAME
: postgresDB_USER
: Your DB usernameDB_PASSWORD
: Your DB passwordLETSENCRYPT_EMAIL
: Your email for SSL certificates
Make sure your portfolio-nginx
repository is running with:
- nginx-proxy container
- letsencrypt companion container
web
network created
Configure Cloudflare DNS:
- Type: A
- Name: captcha
- IPv4 address: Your EC2 public IP
- Proxy status: DNS only (not proxied)
For testing purposes, you can use the following credentials to access the admin panel:
Username: admin
Password: password123
Note: These are demo credentials for development and testing. In production, make sure to change these credentials and implement proper authentication security measures.
- CAPTCHA generation and validation
- Database persistence with Hibernate
- RESTful API endpoints
- React-based user interface
- Automatic SSL certificate generation
- Docker containerization
- CI/CD with GitHub Actions
- Database connection:
backend/src/main/resources/hibernate.properties
- Logging:
backend/src/main/resources/log4j.properties
- API endpoints:
frontend/.env
- Build configuration:
frontend/vite.config.js
- Styling:
frontend/tailwind.config.js
Run backend tests:
cd backend
mvn test
If you encounter SSL handshake errors:
- Ensure Cloudflare proxy is disabled for the subdomain
- Check that the nginx-proxy network is running
- Verify that LETSENCRYPT_EMAIL is correctly set
If database connection fails:
- Check RDS security group allows connection from EC2
- Verify database credentials in environment variables
- Ensure RDS instance is publicly accessible (if needed)
This project is licensed under the MIT License.