]>
Commit | Line | Data |
---|---|---|
00ffc03e C |
1 | # Server code documentation |
2 | ||
69f616ab | 3 | The server is a web server developed with [TypeScript](https://www.typescriptlang.org/)/[Express](http://expressjs.com). |
00ffc03e C |
4 | |
5 | ||
6 | ## Technologies | |
7 | ||
69f616ab | 8 | * [TypeScript](https://www.typescriptlang.org/) -> Language |
7e6afafd | 9 | * [PostgreSQL](https://www.postgresql.org/) -> Database |
94a5ff8a | 10 | * [Redis](https://redis.io/) -> Job queue/cache |
00ffc03e | 11 | * [Express](http://expressjs.com) -> Web server framework |
7e6afafd | 12 | * [Sequelize](http://docs.sequelizejs.com/en/v3/) -> SQL ORM |
82e62423 | 13 | * [WebTorrent](https://webtorrent.io/) -> BitTorrent tracker and torrent creation |
00ffc03e C |
14 | * [Mocha](https://mochajs.org/) -> Test framework |
15 | ||
16 | ||
17 | ## Files | |
18 | ||
afe81767 C |
19 | The server main file is [server.ts](/server.ts). |
20 | The server modules description are in the [package.json](/package.json) at the project root. | |
21 | All other server files are in the [server](/server) directory: | |
00ffc03e | 22 | |
2bb0f9d5 | 23 | server.ts -> app initialization, main routes configuration (static routes...) |
00ffc03e C |
24 | config -> server YAML configurations (for tests, production...) |
25 | scripts -> Scripts files for npm run | |
26 | server | |
27 | |__ controllers -> API routes/controllers files | |
28 | |__ helpers -> functions used by different part of the project (logger, utils...) | |
29 | |__ initializers -> functions used at the server startup (installer, database, constants...) | |
339632b4 | 30 | |__ lib -> library function (WebTorrent, OAuth2, ActivityPub...) |
00ffc03e | 31 | |__ middlewares -> middlewares for controllers (requests validators, requests pagination...) |
fcaf1e0a | 32 | |__ models -> Sequelize models for each SQL tables (videos, users, accounts...) |
00ffc03e C |
33 | |__ tests -> API tests and real world simulations (to test the decentralized feature...) |
34 | ||
35 | ||
36 | ## Conventions | |
37 | ||
38 | Uses [JavaScript Standard Style](http://standardjs.com/). | |
39 | ||
00ffc03e C |
40 | ## Architecture |
41 | ||
42 | The server is composed by: | |
43 | ||
a2431b7d | 44 | * a REST API (Express framework) |
00ffc03e | 45 | * a WebTorrent Tracker |
00ffc03e | 46 | |
a2431b7d | 47 | A video is seeded by the server with the [WebSeed](http://www.bittorrent.org/beps/bep_0019.html) protocol (HTTP). |
00ffc03e | 48 | |
afe81767 | 49 | ![Architecture scheme](/support/doc/development/server/upload-video.png) |
00ffc03e | 50 | |
7e6afafd | 51 | When a user uploads a video, the rest API create the torrent file and then adds it to its database. |
00ffc03e | 52 | |
82e62423 | 53 | If a user wants to watch the video, the tracker will indicate all other users that are watching the video + the HTTP url for the WebSeed. |
00ffc03e C |
54 | |
55 | ## Newcomers | |
56 | ||
afe81767 C |
57 | The server entrypoint is [server.ts](/server.ts). You can begin to look at this file. |
58 | Then you can try to understand the [controllers](/server/controllers): they are the entrypoint of each API request. |