An open API service indexing awesome lists of open source software.

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.

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