Created Project Architecture (markdown)

Risto Lahtela 2019-10-30 14:59:18 +02:00
parent 41deb84c10
commit 3653353ac5
1 changed files with 66 additions and 0 deletions

66
Project-Architecture.md Normal file

@ -0,0 +1,66 @@
![Plan Header](https://puu.sh/AXSg7/5f2f78c06c.jpg)
# Project Architecture (How the plugin is put together)
This page attempts to help new developers start contributing to Plan.
It does not go over the build tool & commands for building as those are detailed in [[Project Setup]].
Page version: **5.0 build 263** [Commit](https://github.com/plan-player-analytics/Plan/commit/f061d4007990be811f2bf622abe23da815d3a1fb)
### Table of contents
- Java
- Modules & Dependencies between modules
- Dagger & Dependency injection
- Structure outline of `common`-module
- About Platform APIs
- Web dev
- Technology stack
- Template-like html
- Static Resources
# Modules & Dependencies between modules
Module | Role
-- | --
`api` | Contains code for [public API](https://github.com/plan-player-analytics/Plan/wiki/APIv5) interface classes
`extensions` | Contains built-in extensions that use DataExtension API (in public API)
`common` | Main package for everything
`bukkit`, `bungee`, `sponge`, `velocity` | Platform specific modules
`plugin` | Creates a single jar out of the modules
Most of the time work is done in `common` module as platforms are abstracted away.
## Build order
`api` -> `extensions` -> `common` -> `bukkit`, `bungee`, `sponge`, `velocity` -> `plugin`
From the build order, the dependencies between the modules should be apparent.
# Dagger & Dependency Injection
Dagger (https://dagger.dev/) is used extensively around the project.
It was used as a remedy to reduce static usage. (*See decisions here [Refactor plugin to use static getters](https://github.com/plan-player-analytics/Plan/wiki/Architectural-Decision-Records#411---417-3rd-dec-2017---2nd-march-2018) and [Dependency Injection: Dagger](https://github.com/plan-player-analytics/Plan/wiki/Architectural-Decision-Records#450-11-august-2018---27-october-2018)*)
`@Singleton` annotations are used to tell Dagger that only a single instance should exist per initialized Component (So that each `PlanSystem` only has one `DatabaseSystem` instead of returning a new one every time the database is needed.)
`@Inject` annotations are used in Constructors to tell Dagger to resolve the dependencies for constructing a new instance of this class.
Note that the Inject constructors allow Injecting an instance of the class the constructor is in to another object:
```
public class Foo {
@Inject
public Foo() {}
}
public class Bar {
@Inject
public Bar(Foo foo) {}
}
```
This is the main mechanism used for instantiating different system level objects, more about those below.
# Structure outline of `common`-module
*Under construction*