Skip to content

A modular Java-based Auction System for BCD 1 research, featuring real-time bidding, user authentication, secure auction management, and a modern web interface. Designed for educational, demonstration, and practical online auction scenarios. Try Now πŸ‘‡

License

Notifications You must be signed in to change notification settings

isharax9/AuctionSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ† Distributed Online Auction System

Java Jakarta EE GlassFish License Build

Enterprise-grade auction system with real-time bidding, distributed messaging, and comprehensive session management

Features β€’ Quick Start β€’ Architecture β€’ API β€’ Contributing


πŸ“‹ Table of Contents


🎯 About The Project

A comprehensive enterprise application for online auctions featuring real-time bidding, built with Jakarta EE 10 and modern Java technologies. Demonstrates production-grade patterns in distributed systems, message-driven architecture, and enterprise development.

Key Highlights

  • πŸŽ“ Educational - Learn enterprise Java patterns and best practices
  • 🏒 Production-Ready - Built with enterprise-grade technologies
  • πŸš€ Scalable - Distributed architecture with horizontal scaling support
  • πŸ”„ Real-Time - WebSocket-based instant notifications
  • πŸ”’ Secure - Comprehensive session and user management

✨ Features

Core Capabilities

Feature Description
🏷️ Auction Management Create, monitor, and manage auctions with automatic expiration
πŸ’° Real-Time Bidding Thread-safe concurrent bid handling with instant validation
πŸ‘₯ User Management Registration, authentication, and activity tracking
πŸ“‘ Live Notifications WebSocket-based real-time bid and auction updates
πŸ”„ Message Queue JMS integration for asynchronous event processing
πŸ“Š Analytics Comprehensive auction and bidding statistics
πŸ§ͺ Testing Suite Unit, integration, and performance tests

Technical Highlights

  • ⚑ Thread-Safe Operations - ConcurrentHashMap and atomic operations
  • 🎯 Stateless EJBs - Horizontal scalability support
  • πŸ”” Event-Driven - Message-Driven Beans for decoupled processing
  • πŸ›‘οΈ Filter Chain - Session validation and security filters
  • πŸ“¦ Clean Architecture - DTOs for data encapsulation

πŸ› οΈ Technology Stack

Core Technologies

Category Technologies
Backend Java 11+, Jakarta EE 10, EJB 4.0.1, JMS 3.1.0, CDI 4.0.1
Web Layer Servlet API 6.0.0, WebSocket, JSP
Frontend JavaScript ES6+, CSS3, WebSocket API
Build Maven 3.x, Maven Compiler Plugin
Testing JUnit 5.9.3, Mockito 5.3.1, Testcontainers 1.18.3, JaCoCo 0.8.8
Server GlassFish 7.x

πŸ—οΈ Architecture

System Architecture Overview

graph TB
    Browser[πŸ–₯️ Web Browser]
    WSClient[πŸ”Œ WebSocket Client]
    
    Servlet[🌐 Servlets & Filters]
    WSEndpoint[πŸ“‘ WebSocket Endpoints]
    
    AuctionEJB[βš™οΈ Auction Service]
    BidEJB[πŸ’° Bid Service]
    UserEJB[πŸ‘€ User Service]
    SessionMgr[πŸ” Session Manager]
    AuctionMgr[⏰ Auction Manager]
    
    JMS[πŸ“¨ JMS Queue]
    MDB[πŸ“¬ Message Driven Bean]
    
    Browser -->|HTTP/HTTPS| Servlet
    WSClient -->|WebSocket| WSEndpoint
    
    Servlet --> AuctionEJB
    Servlet --> BidEJB
    Servlet --> UserEJB
    Servlet --> SessionMgr
    
    WSEndpoint --> AuctionMgr
    WSEndpoint --> SessionMgr
    
    BidEJB -->|Send| JMS
    AuctionEJB -->|Send| JMS
    JMS -->|Consume| MDB
    MDB -->|Broadcast| WSEndpoint
    
    AuctionMgr -.->|Monitor| AuctionEJB
    
    classDef clientStyle fill:#4A90E2,stroke:#2E5C8A,stroke-width:3px,color:#fff
    classDef webStyle fill:#F39C12,stroke:#C87F0A,stroke-width:3px,color:#fff
    classDef businessStyle fill:#9B59B6,stroke:#7D3C98,stroke-width:3px,color:#fff
    classDef messageStyle fill:#27AE60,stroke:#1E8449,stroke-width:3px,color:#fff
    
    class Browser,WSClient clientStyle
    class Servlet,WSEndpoint webStyle
    class AuctionEJB,BidEJB,UserEJB,SessionMgr,AuctionMgr businessStyle
    class JMS,MDB messageStyle
Loading

Bid Placement Flow

sequenceDiagram
    participant U as πŸ‘€ User
    participant S as Servlet
    participant B as Bid Service
    participant J as JMS Queue
    participant M as MDB
    participant W as WebSocket
    participant C as πŸ“± Clients
    
    U->>+S: POST /auction/bid
    S->>+B: placeBid()
    
    alt βœ… Valid Bid
        B->>B: Validate amount
        B->>B: Update auction
        B->>J: Send message
        B-->>-S: BidDTO
        S-->>-U: 200 OK
        
        J->>+M: Deliver
        M->>+W: Broadcast
        W->>C: Push update
        W-->>-M: Done
        M-->>-J: Ack
    else ❌ Invalid Bid
        B-->>S: Error
        S-->>U: 400 Bad Request
    end
Loading

Real-Time Notification Architecture

graph TB
    A[πŸ“’ New Bid]
    B[πŸš€ Auction Started]
    C[🏁 Auction Ended]
    D[❌ Auction Cancelled]
    
    E[βš™οΈ EJB Business Logic]
    F[πŸ“¨ JMS Queue]
    G[πŸ“¬ Message-Driven Bean]
    
    H[πŸ“‘ WebSocket Manager]
    I[πŸ” Session Manager]
    
    J[🌐 Browser 1]
    K[🌐 Browser 2]
    L[🌐 Browser N]
    
    A --> E
    B --> E
    C --> E
    D --> E
    
    E --> F
    F --> G
    G --> H
    
    H --> I
    I --> J
    I --> K
    I --> L
    
    classDef eventStyle fill:#E74C3C,stroke:#C0392B,stroke-width:3px,color:#fff
    classDef processStyle fill:#3498DB,stroke:#2980B9,stroke-width:3px,color:#fff
    classDef distStyle fill:#9B59B6,stroke:#8E44AD,stroke-width:3px,color:#fff
    classDef clientStyle fill:#2ECC71,stroke:#27AE60,stroke-width:3px,color:#fff
    
    class A,B,C,D eventStyle
    class E,F,G processStyle
    class H,I distStyle
    class J,K,L clientStyle
Loading

Component Interaction Diagram

graph TB
    E1[πŸ“¦ Auction Entity]
    E2[πŸ“¦ Bid Entity]
    E3[πŸ“¦ User Entity]
    
    D1[πŸ“‹ AuctionDTO]
    D2[πŸ“‹ BidDTO]
    D3[πŸ“‹ BidUpdateMessage]
    
    S1[βš™οΈ Auction Service]
    S2[βš™οΈ Bid Service]
    S3[βš™οΈ User Service]
    
    SG1[πŸ”’ Auction Manager]
    SG2[πŸ”’ Session Manager]
    
    A1[πŸ”„ Notification MDB]
    
    S1 --> E1
    S2 --> E2
    S3 --> E3
    
    S1 --> D1
    S2 --> D2
    S2 --> D3
    
    S1 -.->|Monitor| SG1
    S2 -->|Publish| A1
    S3 -.->|Track| SG2
    
    A1 -->|Broadcast| SG2
    
    classDef entityStyle fill:#4A90E2,stroke:#2E5C8A,stroke-width:3px,color:#fff
    classDef dtoStyle fill:#F39C12,stroke:#C87F0A,stroke-width:3px,color:#fff
    classDef serviceStyle fill:#9B59B6,stroke:#7D3C98,stroke-width:3px,color:#fff
    classDef singletonStyle fill:#27AE60,stroke:#1E8449,stroke-width:3px,color:#fff
    classDef asyncStyle fill:#E74C3C,stroke:#C0392B,stroke-width:3px,color:#fff
    
    class E1,E2,E3 entityStyle
    class D1,D2,D3 dtoStyle
    class S1,S2,S3 serviceStyle
    class SG1,SG2 singletonStyle
    class A1 asyncStyle
Loading

Design Patterns

Pattern Implementation Purpose
Singleton AuctionManagerSingleton, UserSessionManagerBean Shared state & lifecycle management
Stateless Session Bean AuctionServiceBean, BidServiceBean Scalable, concurrent business logic
Message-Driven Bean BidNotificationMDB Asynchronous event processing
DTO AuctionDTO, BidDTO Data encapsulation & transfer
Front Controller AuctionServlet Centralized request handling
Observer WebSocket + JMS Real-time event notification
Filter Chain SessionFilter, AdminFilter Request preprocessing & security

πŸš€ Getting Started

Prerequisites

Ensure you have the following installed:

# Java 11+
java -version

# Maven 3.6+
mvn -version

# Git
git --version

GlassFish Server 7.x

Quick Installation

# 1. Clone repository
git clone https://github.com/isharax9/AuctionSystem.git
cd AuctionSystem

# 2. Build project
mvn clean install

# 3. Run tests
mvn test

# 4. Package application
mvn package

GlassFish Configuration

Option A: Manual Setup

# Start GlassFish
cd $GLASSFISH_HOME/bin
./asadmin start-domain domain1

# Configure JMS Resources
./asadmin create-jms-resource --restype jakarta.jms.Queue \
  --property Name=BidNotificationQueue jms/BidNotificationQueue

./asadmin create-jms-resource --restype jakarta.jms.QueueConnectionFactory \
  jms/BidNotificationQueueFactory

Option B: Docker Setup

docker run -d \
  -p 8080:8080 \
  -p 4848:4848 \
  --name glassfish \
  glassfish:7.0.0-jdk11

Deploy Application

# Using asadmin
./asadmin deploy target/AuctionSystem.war

# Verify deployment
./asadmin list-applications

Access Points

Service URL Purpose
Main App http://localhost:8080/AuctionSystem/ Primary interface
Real-Time http://localhost:8080/AuctionSystem/real-time-notifications.html Live updates
Session Admin http://localhost:8080/AuctionSystem/session-admin Admin panel
Admin Console http://localhost:4848 GlassFish admin

πŸ“– Usage Examples

Creating an Auction (Java)

@Inject
private AuctionServiceRemote auctionService;

public void createAuction() {
    AuctionDTO auction = auctionService.createAuction(
        "Vintage Camera",
        "Rare 1950s Leica M3 in excellent condition",
        250.0,      // Starting price
        3,          // Duration: 3 hours
        30          // Duration: 30 minutes
    );
    System.out.println("Created: " + auction.getAuctionId());
}

Placing a Bid (Java)

@Inject
private BidServiceRemote bidService;

public boolean placeBid(Long auctionId, String username, double amount) {
    BidDTO bid = bidService.placeBid(auctionId, username, amount);
    return bid != null; // Returns true if successful
}

Real-Time Updates (JavaScript)

// Connect to WebSocket
const socket = new WebSocket('ws://localhost:8080/AuctionSystem/auction-updates');

// Handle incoming updates
socket.onmessage = (event) => {
    const update = JSON.parse(event.data);
    console.log(`New bid: $${update.bidAmount} by ${update.bidder}`);
    
    // Update UI
    document.getElementById('currentBid').textContent = `$${update.bidAmount}`;
    document.getElementById('bidder').textContent = update.bidder;
};

// Send bid
function placeBid(auctionId, amount) {
    socket.send(JSON.stringify({
        type: 'BID',
        auctionId: auctionId,
        amount: amount
    }));
}

πŸ”Œ API Documentation

Core Endpoints

Method Endpoint Description Request Body
GET /auction List active auctions -
GET /auction/{id} Get auction details -
POST /auction Create new auction AuctionDTO
POST /auction/{id}/bid Place a bid BidDTO
GET /auction/history Completed auctions ?page=1&size=10
POST /auction/{id}/close Close auction early -
GET /session-admin Active sessions -

Request/Response Examples

Create Auction

Request:

POST /auction
Content-Type: application/json

{
  "title": "Antique Vase",
  "description": "Ming Dynasty ceramic vase, authenticated",
  "startingPrice": 1000.0,
  "durationHours": 4,
  "durationMinutes": 30
}

Response:

{
  "auctionId": 1,
  "title": "Antique Vase",
  "startingPrice": 1000.0,
  "currentHighestBid": 1000.0,
  "currentHighestBidder": null,
  "startTime": "2024-01-15T10:00:00",
  "endTime": "2024-01-15T14:30:00",
  "active": true,
  "totalBidsCount": 0,
  "status": "ACTIVE"
}

Place Bid

Request:

POST /auction/1/bid
Content-Type: application/json

{
  "username": "bidder123",
  "amount": 1100.0
}

Response:

{
  "bidId": 1,
  "auctionId": 1,
  "username": "bidder123",
  "amount": 1100.0,
  "timestamp": "2024-01-15T10:15:00",
  "valid": true
}

πŸ“‚ Project Structure

AuctionSystem/
β”œβ”€β”€ src/main/java/com/auction/
β”‚   β”œβ”€β”€ config/              # WebSocket configuration
β”‚   β”œβ”€β”€ dto/                 # Data Transfer Objects
β”‚   β”œβ”€β”€ ejb/                 # Enterprise JavaBeans
β”‚   β”‚   β”œβ”€β”€ *ServiceBean.java       # Business logic
β”‚   β”‚   β”œβ”€β”€ *ServiceRemote.java     # Remote interfaces
β”‚   β”‚   β”œβ”€β”€ AuctionManagerSingleton.java
β”‚   β”‚   └── BidNotificationMDB.java
β”‚   β”œβ”€β”€ entity/              # Domain entities (Auction, Bid, User)
β”‚   β”œβ”€β”€ filter/              # Servlet filters (Session, Admin, Encoding)
β”‚   β”œβ”€β”€ servlet/             # Web servlets
β”‚   β”œβ”€β”€ session/             # Session management
β”‚   └── websocket/           # WebSocket endpoints
β”œβ”€β”€ src/main/webapp/
β”‚   β”œβ”€β”€ WEB-INF/web.xml      # Deployment descriptor
β”‚   β”œβ”€β”€ css/                 # Stylesheets
β”‚   β”œβ”€β”€ js/                  # JavaScript modules
β”‚   β”œβ”€β”€ error/               # Error pages (404, 500)
β”‚   └── *.jsp, *.html        # Web pages
β”œβ”€β”€ src/test/java/           # Test suite
β”‚   β”œβ”€β”€ ejb/                 # Unit tests
β”‚   β”œβ”€β”€ entity/              # Entity tests
β”‚   β”œβ”€β”€ integration/         # Integration tests
β”‚   └── performance/         # Performance tests
β”œβ”€β”€ pom.xml                  # Maven configuration
└── README.md

πŸ§ͺ Testing

Run Tests

# All tests
mvn test

# Specific test class
mvn test -Dtest=AuctionServiceBeanTest

# With coverage report
mvn clean test jacoco:report

# View coverage
open target/site/jacoco/index.html

Test Coverage

Category Coverage Target
Overall > 80%
Business Logic > 90%
Entities > 85%
Servlets > 75%

Test Suite

  • βœ… Unit Tests - EJB business logic, entity validation
  • βœ… Integration Tests - End-to-end auction workflows
  • βœ… Concurrency Tests - Thread safety verification
  • βœ… Performance Tests - Load and stress testing

🚒 Deployment

Production Build

mvn clean package -Pprod

Docker Deployment

FROM glassfish:7.0.0-jdk11

COPY target/AuctionSystem.war \
  /opt/glassfish7/glassfish/domains/domain1/autodeploy/

EXPOSE 8080 4848

CMD ["asadmin", "start-domain", "--verbose"]
# Build and run
docker build -t auction-system .
docker run -d -p 8080:8080 -p 4848:4848 --name auction auction-system

Environment Configuration

Environment Server Database Messaging
Dev localhost In-Memory Local Queue
Staging staging.example.com PostgreSQL ActiveMQ
Prod www.example.com PostgreSQL HA ActiveMQ Cluster

πŸ—ΊοΈ Roadmap

Version 2.0 (Planned)

  • Database persistence (PostgreSQL/MySQL + JPA)
  • OAuth2/JWT authentication
  • Payment gateway integration
  • Image upload for auctions
  • Email & SMS notifications
  • Redis caching layer
  • Kubernetes deployment

Version 1.0 (Current) βœ…

  • Core auction management
  • Real-time bidding with WebSocket
  • JMS message-driven architecture
  • Session management
  • Comprehensive test suite
  • Production-ready build

🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Quick Start

# 1. Fork and clone
git clone https://github.com/yourusername/AuctionSystem.git

# 2. Create feature branch
git checkout -b feature/AmazingFeature

# 3. Make changes and test
mvn test

# 4. Commit and push
git commit -m 'Add AmazingFeature'
git push origin feature/AmazingFeature

# 5. Open Pull Request

πŸ“„ License

This project is licensed under the MIT License - see LICENSE for details.


πŸ’¬ Contact

Platform Link
πŸ“§ Email isharax9@gmail.com
πŸ’¬ Telegram @mac_knight141
πŸ’Ό LinkedIn isharax9
πŸ™ GitHub @isharax9

Support This Project

⭐ Star the repository β€’ πŸ› Report bugs β€’ πŸ’‘ Suggest features β€’ πŸ”€ Contribute code


πŸ™ Acknowledgments

  • Jakarta EE Community - Enterprise platform
  • GlassFish Team - Application server
  • Maven & JUnit - Build and testing tools
  • Open Source Contributors - Community support

Made with ❀️ by isharax9

GitHub repo size GitHub code size GitHub top language

About

A modular Java-based Auction System for BCD 1 research, featuring real-time bidding, user authentication, secure auction management, and a modern web interface. Designed for educational, demonstration, and practical online auction scenarios. Try Now πŸ‘‡

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published