]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - support/doc/development/server/code.md
Adding dependencies informations for CentOS 7 (#288)
[github/Chocobozzz/PeerTube.git] / support / doc / development / server / code.md
... / ...
CommitLineData
1# Server code documentation
2
3The server is a web server developed with [TypeScript](https://www.typescriptlang.org/)/[Express](http://expressjs.com).
4
5
6## Technologies
7
8 * [TypeScript](https://www.typescriptlang.org/) -> Language
9 * [PostgreSQL](https://www.postgresql.org/) -> Database
10 * [Redis](https://redis.io/) -> Job queue/cache
11 * [Express](http://expressjs.com) -> Web server framework
12 * [Sequelize](http://docs.sequelizejs.com/en/v3/) -> SQL ORM
13 * [WebTorrent](https://webtorrent.io/) -> BitTorrent tracker and torrent creation
14 * [Mocha](https://mochajs.org/) -> Test framework
15
16
17## Files
18
19The server main file is [server.ts](/server.ts).
20The server modules description are in the [package.json](/package.json) at the project root.
21All other server files are in the [server](/server) directory:
22
23 server.ts -> app initialization, main routes configuration (static routes...)
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...)
30 |__ lib -> library function (WebTorrent, OAuth2, ActivityPub...)
31 |__ middlewares -> middlewares for controllers (requests validators, requests pagination...)
32 |__ models -> Sequelize models for each SQL tables (videos, users, accounts...)
33 |__ tests -> API tests and real world simulations (to test the decentralized feature...)
34
35
36## Conventions
37
38Uses [JavaScript Standard Style](http://standardjs.com/).
39
40## Architecture
41
42The server is composed by:
43
44 * a REST API (Express framework)
45 * a WebTorrent Tracker
46
47A video is seeded by the server with the [WebSeed](http://www.bittorrent.org/beps/bep_0019.html) protocol (HTTP).
48
49![Architecture scheme](/support/doc/development/server/upload-video.png)
50
51When a user uploads a video, the rest API create the torrent file and then adds it to its database.
52
53If 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.
54
55## Newcomers
56
57The server entrypoint is [server.ts](/server.ts). You can begin to look at this file.
58Then you can try to understand the [controllers](/server/controllers): they are the entrypoint of each API request.