https://github.com/sandeepvashishtha/eventra-backend
A comprehensive event management system backend built with Spring Boot, providing secure RESTful APIs for event creation, user management, and administrative operations.
https://github.com/sandeepvashishtha/eventra-backend
java java-17 mysql spring spring-boot springboot
Last synced: about 2 months ago
JSON representation
A comprehensive event management system backend built with Spring Boot, providing secure RESTful APIs for event creation, user management, and administrative operations.
- Host: GitHub
- URL: https://github.com/sandeepvashishtha/eventra-backend
- Owner: SandeepVashishtha
- Created: 2025-09-06T18:23:40.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2025-09-06T20:50:29.000Z (10 months ago)
- Last Synced: 2025-09-06T22:25:15.420Z (10 months ago)
- Topics: java, java-17, mysql, spring, spring-boot, springboot
- Language: Java
- Homepage: https://eventra-backend-dgcae3etebbag8ft.centralindia-01.azurewebsites.net/
- Size: 200 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Eventra Backend
A comprehensive event management system backend built with Spring Boot, providing secure RESTful APIs for event creation, user management, and administrative operations.
## ๐ Features
- **Authentication & Authorization**: JWT-based security with role-based access control
- **Event Management**: Create, update, delete, and manage events
- **User Management**: User registration, profile management, and admin operations
- **Project Management**: Handle event-related projects and collaborations
- **Health Monitoring**: Built-in health checks and monitoring endpoints
- **API Documentation**: Interactive Swagger UI with OpenAPI 3.0 specification
- **Database Flexibility**: Support for both MySQL (production) and H2 (development)
- **Azure Cloud Ready**: Complete deployment configuration for Azure App Service
## ๐ Technology Stack
- **Framework**: Spring Boot 3.3.1
- **Language**: Java 17
- **Build Tool**: Maven
- **Security**: Spring Security with JWT
- **Database**: MySQL (production) / H2 (development)
- **ORM**: Spring Data JPA with Hibernate
- **Documentation**: SpringDoc OpenAPI (Swagger)
- **Validation**: Spring Boot Validation
- **Testing**: JUnit 5 with Spring Boot Test
- **Cloud**: Azure App Service deployment ready
## ๐ Prerequisites
Before running the application, ensure you have:
- **Java 17** or higher
- **Maven 3.6+** (or use included Maven wrapper)
- **MySQL 8.0+** (for production environment)
- **Git** for version control
## ๐โโ๏ธ Quick Start
### Local Development Setup
1. **Clone the repository**
```bash
git clone https://github.com/SandeepVashishtha/Eventra-Backend
cd Eventra-Backend
```
2. **Run with Maven Wrapper (Recommended)**
**Windows:**
```cmd
.\mvnw.cmd spring-boot:run
```
**Linux/Mac:**
```bash
./mvnw spring-boot:run
```
3. **Alternative: Build and run JAR**
```bash
.\mvnw.cmd clean package
java -jar target/backend-0.0.1-SNAPSHOT.jar
```
The application will start on `http://localhost:8080` using H2 in-memory database for development.
### ๐ Access Points
Once running, you can access:
- **API Base URL**: `http://localhost:8080/api`
- **Swagger UI**: `http://localhost:8080/swagger-ui.html`
- **H2 Console**: `http://localhost:8080/h2-console` (dev mode only)
- **Health Check**: `http://localhost:8080/health`
## ๐ Database Configuration
### Development (H2 - Default)
The application uses H2 in-memory database by default for development with these credentials:
- **URL**: `jdbc:h2:mem:testdb`
- **Username**: `sa`
- **Password**: *(empty)*
### Production (MySQL)
Configure the following environment variables for MySQL:
```bash
AIVEN_DATABASE_URL=jdbc:mysql://your-mysql-host:3306/eventra_db?useSSL=true
AIVEN_DATABASE_USERNAME=your_username
AIVEN_DATABASE_PASSWORD=your_password
DATABASE_DRIVER=com.mysql.cj.jdbc.Driver
DATABASE_DIALECT=org.hibernate.dialect.MySQL8Dialect
DDL_AUTO=update
```
### Using Different Profiles
**Development Profile:**
```bash
mvn spring-boot:run -Dspring.profiles.active=dev
```
**Production Profile:**
```bash
mvn spring-boot:run -Dspring.profiles.active=prod
```
**Azure Profile:**
```bash
mvn spring-boot:run -Dspring.profiles.active=azure
```
## ๐ Security Configuration
The application uses JWT-based authentication. Configure these environment variables:
```bash
JWT_SECRET=your-256-bit-secret-key
JWT_EXPIRATION=86400000 # 24 hours in milliseconds
```
## ๐ API Documentation
### Interactive Documentation
Access the Swagger UI at: `http://localhost:8080/swagger-ui.html`
### Main API Endpoints
| Endpoint Category | Base Path | Description |
|------------------|-----------|-------------|
| Authentication | `/api/auth` | Login, register, token management |
| Users | `/api/users` | User profile and management |
| Events | `/api/events` | Event CRUD operations |
| Admin | `/api/admin` | Administrative operations |
| Projects | `/api/projects` | Project management |
| Health | `/health` | Application health checks |
### Authentication Endpoints
- `POST /api/auth/login` - User login
- `POST /api/auth/register` - User registration
- `POST /api/auth/refresh` - Refresh JWT token
### Event Management
- `GET /api/events` - List all events
- `POST /api/events` - Create new event
- `GET /api/events/{id}` - Get event by ID
- `PUT /api/events/{id}` - Update event
- `DELETE /api/events/{id}` - Delete event
## ๐งช Testing
### Run All Tests
```bash
./mvnw test
```
### Run Specific Test Classes
```bash
./mvnw test -Dtest=BackendApplicationTests
./mvnw test -Dtest=ErrorHandlingTest
```
### Test Coverage
The project includes:
- **Unit Tests**: Individual component testing
- **Integration Tests**: End-to-end API testing
- **Security Tests**: Authentication and authorization testing
## ๐ Project Structure
```
Eventra-Backend/
โโโ src/
โ โโโ main/
โ โ โโโ java/com/eventra/
โ โ โ โโโ BackendApplication.java # Main application class
โ โ โ โโโ SecurityConfig.java # Security configuration
โ โ โ โโโ controller/ # REST Controllers
โ โ โ โ โโโ AuthController.java # Authentication endpoints
โ โ โ โ โโโ UserController.java # User management
โ โ โ โ โโโ EventController.java # Event operations
โ โ โ โ โโโ AdminController.java # Admin operations
โ โ โ โ โโโ ...
โ โ โ โโโ service/ # Business logic
โ โ โ โโโ repository/ # Data access layer
โ โ โ โโโ entity/ # JPA entities
โ โ โ โโโ dto/ # Data transfer objects
โ โ โ โโโ config/ # Configuration classes
โ โ โ โโโ exception/ # Custom exceptions
โ โ โ โโโ filter/ # Security filters
โ โ โ โโโ util/ # Utility classes
โ โ โโโ resources/
โ โ โโโ application.properties # Main configuration
โ โ โโโ application-dev.properties # Development config
โ โ โโโ application-prod.properties # Production config
โ โ โโโ application-azure.properties # Azure config
โ โโโ test/ # Test classes
โโโ target/ # Compiled output
โโโ bin/ # Build scripts
โโโ pom.xml # Maven configuration
โโโ mvnw, mvnw.cmd # Maven wrapper
โโโ deploy-azure.ps1 # Azure deployment script
โโโ test-azure-backend.ps1 # Azure testing script
โโโ AZURE_DEPLOYMENT_GUIDE.md # Azure deployment guide
โโโ README.md # This file
```
## โ๏ธ Azure Deployment
This project is configured for Azure App Service deployment. Follow these guides:
### Quick Azure Deployment
1. **Configure Azure CLI** and login to your account
2. **Run the deployment script**:
```powershell
.\deploy-azure.ps1
```
### Detailed Guides
- ๐ **[Azure Deployment Guide](AZURE_DEPLOYMENT_GUIDE.md)** - Complete Azure setup instructions
- ๐ **[Azure Config Template](AZURE_CONFIG_TEMPLATE.md)** - Environment configuration template
- ๐ **[Database Migration Guide](DATABASE_MIGRATION.md)** - Database setup and migration
### Test Azure Deployment
```powershell
.\test-azure-backend.ps1
```
## ๐ง Environment Variables
### Required for Production
| Variable | Description | Example |
|----------|-------------|---------|
| `AIVEN_DATABASE_URL` | MySQL database URL | `jdbc:mysql://host:3306/db` |
| `AIVEN_DATABASE_USERNAME` | Database username | `your_username` |
| `AIVEN_DATABASE_PASSWORD` | Database password | `your_password` |
| `JWT_SECRET` | JWT signing secret | `your-256-bit-secret` |
### Optional Configuration
| Variable | Description | Default |
|----------|-------------|---------|
| `PORT` | Server port | `8080` |
| `JWT_EXPIRATION` | Token expiration (ms) | `86400000` |
| `DB_MAX_POOL_SIZE` | Max connection pool size | `10` |
| `SHOW_SQL` | Show SQL queries | `false` |
## ๐ Troubleshooting
### Common Issues
**Port already in use:**
```bash
# Change port in application.properties or set environment variable
export PORT=8081
```
**Database connection failed:**
- Verify MySQL is running and accessible
- Check connection string and credentials
- Ensure database exists
**JWT token issues:**
- Verify JWT_SECRET is properly set
- Check token expiration time
- Ensure proper Authorization header format: `Bearer `
### Debug Mode
Enable debug logging:
```bash
mvn spring-boot:run -Dspring.profiles.active=dev -Dlogging.level.com.eventra=DEBUG
```
## ๐ค Contributing
We welcome contributions! Please follow these guidelines:
1. **Fork the repository**
2. **Create a feature branch**: `git checkout -b feature/amazing-feature`
3. **Make your changes** following the existing code style
4. **Add tests** for new functionality
5. **Run all tests**: `./mvnw test`
6. **Commit your changes**: `git commit -m 'Add amazing feature'`
7. **Push to the branch**: `git push origin feature/amazing-feature`
8. **Open a Pull Request**
### Code Style Guidelines
- Follow Java naming conventions
- Use Lombok annotations to reduce boilerplate
- Add proper JavaDoc for public methods
- Write comprehensive tests for new features
- Follow RESTful API design principles
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Support
For questions and support:
- ๐ง Create an issue in this repository
- ๐ Check the [documentation](docs/)
- ๐ฌ Join our community discussions
## ๐ What's Next?
Upcoming features and improvements:
- [ ] Real-time notifications
- [ ] Event analytics dashboard
- [ ] Mobile API optimization
- [ ] Advanced search capabilities
- [ ] Integration with external calendar systems
---
Built with โค๏ธ using Spring Boot and Java