Saturday, October 29, 2016

Project: E-commerce system Architecture, Design and Implementation

1.    Business Case

Develop online shopping web application, which is capable of secure online shopping and payment by credit card in addition to cash on delivery option (COD). The delivery of the goods should be completed within 2 working days.
The system will improve customer experience by allowing to shop online instead of visiting the stores, which finally results in satisfied customer and company (Sumedagawa Corporation) revenue growth.

Context Diagram:

2.    Use case model

(Interaction between actors and system.)

Figure 1: Use case model for E-commerce system


    Table 1: List of actors for the E-commerce system

Actor
Description
Customer
Customer interacts with the system to buy item, search item and do payment. No login is necessary to search an item.
Credit card Gateway
The gateway gets the input from the do payment use case to authorize the payment. For authorization purpose it connects to the credit card gateway.
Delivery Service
Deliver Service actor, delivers the item to the Customer as per instructions from the deliver item use case

2.1 List of use cases based on above use case model


ID
Use case title
Description
UC1
Do Sign-up
 New user sign-up
UC3
Do Login
Customer login
UC3
Search item
Search item based on the keyword
UC4
Buy item
Buy item after search
UC5
Do payment
Process order payment with external system
UC6
Deliver item
Deliver the item to the customer via delivery service

2.2 Use case details

2.2.1 Use case: Do Sign-up
Use case name
Do Sign-up
Use case ID

Description

Level

Primary actors

Supporting actors

Stakeholders

Pre-condition

Post-condition
Success end:

Failure end:

Minimum guarantee:

Main Flow (MF, success):












Extensions:








Sequence diagram (MF): Do Sign-up
To-do

2.2.2 Use case: Do login
Use case name
Do login
Use case ID

Description

Level

Primary actors

Supporting actors

Stakeholders

Pre-condition

Post-condition
Success end:

Failure end:

Minimum guarantee:

Main Flow (MF, success):












Extensions:








Sequence diagram (MF):  Do Login


Figure 2: Sequence diagram for Do Login scenario

2.2.3 Use case: Search item
Use case name
Search item
Use case ID

Description

Level

Primary actors

Supporting actors

Stakeholders

Pre-condition

Post-condition
Success end:

Failure end:

Minimum guarantee:

Main Flow (MF, success):












Extensions:








Sequence diagram (MF):
To-do

2.2.4 Use case: Buy item
Use case name
Buy Item
Use case ID
UC4
Description
Customer buys item by putting it into the shopping cart and checkout to do payment. Once the payment is confirmed the deliver service get notification about delivering the item to the billing address.
Level
High
Primary actors
Customer
Supporting actors
Credit card gateway,
Stakeholders
Customer, Delivery service, Credit card gateway
Pre-condition
Customer should be login
Post-condition
Success end: Customer successfully buys the item

Failure end: payment failure

Minimum guarantee: The transaction will atomic (full success or full rollback in case of failure)

Main Flow (MF, success):
1. Customer search item
2. System displays the item
3. Customer add the item to shopping cart
4. Customer checks out
5. System displays total payment information and credit card form
6. Customer enter credit card details and do payment
7. System gets authorization from credit card company
8. System displays payment and item confirmation details

Extensions:
7a. System gets un-authorization from the credit card company
1.  Customer can reenter card information and retry


Sequence diagram (MF):
To-do

2.2.5 Use case: Do payment
Use case name
Do payment
Use case ID

Description

Level

Primary actors

Supporting actors

Stakeholders

Pre-condition

Post-condition
Success end:

Failure end:

Minimum guarantee:

Main Flow (MF, success):












Extensions:








Sequence diagram (MF):
To-do

2.2.6 Use case: Deliver item
Use case name
Deliver item
Use case ID

Description

Level

Primary actors

Supporting actors

Stakeholders

Pre-condition

Post-condition
Success end:

Failure end:

Minimum guarantee:

Main Flow (MF, success):












Extensions:








Sequence diagram (MF):
To-do

2.3 Class Diagram:

Class
Responsibility



















3.    Requirements (primary requirements are drivers)

3.1 Functional requirements
ID
Requirement List
Primary?
FR1
Do Sign-up
Y
FR2
Do Login
Y
FR3
Search item
Y
FR4
Buy item
Y
FR5
Do payment
Y
FR6
Deliver item
Y

3.2    Quality attributes (NFR, driver)
ID
Quality Attribute
Outcome (Testable and Measureable)
QA1





















3.3         Quality attribute scenarios (driver)
ID
Quality Attribute
Scenario
Related UC
QAW1
Security
All transactions should be logged
UC2


All transactions should be secured with SSL
UC2

























     3.4   Constraints (NFR, driver)
ID
Type
Description
CN1
Business
System should be released before Dec. 2016
CN2
Technical
User accounts should be authenticated using internal customer db (non-cloud)
CN3
Technical
System must support IE browser, version 9 and above
CN4
Technical
Data source connection should be over JDBC protocol










     3.5    Architectural Concerns (driver)
ID
Description
ACN1
The system shall be programmed using Java and java based technologies
ACN2
Application logs shall be maintained using daily rotation








4. Architectural Documentation

4.1 Module Structure (dc: use reference architecture & deployment diagram)
(Static view)
TO-DO: DIAGRAM


Element
Responsibility



















4.2 Component & Connector Structure  (component diagram)
(Dynamic view)
TO-DO: DIAGRAM


Element
Responsibility




























4.3 Allocation View
(Relation of the system to non-software structures in the environment)
TO-DO: DIAGRAM


Element
Responsibility





















5. Implementation

Implementation is based on MVC (Model View Controller) design pattern. For class diagram please refer to section above.

Project Structure in Eclipse:


5.1 Source code:

[LoginManager.java]

package controller;

import java.sql.Connection;

import model.Login;
import model.dao.DBConnectionManger;
import model.dao.LoginDAO;

public class LoginManager {
      
       /**
        * Method to authenticate the user for the specified login information.
        * @param login login information
        * @return true if authentic user else return false
        */
       public boolean doAuthentication(Login login) {
             
              boolean result = false;
             
              try {
                     Connection connection = DBConnectionManger.getConnection();
                     LoginDAO loginDAO = new LoginDAO(connection);
             
                     result = loginDAO.doCheck(login);
                           
              } finally {
                     DBConnectionManger.closeConnection();
              }
             
              return result;
       }
}


[Login.java]

package model;

public class Login {

       private String userId;
       private String password;
      
       public String getUserId() {
              return userId;
       }
      
       public void setUserId(String userId) {
              this.userId = userId;
       }
      
       public String getPassword() {
              return password;
       }
      
       public void setPassword(String password) {
              this.password = password;
       }
}


[DBConnectionManger.java]

package model.dao;

import java.sql.Connection;
import java.sql.SQLException;

public class DBConnectionManger {

       private static Connection conn;
      
       /**
        * Method to return database connection based on the underlying database.
        * @return database connection
        */
       public static Connection getConnection() {
              //TODO: implement
              return conn;
       }
      
       /**
        * Method to close the DB connection
        */
       public static void closeConnection() {
                     try {
                            if (conn != null) {
                                   conn.close();
                            }
                     } catch (SQLException e) {
                            e.printStackTrace();
                     }
       }
}


[LoginDAO.java]

package model.dao;

import java.sql.Connection;
import model.Login;

public class LoginDAO {
             
       private static Connection conn;
      
       public LoginDAO(Connection connection) {
              conn = connection;
       }
      
       /**
        * Method to create login
        */
       public void create() {
             
       }
      
       /**
        * Check login details from the data source
        * @param login parameter with login details
        * @return true if authenticate else false
        */
       public boolean doCheck(Login login) {
              boolean result = false;
             
//TODO: implement      
              if (
                     login.getUserId().equalsIgnoreCase("Tokyo") &&
                     login.getPassword().equals("Osaka")
                     ) {
                     result = true;
              }

              return result;
       }

public Login doUpdate(Login existingLogin) {
              //TODO: implement
              return null;
       }
 }


[LoginManagerTest.java]

package controller;
import controller.LoginManager;
import junit.framework.TestCase;
import model.Login;

public class LoginManagerTest extends TestCase{
      
       public void testDoAuthentication() {
             
              LoginManager loginManager = new LoginManager();
             
              Login login = new Login();

              login.setUserId("tokyo");
              login.setPassword("Osaka");
             
              boolean result = loginManager.doAuthentication(login);
              assertEquals(true, result);
       }
}


[LoginDAOTest.java]

package model.dao;
import java.sql.Connection;

import junit.framework.TestCase;
import model.Login;
import model.dao.DBConnectionManger;
import model.dao.LoginDAO;

public class LoginDAOTest extends TestCase {

       Connection connection;
      
       @Override
       protected void setUp() throws Exception {
              connection = DBConnectionManger.getConnection();
              super.setUp();
       }
      
       public void testDoCheck() {

              LoginDAO loginDAO = new LoginDAO(connection);
      
              Login login = new Login();
              login.setUserId("tokyo");
              login.setPassword("Osaka");
             
              boolean result = loginDAO.doCheck(login);
             
              assertEquals(true, result);
       }
      
       public void testDoCheckFail() {

              LoginDAO loginDAO = new LoginDAO(connection);
      
              Login login = new Login();
              login.setUserId("tokyo");
              login.setPassword("osaka");
             
              boolean result = loginDAO.doCheck(login);
             
              assertEquals(false, result);
       }

       public void testCreate() {
              //TODO: implement
       }
     
       public void testUpdate() {
              //TODO: implement
       }
      
       @Override
       protected void tearDown() throws Exception {
              super.tearDown();
              connection.close();
       }


No comments:

Post a Comment