Docs‎ > ‎Overview‎ > ‎

Building a REST Server

Building a REST server for SQL data takes time. Use this summary to compare a traditional process with API Creator.


If you are using a framework that automates the persistence, caching, REST listeners, JSON mapping, etc, a moderate 100-table system requires in excess of 70,000 lines of code using a conventional approach. Live API Creator expresses this is 1,500 lines. This is a useful comparison, but it only begins to tell the story. At least as much time is spent in design as coding, which is largely eliminated from requirements capture. Automatic re-use affects maintenance since logic changes are automatically re-ordered and applied to all use cases.

 Activity Description API Creator  
 Hardware   Procure machines for DB and REST server, install OS, etc.Optional for a service or on-premises appliance
 Define Database Build database (define tables, columns, referential integrity)Required
 REST Listener Use framework (e.g, Jersey) to listen for REST requests, and supply REST logic.Automated
 SQL
 Build SQL Requests 
 JSON
 Map JSON/SQL data 
 Security
 Ensure reads/changes to data respect security requirements 
 Authentication
 Ensure User/Password is valid, determine authorized roles 
 Authorization
 Inject Security into every read request to filter rows/columns on read (leveraging SQL filtering for to minimize DBMS trips), and protect data on update 
 Multi-table Rest Resource
 To reduce latency 
 Design
 Determine data to be returned 
 Build
 Build (including Security enforcement) 
 Logic
 Supply database integrity logic for validations, derivations, and actions such as email or auditing 
 Object Model
 Build an Object Model for Domain Objects (e.g., JPA) to provide accessors for attributes and related data

See the example at the bottom of this page.  Each such object requires appx 200 lines of code (20,000 for our 100 table system)
 
 Persistence
 Map object retrievals and updates to SQL, with caching for performance and consistency (provided by JPA, hand-coded with jdbc/odbc) 
 Logic
 Use the Object Model. 
 Logic Analysis
 Identify Requirements for derivations, validations, actions 
 Logic Design
 Identify Use Cases affected by Requirement (e.g., OrderTotal definition affects inserting Line Items, deleting Line Items, changing Line Item Quantity, and Part Number) 
 Resource Mapping
 Resource / Object Mapping (de-alias, de-project attributes, to re-use Object Model Logic) 
 Code Object Behavior
 Supply logic 

Our experience suggests at least 500 lines of code per table (50,000 for our 100 table system)
 
 Change Detection
 Build logic to detect changes (e.g., detect change in Line Item Quantity), including intricate multi-attribute changes (e.g., change to LineItem Quantity and Part Number) 
 Change Propagation
 Adjust Order Total, Customer Balance 
 Logic Ordering
 Ensure the Propagation respects logic dependencies (a greater concern during maintenance / iterations) 
 Data Explorer          
  AngularJS (HTML/CSS) layout of Grid/Scalar and Child Tabs    Read Metadata