Skip to content

About

Spring Boot REST API for creating events, referrals, tracking user referrals developed during the NLW Connect

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NLW Connect - DevStage

A Spring Boot application for creating events, referrals, and tracking user referrals. This project was developed during the NLW Connect event by Rocketseat.

NLW Connect DevStage Logo

✨ Features

  • Create and make referrals to events
  • Event subscription system
  • Referral tracking mechanism
  • Ranking system for user referrals

🎨 UI/UX Design

This project's interface follows Rocketseat's design system as showcased in the NLW Connect Figma Design.

NLW Connect Design Preview

πŸš€ Tech Stack

Java Spring Boot Lombok Maven MySQL Docker Postman

πŸ“‹ Project Structure

events/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main/
β”‚   β”‚   β”œβ”€β”€ java/br/com/nlw/events/
β”‚   β”‚   β”‚   β”œβ”€β”€ controller/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ EventController.java
β”‚   β”‚   β”‚   β”‚   └── SubscriptionController.java
β”‚   β”‚   β”‚   β”œβ”€β”€ dto/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ EventDTO.java
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ SubscriptionDTO.java
β”‚   β”‚   β”‚   β”‚   └── UserDTO.java
β”‚   β”‚   β”‚   β”œβ”€β”€ entity/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ EventEntity.java
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ SubscriptionEntity.java
β”‚   β”‚   β”‚   β”‚   └── UserEntity.java
β”‚   β”‚   β”‚   β”œβ”€β”€ exception/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ GlobalExceptionHandler.java
β”‚   β”‚   β”‚   β”‚   └── ResourceNotFoundException.java
β”‚   β”‚   β”‚   β”œβ”€β”€ repository/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ EventRepository.java
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ SubscriptionRepository.java
β”‚   β”‚   β”‚   β”‚   └── UserRepository.java
β”‚   β”‚   β”‚   β”œβ”€β”€ service/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ EventService.java
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ SubscriptionService.java
β”‚   β”‚   β”‚   β”‚   └── UserService.java
β”‚   β”‚   β”‚   └── EventsApplication.java
β”‚   β”‚   └── resources/
β”‚   β”‚       β”œβ”€β”€ application.properties
β”‚   β”‚       β”œβ”€β”€ application-dev.properties
β”‚   β”‚       └── application-prod.properties
β”‚   └── test/
β”‚       └── java/br/com/nlw/events/
β”‚           β”œβ”€β”€ controller/
β”‚           β”œβ”€β”€ service/
β”‚           └── repository/
β”œβ”€β”€ database_script/
β”‚   β”œβ”€β”€ db_events.sql
β”‚   β”œβ”€β”€ queries.sql
β”‚   └── subscribers_mock.json
β”œβ”€β”€ .mvn/
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
└── pom.xml

πŸ› οΈ Installation and Setup

Prerequisites

  • Java 21+
  • Maven
  • Docker and Docker Compose

Running the Application

  1. Clone the repository
git clone https://github.com/zlucasftw/rocketseat-nlw-connect-devstage-java.git
cd rocketseat-nlw-connect-devstage-java
  1. Set up environment variables

Create a .env file in the root directory with the following variables:

DB_USERNAME=root
DB_PASSWORD=root
DB_HOST=localhost:3336
DB_SOURCE=db_events
  1. Start MySQL with Docker
docker-compose up -d
  1. Set up the database
mysql -h 127.0.0.1 -P 3336 -u root -p < database_script/db_events.sql
  1. Build and run the application
./mvnw spring-boot:run

The application will be available at http://localhost:8080.

πŸ”Œ API Endpoints

Events API

  • GET /events - List all events
  • GET /events/{prettyName} - Get event by its pretty name
  • POST /events - Create a new event

Subscriptions API

  • POST /subscription/{prettyName} - Subscribe user to an event
  • POST /subscription/{prettyName}/{userId} - Subscribe user to an event with referral
  • GET /subscription/{prettyName}/ranking - Get referral rankings for an event
  • GET /subscription/{prettyName}/ranking/{userId} - Get specific user ranking for an event

πŸ“Š Database Schema

The database consists of three main tables:

  • tbl_event - Stores event information
  • tbl_user - Stores user information
  • tbl_subscription - Links users to events and tracks referrals

πŸ§ͺ Usage Example

Creating an Event

curl -X POST http://localhost:8080/events \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Dev Stage",
    "location": "Online",
    "price": 0.00,
    "startDate": "2023-11-10",
    "endDate": "2023-11-10",
    "startTime": "09:00",
    "endTime": "17:00"
  }'

Subscribing to an Event

curl -X POST http://localhost:8080/subscription/dev-stage \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john.doe@example.com"
  }'

πŸ“ TO-DO

  • Improve API's global exception reponse/handling
  • Add OpenAPI and Swagger for API documentation
  • Add email notifications for event reminders
  • Create admin dashboard for event management
  • Implement event capacity limits
  • Set up CI/CD pipeline
  • Create comprehensive test coverage
  • Add WebSocket support for real-time updates

🚧 Improvements

Security Enhancements

  • Implement role-based access control
  • Add rate limiting for API endpoints
  • Set up HTTPS with proper certificates

Performance Optimizations

  • Add Redis caching for frequently accessed data
  • Implement database query optimizations
  • Set up connection pooling configurations

Frontend Client

  • Create responsive frontend with React

Feature Extensions

  • Support for recurring events
  • Multi-language support
  • Event analytics dashboard
  • Social media sharing integration

πŸ‘₯ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details. The AGPL-3.0 requires that modified versions of this software also be made available under the same license, including when the software is running as a service.

πŸ™ Acknowledgements

  • Rocketseat for the NLW Connect event and the amazing UI/UX design created by Rocketseat's designer Millena KupsinskΓΌ.

About

Spring Boot REST API for creating events, referrals, tracking user referrals developed during the NLW Connect

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages