This project demonstrates a scalable and high-performance REST API built with Spring Boot, AWS Lambda, DynamoDB, and Redis Pub/Sub. It handles real-time messaging and processes over 1M+ requests daily with efficient integration of microservices and cloud-based components.
- Spring Boot Framework: Simplifies development with robust tools for dependency injection and API handling.
- Redis for Caching: Enhances performance by reducing database calls.
- AWS DynamoDB: Provides a low-latency and highly scalable NoSQL database.
- Scalable Architecture: Designed to support high-throughput traffic and scalability.
- Java 17 or higher
- Maven (for dependency management)
- Redis (locally or via a cloud provider like AWS ElastiCache)
- AWS CLI (for DynamoDB access)
- AWS DynamoDB: For data storage.
git clone https://github.com/agreatpigeon/scalable-api-framework.git
cd scalable-api-frameworkUpdate src/main/resources/application.properties with your Redis and AWS configurations:
# Redis Configuration
spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=yourpassword
# AWS Configuration
aws.region=your-region
aws.dynamodb.table=your-dynamodb-tableRun the following command to build the project:
mvn clean packageThe application uses Redis for caching to enhance performance and reduce DynamoDB latency. Caching logic is implemented in RedisCacheService.java:
@Autowired
private RedisTemplate<String, Object> redisTemplate;
public void saveToCache(String key, Object value) {
redisTemplate.opsForValue().set(key, value, Duration.ofMinutes(10));
}CRUD operations are implemented using the AWS SDK. The service interacts with DynamoDB in DynamoDBService.java:
@Autowired
private DynamoDbClient dynamoDbClient;
public void saveItem(String tableName, Map<String, AttributeValue> item) {
dynamoDbClient.putItem(PutItemRequest.builder().tableName(tableName).item(item).build());
}Build a JAR file suitable for deployment:
mvn clean package- Transfer the JAR file to your server.
- Run the application:
java -jar scalable-api-framework.jar
- Ensure that the server can connect to your AWS DynamoDB instance and Redis cache.
Run the application locally:
mvn spring-boot:runTest the API using curl or tools like Postman:
curl -X POST http://localhost:8080/api/save \
-H "Content-Type: application/json" \
-d '{"id":"123", "payload":"Test data"}'Set a value in the cache:
curl -X POST http://localhost:8080/api/cache \
-H "Content-Type: application/json" \
-d '{"key":"exampleKey", "value":"exampleValue"}'Retrieve the cached value:
curl -X GET http://localhost:8080/api/cache/exampleKey- Implement WebSocket for real-time client notifications.
- Add JWT-based authentication for secure API access.
- Scale Redis with AWS ElastiCache for distributed caching.
- Integrate AWS Lambda for serverless compute operations.
For any inquiries or issues, please open an issue in the repository or contact me directly.