deme architecture

42
Architecture Implementation Deme Architecture Todd Davies Mike Mintz Stanford University Silicon Valley Code Camp, 2008 Davies, Mintz Deme Architecture

Upload: others

Post on 03-Feb-2022

8 views

Category:

Documents


0 download

TRANSCRIPT

ArchitectureImplementation

Deme Architecture

Todd Davies Mike Mintz

Stanford University

Silicon Valley Code Camp, 2008

Davies, Mintz Deme Architecture

ArchitectureImplementation

Outline

1 ArchitectureItem StructureItem OntologyViewers

2 Implementation

Davies, Mintz Deme Architecture

ArchitectureImplementation

Outline

1 ArchitectureItem StructureItem OntologyViewers

2 Implementation

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Outline

1 ArchitectureItem StructureItem OntologyViewers

2 Implementation

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

What is an item?

All persistent data abstracted as itemsE.g., documents, users, settings, etc.

Items are instances of “item types”Item types specify structure of fieldsItems provide values for fields

E.g. “Person” is item type, “Mike” and “Todd” are items ofthat typeFirst Name Last Name

Mike MintzTodd Davies

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

What is an item?

All persistent data abstracted as itemsE.g., documents, users, settings, etc.

Items are instances of “item types”Item types specify structure of fieldsItems provide values for fields

E.g. “Person” is item type, “Mike” and “Todd” are items ofthat typeFirst Name Last Name

Mike MintzTodd Davies

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

What is an item?

All persistent data abstracted as itemsE.g., documents, users, settings, etc.

Items are instances of “item types”Item types specify structure of fieldsItems provide values for fields

E.g. “Person” is item type, “Mike” and “Todd” are items ofthat typeFirst Name Last Name

Mike MintzTodd Davies

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Item inheritance

Item types can inherit from other item types“Item” is at top of the hierarchyE.g., Item -> Document -> Comment

Item types inherit existing fields, add additional fieldsItem: name, descriptionDocument: name, description, bodyComment: name, description, body, commented_item

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Item inheritance

Item types can inherit from other item types“Item” is at top of the hierarchyE.g., Item -> Document -> Comment

Item types inherit existing fields, add additional fieldsItem: name, descriptionDocument: name, description, bodyComment: name, description, body, commented_item

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Outline

1 ArchitectureItem StructureItem OntologyViewers

2 Implementation

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Overview

AgentsCollectionsDocumentsRelationshipsPermissionsURLs

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

All Items

All items share metadata structure:Unique IDNameDescriptionCreator / Create TimeUpdater / Update TimeVersionsTrashed?

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Agents

AgentsItem that can “do” things

(Given permissions, can appear as creator/updater)

Application user is always a specific AgentSubclasses: Person, AnonymousAgent, Group

GroupsCollection of AgentsMembers can share common permissions

AccountsChannel of authenticationSubclasses: PasswordAccount, OpenId

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Agents

AgentsItem that can “do” things

(Given permissions, can appear as creator/updater)

Application user is always a specific AgentSubclasses: Person, AnonymousAgent, Group

GroupsCollection of AgentsMembers can share common permissions

AccountsChannel of authenticationSubclasses: PasswordAccount, OpenId

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Agents

AgentsItem that can “do” things

(Given permissions, can appear as creator/updater)

Application user is always a specific AgentSubclasses: Person, AnonymousAgent, Group

GroupsCollection of AgentsMembers can share common permissions

AccountsChannel of authenticationSubclasses: PasswordAccount, OpenId

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Collections

ItemSetsArbitrary collection of itemsSubclasses: Folio

FolioEvery group has one folioContains items shared among all members

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Collections

ItemSetsArbitrary collection of itemsSubclasses: Folio

FolioEvery group has one folioContains items shared among all members

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Documents

Main unit of collaborative workDifferent item types for different formatsSubclasses

TextDocumentHtmlDocumentDjangoTemplateDocumentComment

FileDocumentImageDocument

Comments refer to other ItemsSometimes specific versions and locations

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Documents

Main unit of collaborative workDifferent item types for different formatsSubclasses

TextDocumentHtmlDocumentDjangoTemplateDocumentComment

FileDocumentImageDocument

Comments refer to other ItemsSometimes specific versions and locations

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Documents

Main unit of collaborative workDifferent item types for different formatsSubclasses

TextDocumentHtmlDocumentDjangoTemplateDocumentComment

FileDocumentImageDocument

Comments refer to other ItemsSometimes specific versions and locations

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Relationships

Explicit items for relationships between itemsSubclasses: GroupMembership, ItemsetMembership

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Permissions

Specifies who can do what to which itemsAgentAbilityItem

Three levelsDirectGroupwideDefault

RolesCustomizable sets of abilities

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Permissions

Specifies who can do what to which itemsAgentAbilityItem

Three levelsDirectGroupwideDefault

RolesCustomizable sets of abilities

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Permissions

Specifies who can do what to which itemsAgentAbilityItem

Three levelsDirectGroupwideDefault

RolesCustomizable sets of abilities

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Custom URLs

Users can create custom URLs to point to itemsEach domain can have separate namespace of URLs

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Custom URLs

Users can create custom URLs to point to itemsEach domain can have separate namespace of URLs

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Outline

1 ArchitectureItem StructureItem OntologyViewers

2 Implementation

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

What is a viewer?

A Django class that processes browser or API requestsURLs that begin with /resource/ are routed to viewersViewers handle items of specific typeViewers inherit from other viewers

Everything ultimately inherits from ItemViewerItemViewer is about 80% of view code

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

What is a viewer?

A Django class that processes browser or API requestsURLs that begin with /resource/ are routed to viewersViewers handle items of specific typeViewers inherit from other viewers

Everything ultimately inherits from ItemViewerItemViewer is about 80% of view code

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

What is a viewer?

A Django class that processes browser or API requestsURLs that begin with /resource/ are routed to viewersViewers handle items of specific typeViewers inherit from other viewers

Everything ultimately inherits from ItemViewerItemViewer is about 80% of view code

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

What is a viewer?

A Django class that processes browser or API requestsURLs that begin with /resource/ are routed to viewersViewers handle items of specific typeViewers inherit from other viewers

Everything ultimately inherits from ItemViewerItemViewer is about 80% of view code

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

RESTful URLs

Entry actions/resource/<viewer>/<id>/<action>E.g., /resource/person/5/editE.g., /resource/person/5

Collection actions/resource/<viewer>/<action>E.g., /resource/person/newE.g., /resource/personE.g., /resource/person.json

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

RESTful URLs

Entry actions/resource/<viewer>/<id>/<action>E.g., /resource/person/5/editE.g., /resource/person/5

Collection actions/resource/<viewer>/<action>E.g., /resource/person/newE.g., /resource/personE.g., /resource/person.json

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Authentication

There is always an authenticated agent in a viewer(If user does not log in, it is AnonymousAgent.)

Viewer takes care of checking permissions forauthenticated agent

Davies, Mintz Deme Architecture

ArchitectureImplementation

Item StructureItem OntologyViewers

Authentication

There is always an authenticated agent in a viewer(If user does not log in, it is AnonymousAgent.)

Viewer takes care of checking permissions forauthenticated agent

Davies, Mintz Deme Architecture

ArchitectureImplementation

Deme is written in Django

Deme is:A collection of Django modelsA system of hierarchical viewers that use Django templatesAdditional components that handle Deme-specific features

VersioningPermissionsCommenting

Davies, Mintz Deme Architecture

ArchitectureImplementation

Why Django?

Big developer communityNow supports multi-table inheritance

Davies, Mintz Deme Architecture

ArchitectureImplementation

Models –> Item types

A Django model corresponds to an item typeAn item is:

A Django model instanceA row in a table

Davies, Mintz Deme Architecture

ArchitectureImplementation

Models –> Item types

A Django model corresponds to an item typeAn item is:

A Django model instanceA row in a table

Davies, Mintz Deme Architecture

ArchitectureImplementation

Database Visual

Davies, Mintz Deme Architecture

ArchitectureImplementation

Versioning

Every table has a dual version-table

PersonID First Name Last Name1 Mike Mintz

PersonVersionID Version First Name Last Name1 1 Michael Mintz1 2 Mike Mintz

Davies, Mintz Deme Architecture

ArchitectureImplementation

Demo time!

Davies, Mintz Deme Architecture