Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blog] Extension Framework Game Plan #50

Merged
merged 1 commit into from
Apr 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions _posts/2016-04-05-extension-framework-game-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
layout: post
cover: 'assets/images/general-cover-3.jpg'
title: Extension Framework Game Plan
tags: docs
subclass: 'post tag-docs'
categories: 'elixir'
author: 'Pikender'
navigation: true
logo: 'assets/images/nectar-cart.png'
---

>
The post belongs to _NectarCommerce and Extension Framework Awareness_ Series
>
1. _[NectarCommerce Vision](http://vinsol.com/blog/2016/04/08/nectarcommerce-vision/)_
1. **Extension Framework Game Plan**
1. Introduction to MetaProgramming
1. Running Multiple Phoenix Apps Together
1. Ecto Model Schema Extension
1. Ecto Model Support Functions Extension
1. Phoenix Router Extension
1. Phoenix View Extension
1. Extension Approach Explained
1. Developer Experience and Workflow developing Favorite Product Extension
1. Developer Experience and Workflow testing Favorite Product Extension

## What will be NectarCommerce

>
Off-the-shelf Opensource E-commerce application for building online store.
>
Provides an Extension Framework to support features not included in core as extensions.
>
Strives for un-obstrusive parallel development of NectarCommerce and Extensions

NectarCommerce is committed to provide a ready-to-use e-commerce solution but definition of 100% is different under different business domains. It aims to solve common use-cases as part of the project and relying on extension framework to tap the rest.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to keep this part in every blog post?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

## Extension Framework Game Plan

Let's validate and list the capabilities needed in Extension Framework through an **extension** which provides feature **to mark a product as user's favorite**

_**Favorite Product Extension Requirements:**_

- **Ability to mark and unmark a Product as favorite**
- a View _probably_ showing all products with Ability to mark/unmark product as favorite
- a controller action preparing the view
- a route exposing the controller / view through Web
- a controller action handling mark product as favorite
- a route exposing the controller / view through Web
- a controller action removing product from the list of favorites
- a route exposing the controller / view through Web
- a model interfacing with database to store product favorited by user
- a migration to create join table in database
- a join table storing product\_id and user\_id
- **Showing All Products favorited by a User**
- association in User to get favorite products
- a View showing list of Favorite Products
- a controller preparing the view
- a route exposing the controller / view through Web
- **Showing Users who favorited a particular Product**
- association in Product to get users who favorited
- a View showing list of Users who favorited
- a controller preparing the view
- a Route exposing the controller / view through Web
- Ability to test the integration of above mentioned requirements

**Let's break the above requirements into _two_ groups**

- Model layer changes
- Request layer changes

### Model Layer Changes

- Ability to mark and unmark a Product as favorite
- a model interfacing with database to store product favorited by user
- a migration to create join table in database
- a join table storing product_id and user_id
- Showing All Products favorited by a User
- association in User to get favorite products
- Showing Users who favorited a particular Product
- association in Product to get users who favorited

_**translates to**_

- Ability to mark and unmark a Product as favorite
- **New Ecto Model** with user\_id and product\_id fields
- **Ecto migration** to create join table storing product_id and user_id
- Showing All Products favorited by a User
- **extending User schema** to have associations as needed
- **support functions in User Model** to retrieve all products favorited by a user
- Showing Users who favorited a particular Product
- **extending Product schema** to have associations as needed
- **support functions in Product Model** too retrieve all users who favorited a product


### Request Layer Changes

- Ability to mark and unmark a Product as favorite
- a View probably showing all products with ability to mark/unmark product as favorite
- a controller action preparing the view
- a route exposing the controller / view through Web
- a controller action handling mark product as favorite
- a route exposing the controller / view through Web
- a controller action removing product from the list of favorites
- a route exposing the controllerontroller / view through Web
- Showing All Products favorited by a User
- a View showing list of Products
- a controller preparing the view
- already route exposing the controller / view through Web
- Showing Users who favorited a particular Product
- a View showing list of Users
- a controller preparing the view
- a route exposing the controller / view through Web

_**translates to**_

- Ability to mark and unmark a Product as favorite
- a **View** probably showing all products with ability to mark/unmark product as favorite
- a **controller** with index / create / delete action
- a **route** exposingposing index / create / delete action
- Showing All Products favorited by a User
- a **View** showing list of Products
- a **controller** preparing the viewew
- a **route** exposing the controller / view through Web
- Showing Users who favorited a particular Product
- a **View** showing list of Users
- a **controller** preparing the view
- a **route** exposing throughe controller / view through Web

## What we need

- way to extend schema definitions for existing models
- way to add new functions in existing models
- way to add routes
- way to add controller / views for newly added routes
- way to extend views
- way to reuse layouts
- way to reuse already available routes

## How we attempt to solve

- Elixir Metaprogramming
- Elixir umbrella app dependencies to share and reuse code among Nectar & Extensions using ExtensionManager
- Extensions as Phoenix project leveraging NectarCommerce

## Bridging the Gap

**Next Posts** would refer the *Favorite Product Extension* to help co-relate and reveal the challenges & solutions implemented to propose an Extension framework.

>
_Our aim with these posts is to start a dialog with the Elixir community on validity and technical soundness of our approach. We would really appreciate your feedback and reviews, and any ideas/suggestions/pull requests for improvements to our current implementation or entirely different and better way to do things to achieve the goals we have set out for NectarCommerce._

We look forward for your support and feedback on [twitter](https://twitter.com/NectarCommerce) and [github](https://github.com/vinsol/nectarcommerce/pull/47)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong github link? I think this should be the one- https://github.com/vinsol/nectarcommerce

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are asking for support and feedback so thought of adding the link of PR for same
but I still have to replace the link from #48 to #47 :)

_Enjoy the Elixir potion !!_