Question: ## Background Full - stack applications are typically concerned with both a front end, that displays information to the user and takes in input, and

## Background
Full-stack applications are typically concerned with both a front end, that displays information to the user and takes in input, and a backend, that manages persisted information.
This project will be a backend for a hypothetical social media app, where we must manage our users accounts as well as any messages that they submit to the application. However, the functionality for this project will leverage a popular web application framework for Java known as Spring. The Spring framework allows for automatic injection and configuration of many features, including data persitence, endpoints and conventional data manipulation logic (CRUD operations).
In our hypothetical micro-blogging or messaging app, any user should be able to see all of the messages posted to the site, or they can see the messages posted by a particular user. In either case, we require a backend which is able to deliver the data needed to display this information as well as process actions like logins, registrations, message creations, message updates, and message deletions.
## Database Tables
The following tables will be initialized in your project's built-in database upon startup using the configuration details in the application.properties file and the provided SQL script.
### Account
```
accountId integer primary key auto_increment,
username varchar(255) not null unique,
password varchar(255)
```
### Message
```
messageId integer primary key auto_increment,
postedBy integer,
messageText varchar(255),
timePostedEpoch long,
foreign key (postedBy) references Account(accountId)
```
# Spring Technical Requirement
## Project must leverage the Spring Boot Framework
Java classes have been provided, but your entire project MUST leverage the Spring framework.
In addition to functional test cases, "SpringTest" will verify that you have leveraged the Spring framework, Spring Boot, Spring MVC, and Spring Data.
SpringTest will verify the following
- That you have, by any means, have a bean for the AccountService, MessageService, AccountRepository, MessageRepository, and SocialMediaController classes
- That AccountRepository and MessageRepository are working JPARepositories based on their corresponding Account and Message entities
- That your Spring Boot app leverages MVC by checking for Spring's default error message structure.
The app will already be a Spring Boot app with a valid application.properties and valid database entities at the start.
# User Stories
## 2: Our API should be able to process User logins.
As a user, I should be able to verify my login on the endpoint POST localhost:8080/login. The request body will contain a JSON representation of an Account.
- The login will be successful if and only if the username and password provided in the request body JSON match a real account existing on the database. If successful, the response body should contain a JSON of the account in the response body, including its accountId. The response status should be 200 OK, which is the default.
- If the login is not successful, the response status should be 401.(Unauthorized)
## 3: Our API should be able to process the creation of new messages.
As a user, I should be able to submit a new post on the endpoint POST localhost:8080/messages. The request body will contain a JSON representation of a message, which should be persisted to the database, but will not contain a messageId.
- The creation of the message will be successful if and only if the messageText is not blank, is not over 255 characters, and postedBy refers to a real, existing user. If successful, the response body should contain a JSON of the message, including its messageId. The response status should be 200, which is the default. The new message should be persisted to the database.
- If the creation of the message is not successful, the response status should be 400.(Client error)
## 4: Our API should be able to retrieve all messages.
As a user, I should be able to submit a GET request on the endpoint GET localhost:8080/messages.
- The response body should contain a JSON representation of a list containing all messages retrieved from the database. It is expected for the list to simply be empty if there are no messages. The response status should always be 200, which is the default.
## 5: Our API should be able to retrieve a message by its ID.
As a user, I should be able to submit a GET request on the endpoint GET localhost:8080/messages/{messageId}.
- The response body should contain a JSON representation of the message identified by the messageId. It is expected for the response body to simply be empty if there is no such message. The response status should always be 200, which is the default.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!