You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Directory for our GitHub actions and templates for issues and pull requests.
46
-
47
-
## `.platform`
48
-
49
-
Scripts for deploying to Platform.sh.
50
-
51
-
## `bin`
52
-
53
-
Executable shell scripts for various purposes, most notably building, testing, and running PostHog.
54
-
55
-
## `cypress`
56
-
57
-
Hosts our [Cypress](https://www.cypress.io/) tests. When writing tests that use Cypress, you will mostly be working on the `integration/` subdirectory. Remember that you should always be including tests if you are making a significant change to our frontend.
58
-
59
-
## `ee`
60
-
61
-
Enterprise Edition features for PostHog. This subdirectory is the only subdirectory not MIT-Licensed in the [PostHog/posthog](https://github.com/PostHog/posthog) repository, and a license is needed to use its features. To use PostHog with 100% FOSS code, refer to our [PostHog/posthog-foss](https://github.com/PostHog/posthog-foss) repository.
62
-
63
-
## `frontend`
64
-
65
-
Hosts the PostHog frontend, built with React.
66
-
67
-
### Subdirectories
68
-
69
-
#### `public`
70
-
71
-
PostHog logos to be used by the app.
72
-
73
-
#### `src`
74
-
75
-
Code for the frontend.
76
-
77
-
##### `src/layout`
78
-
79
-
Components referring to the overall PostHog app layout, such as sections of the app used in most pages, like `Sidebar.js`.
80
-
81
-
##### `src/lib`
82
-
83
-
Various components used all around the PostHog app. Reusable components will most likely be placed in this subdirectory, such as buttons, charts, etc.
84
-
85
-
##### `src/models`
86
-
87
-
[Kea](https://github.com/keajs/kea) models for the app's state.
38
+
## Key directories
88
39
89
-
##### `src/scenes`
40
+
###`frontend`
90
41
91
-
Components referring to specific pages of the PostHog app. Mostly non-reusable.
42
+
The PostHog web application, built with React and TypeScript. Uses [Kea](https://github.com/keajs/kea) for state management.
92
43
93
-
##### `src/styles`
44
+
-`src/lib` – Reusable components and utilities
45
+
-`src/scenes` – Page-specific components organized by feature
46
+
-`src/queries` – Query builder and data visualization components
47
+
-`src/toolbar` – Code for the [PostHog Toolbar](/docs/user-guides/toolbar)
94
48
95
-
[Sass](https://sass-lang.com/) files for the PostHog app's style.
49
+
### `posthog`
96
50
97
-
##### `toolbar`
51
+
The Django backend application. Key subdirectories:
98
52
99
-
All code related exclusively to the [PostHog Toolbar](/docs/user-guides/toolbar).
53
+
-`api` – REST API endpoints and serializers
54
+
-`clickhouse` – ClickHouse schema definitions and migrations
55
+
-`hogql` – HogQL query language compiler and executor
56
+
-`models` – Django ORM models (PostgreSQL)
57
+
-`tasks` – Celery background tasks
100
58
101
-
##`livestream`
59
+
### `products`
102
60
103
-
The live events API, a Golang service (used in the Live tab of Activity in the app).
61
+
Product-specific code organized as **vertical slices**. Each product folder contains its own backend (Django app), frontend (React), and optionally shared code. This structure allows features to evolve independently.
104
62
105
-
## `posthog`
106
-
107
-
Hosts the PostHog backend, built with Django.
108
-
109
-
### Subdirectories
110
-
111
-
#### `api`
112
-
113
-
Subdirectory for PostHog's REST API. Includes its own tests.
114
-
115
-
#### `management`
116
-
117
-
Custom [Django management commands](https://docs.djangoproject.com/en/3.1/howto/custom-management-commands/). Commands defined here are registered as `manage.py` commands and can be called with:
118
-
119
-
```bash
120
-
./manage.py <your_command_here>
121
-
# or
122
-
python manage.py <your_command_here>
123
-
```
124
-
125
-
These commands are for admin use only, and generally refer to the configuration of your Django app.
126
-
127
-
#### `migrations`
128
-
129
-
Hosts the database migrations which occur when there are changes to the models. If you make any changes to the app's ORM, you need to first make migrations:
130
-
```
131
-
python manage.py makemigrations
132
-
```
133
-
134
-
And after making your own migrations or running `git pull` after new migrations, you also need to apply them:
135
-
```
136
-
python manage.py migrate
137
-
```
138
-
139
-
#### `ClickHouse Migrations`
140
-
141
-
To create boilerplate for clickhouse migrations use
142
-
```
143
-
python manage.py create_ch_migration --name <name of migration>
144
-
```
145
-
146
-
To apply clickhouse migrations use
147
-
```
148
-
python manage.py migrate_clickhouse
149
-
```
63
+
See the [products README](https://github.com/PostHog/posthog/blob/master/products/README.md) for detailed conventions.
150
64
151
-
#### `models`
65
+
###`plugin-server`
152
66
153
-
Subdirectory for the models ([Django ORM](https://docs.djangoproject.com/en/3.1/topics/db/models/)). Interactions with our database are handled by these models.
67
+
Node.js service responsible for:
68
+
- Event ingestion and processing
69
+
- Running plugins and data pipelines
70
+
- Webhook delivery
154
71
155
-
#### `queries`
72
+
###`rust`
156
73
157
-
Hosts the queries used to query data from our database, which will be used by our various features, such as [Retention](/docs/user-guides/retention) and [Trends](/docs/user-guides/trends).
74
+
High-performance Rust services including:
75
+
-`capture` – Event capture endpoint
76
+
-`feature-flags` – Feature flag evaluation
77
+
-`cymbal` – Error tracking symbolication
78
+
- Various workers and utilities
158
79
159
-
#### `tasks`
80
+
###`common`
160
81
161
-
Celery tasks that happen in the "background" of the server to enhance PostHog's performance by preventing long processes from blocking the main thread. An example of task is processing events as they come in.
82
+
Shared code used across the codebase:
83
+
-`hogql_parser` – HogQL parser (C++)
84
+
-`hogvm` – Hog virtual machine
85
+
-`tailwind` – Shared Tailwind configuration
162
86
163
-
#### `templates`
87
+
###`ee`
164
88
165
-
[Django templates](https://docs.djangoproject.com/en/3.1/topics/templates/) used to generate dynamic HTML. We use templates for pages such as `/login` and `/setup_admin`.
89
+
Enterprise Edition features. This directory has a [separate license](https://github.com/PostHog/posthog/blob/master/ee/LICENSE) - not MIT. For 100% FOSS code, see [PostHog/posthog-foss](https://github.com/PostHog/posthog-foss).
166
90
167
-
#### `test`
91
+
###`playwright`
168
92
169
-
Subdirectory hosting our backend tests. You should always include tests when you make changes to our backend.
93
+
End-to-end tests using [Playwright](https://playwright.dev/). Tests live in the `e2e/` subdirectory.
170
94
171
-
### `requirements`
95
+
### `livestream`
172
96
173
-
Hosts our backend's dev requirements.
97
+
Golang service powering the live events feed in the Activity tab.
0 commit comments