Git Product home page Git Product logo

cars_sample_app's Introduction

Cars Sample App Readme

This is a simple web app which provides for a Super car store which has a couple of performance/code issues. The app can be build with Maven.

Architecture

The app is based on a Angular 1 front end, calling back to RESTful services, base on Jersey, with a MySQL back end.

image

There is also a iOS mobile app which uses the same REST endpoints. This app is described in it's own README.

The internals of the web app are fairly simple. The packages in the code are:

  • com.supercars - Contains classes to describe the different business entities, e.g. car, manufacturer etc.
  • com.supercars.dataloader - Classes to access the DB and retrieve or persist the different business entities
  • com.supercars.externaldata - Classes to retrieve data from 3rd party services of HTTP - This is where the fuel prices come from on the home page
  • com.supercars.logging - Classes for custom logging, used to help with exercises for AppDynamics
  • com.supercars.rest - Classes which exposes the REST services
  • com.supercars.usermanagement - Classes for user management

A JSP Page

There is one application page which isn't Angular, but is a standalone JSP page this is "/Cars_Sample_App/angular/tuner.jsp". This page is access using the links from the performance accessories section on the home page:

image

Database

The app uses a MySQL DB in the backend, this be default is expected to be the "supercars" schema, and MySQL running locally to the app. The schema build is in src/main/resources/db/mysql.sql. Execute this script against the schema you create in MySQL.

The datasouce is defined in context.xml in src/webapp/META-INF

Building

This app uses Maven for the build. To get a build environment working:

  1. Have git installed and working
  2. Get Maven installed
    1. Get the tar.gz or zip package from the Maven site
    2. Unpack somewhere on your file system, e.g. "/opt/maven/apache-maven-3.3.9/"
    3. Add the Maven bin directory to your path, e.g. in "vi .bash_profile" add:
      
       export M2_HOME=/opt/maven/apache-maven-3.3.9
       export M2=$M2_HOME/bin
       export PATH=$PATH:$M2
       
    4. Login and out of your shell to get the new path
    5. Test using the command "mvn". This should run Maven and indicate "Build Failure"
  3. Use git to get the source code
    
     git clone https://github.com/tombatchelor/Cars_Sample_App.git
     
  4. Change to the Cars_Sample_App directory and then execute the following for the build
    
     mvn install
     
  5. This should run and leave "Cars_Sample_App.war" in the "target/" directory

It is also possible to have Maven auto deploy right into Tomcat.

  1. First step is to configure a user for the Tomcat Manager. In "$TOMCAT_HOME/conf/tomcat-users.xml" add a line line the following:
    
     <user username="user" password="pass" roles="manager-script,manager-gui"/>
     
  2. Restart Tomcat
  3. Update our Maven config with this information. This is in the file "$M2_HOME/conf/settings.xml".
    1. Locate the "<servers>" tag
    2. Inside here add a server entry like the following:
    
     <server>
       <id>Tomcat</id>
       <username>user</username>
       <password>pass</password>
     </server>
     
    1. Note that the user/pass must match what you set in the Tomcat config
  4. Now go back to the Cars_Sample_App source. Instead of "mvn install", the following will build and deploy:
    
     mvn tomcat7:deploy
     
  5. If the app is already deployed into the Tomcat the following will build and re-deploy
    
     mvn tomcat7:redeploy
     
  6. Now the app is available on "/Cars_Sample_App/angular/index.jsp" on your Tomcat

cars_sample_app's People

Contributors

tombatchelor avatar

Watchers

Sami Begg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.