Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StreamIt - Social Post Streaming Application

StreamIt is a simple social application built using Quarkus and JavaScript that allows users to create posts of up to 140 characters and view them in a single streaming feed. The backend service is deployed as a monolithic application and can be later split into microservices using AWS Lambda. User authentication and security are managed with JWT and AWS Cognito.

Features

  • User Registration: Users can register with their name, email, and password.
  • Login & Authentication: Users can log in and access protected features with JWT.
  • Post Creation: Authenticated users can create posts up to 140 characters.
  • Post Streaming: All posts are displayed in a live stream ordered by timestamp.
  • Secure API: Endpoints are protected with JWT, generated by AWS Cognito.
  • Scalable Architecture: The application can be separated into microservices and deployed on AWS Lambda.

Prerequisites

  • Java 11+
  • Quarkus Framework
  • Maven
  • AWS CLI (for deployment on S3 and Lambda)
  • AWS Cognito (for authentication and JWT)
  • Docker (optional, for containerized deployments)

Project Structure

  • src/main/java: Contains the Java code for the Quarkus backend.
  • src/main/resources: Contains HTML, JavaScript, and static assets.
  • controllers: REST API controllers for managing users, posts, and streams.
  • entities: JPA entities representing Users and Posts.
  • repositories: Repositories for accessing User and Post data.

Setup and Installation

1. Clone the Repository

git clone https://github.com/JohannBulls/StreamIt.git
cd StreamIt

2. Set Up AWS Cognito

  1. Create a Cognito User Pool on AWS.
  2. Configure app clients and enable user authentication with email and password.
  3. Update the BASE_URL in app.js and backend to match your Cognito credentials and endpoint.

3. Run the Application Locally

To start the application locally, run the following commands:

./mvnw compile quarkus:dev

The application should be running on http://localhost:8080.

4. Deploy to AWS S3 (Frontend)

To deploy the frontend application on S3:

  1. Create an S3 bucket with public access for hosting a static website.
  2. Upload index.html, app.js, and other assets to the bucket.
  3. Configure the bucket for static website hosting and note the endpoint URL.

5. Secure the Application with AWS Cognito

Configure AWS Cognito to issue JWTs for user authentication:

  1. Update the /auth/login endpoint in app.js to authenticate with Cognito.
  2. Configure protected endpoints to validate tokens from AWS Cognito.

6. Separate into Microservices on AWS Lambda

  1. Refactor the monolithic application into three microservices:
    • User Service
    • Post Service
    • Stream Service
  2. Deploy each service as an AWS Lambda function.
  3. Configure API Gateway to route requests to Lambda functions.

Endpoints

Endpoint HTTP Method Description
/users GET Retrieve all users
/users POST Register a new user
/users/{id} GET Get user details by ID
/posts GET Retrieve all posts
/posts POST Create a new post
/posts/{id} GET Get post details by ID
/stream GET Get a stream of all posts ordered by timestamp

Frontend Application (JavaScript)

  • Register a New User: Collects user information and sends it to the /users endpoint.
  • Login: Authenticates user credentials and stores the JWT token.
  • Create Post: Allows the user to create a new post of up to 140 characters.
  • Stream Feed: Displays a feed of all posts in real-time.

Usage

  1. Register: Go to the "Register" form and create a new user.
  2. Login: Log in with your email and password to receive a token.
  3. Create a Post: Submit a new post via the "Create Post" form.
  4. View Stream: See the live stream of posts in the "Stream" section.

Testing

Test the application locally with the following tools:

  1. Postman: Test each endpoint with JWT tokens.
  2. Frontend UI: Interact with the forms and validate the application flow.
  3. AWS Console: Test deployed Lambda functions and API Gateway setup.

Architecture

The application follows a monolithic architecture in the initial setup with Quarkus and then transitions to a microservices architecture with AWS Lambda. The architecture consists of the following components:

  • API Gateway: Routes requests to microservices in Lambda.
  • AWS Cognito: Manages user authentication and issues JWT tokens.
  • AWS S3: Hosts the static frontend for public access.
  • Microservices: User, Post, and Stream services deployed independently on Lambda.

Project Structure

image

License

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

About

Microblogging application with authentication and post streaming functionality.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages