Skip to content

Commit 55cc0df

Browse files
committed
docs: added readme and contribution guide
1 parent 1256d28 commit 55cc0df

2 files changed

Lines changed: 393 additions & 111 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
# Contributing to Flagix
2+
3+
Thank you for your interest in contributing! This guide explains how to get Flagix running locally and how to submit contributions.
4+
5+
## Prerequisites
6+
7+
Before you start, make sure you have the following installed or available:
8+
9+
- **Node.js** ≥ 18.x
10+
- **pnpm** ≥ 9.x (install with `npm i -g pnpm`)
11+
- **PostgreSQL** database (we use Neon)
12+
- **Redis** database (we use Upstash)
13+
- **Google**, **GitHub**, and **Discord** OAuth apps (for authentication)
14+
- **Resend** account (for email notifications)
15+
- **Tinybird** account (for analytics)
16+
17+
## Structure
18+
19+
This repository is a monorepo and is structured as follows:
20+
21+
```
22+
/
23+
├── apps/
24+
│ ├── api/ → Express.js API backend
25+
│ ├── web/ → Next.js dashboard
26+
│ └── docs/ → Documentation site
27+
├── packages/
28+
│ ├── db/ → Prisma schema + client
29+
│ ├── data-sync/ → Data synchronization utilities
30+
│ └── evaluation-core/ → Flag evaluation logic
31+
│ └── tinybird/ → Analytics pipeline configurations
32+
│ └── tsconfig/ → Shared TS config
33+
│ └── UI/ → UI components
34+
├── sdk/
35+
│ ├── javascript/ → JavaScript SDK
36+
│ └── react/ → React SDK
37+
├── .github/
38+
│ └── workflows/ → CI/CD configurations
39+
├── .npmrc
40+
├── biome.jsonc
41+
├── package.json
42+
├── pnpm-workspace.yaml
43+
├── turbo.json
44+
└── README.md
45+
```
46+
47+
### Apps
48+
49+
This directory contains the source code for all related applications:
50+
51+
- **api**: An Express.js app serving the REST API
52+
- **web**: A Next.js app for the dashboard
53+
- **docs**: A Next.js app for documentation
54+
55+
### Packages
56+
57+
Packages contain internal shared modules used across different applications:
58+
59+
- **db**: Database client and schema shared between applications
60+
- **data-sync**: Data synchronization utilities
61+
- **evaluation-core**: Core logic for flag evaluation and targeting
62+
- **tinybird**: Analytics pipeline configurations
63+
- **tsconfig**: Shared TS config
64+
- **UI**: UI components
65+
66+
### SDKs
67+
68+
Publicly published SDKs for integrating Flagix into applications:
69+
70+
- **javascript**: Vanilla JavaScript SDK
71+
- **react**: React-specific SDK
72+
73+
## Getting Started
74+
75+
### 1. Fork this repository
76+
77+
Visit the Flagix repository and click the "Fork" button in the top right.
78+
79+
### 2. Clone the fork to your local device
80+
81+
```bash
82+
git clone https://github.com/flagix-io/flagix.git
83+
cd flagix
84+
```
85+
86+
### 3. Add the original repo as upstream
87+
88+
```bash
89+
git remote add upstream https://github.com/flagix-io/flagix.git
90+
```
91+
92+
### 4. Install Dependencies
93+
94+
```bash
95+
pnpm install
96+
```
97+
98+
### 5. Configure Environment Variables
99+
100+
Each app has an example env file. You'll need to copy and fill those out:
101+
102+
```bash
103+
cp apps/api/.env.example apps/api/.env
104+
cp apps/web/.env.example apps/web/.env
105+
cp packages/db/.env.example packages/db/.env
106+
cp packages/data-sync/.env.example packages/data-sync/.env
107+
```
108+
109+
You'll need:
110+
111+
- A Postgres connection string (Neon)
112+
- Redis credentials (Upstash)
113+
- OAuth credentials (Google or github or discord)
114+
- A BetterAuth secret
115+
- Resend API key for emails
116+
- Tinybird token for analytics
117+
118+
### 6. Database Setup (Neon)
119+
120+
We use Neon for the database. Create a Neon project and copy your connection string for Prisma (ensure it includes `sslmode=require`).
121+
122+
Paste it into the relevant env files:
123+
124+
```bash
125+
# apps/api/.env
126+
DATABASE_URL="postgresql://<user>:<password>@<host>/<db>?sslmode=require"
127+
128+
# packages/db/.env
129+
DATABASE_URL="postgresql://<user>:<password>@<host>/<db>?sslmode=require"
130+
```
131+
132+
Run migrations:
133+
134+
```bash
135+
pnpm db:migrate
136+
```
137+
138+
### 7. Set up OAuth Providers
139+
140+
#### Google OAuth
141+
142+
1. Create a project in the Google Cloud Console
143+
2. Go to "APIs & Services" → "Credentials"
144+
3. Click "Create Credentials" → "OAuth client ID"
145+
4. Select "Web application"
146+
5. Add authorized redirect URI: `http://localhost:5000/api/auth/callback/google`
147+
6. Copy the Client ID and Client Secret to your env files
148+
149+
#### GitHub OAuth
150+
151+
1. Go to GitHub Settings → Developer settings → OAuth Apps
152+
2. Click "New OAuth App"
153+
3. Set Homepage URL: `http://localhost:3000`
154+
4. Set Authorization callback URL: `http://localhost:5000/api/auth/callback/github`
155+
5. Copy the Client ID and Client Secret to your env files
156+
157+
#### Discord OAuth
158+
159+
1. Go to the Discord Developer Portal and log in.
160+
2. Click "New Application" and give it a name (e.g., Flagix Dev).
161+
3. Navigate to "OAuth2" → "General" in the sidebar.
162+
4. Click "Add Redirect" and enter: `http://localhost:5000/api/auth/callback/discord`
163+
5. Click "Save Changes".
164+
6. Copy your Client ID and Client Secret to your env files.
165+
166+
### 8. Set up Redis
167+
168+
Flagix uses Redis for caching and real-time features. We use Upstash for serverless Redis:
169+
170+
1. Go to Upstash Console and sign in
171+
2. Click "Create Database"
172+
3. Give your database a name (e.g., flagix-redis)
173+
4. Select a region close to you
174+
5. Click "Create"
175+
6. Copy the REST URL and token to your env files:
176+
177+
```bash
178+
# apps/api/.env
179+
REDIS_URL=<YOUR_UPSTASH_REDIS_REST_URL>
180+
```
181+
182+
### 9. Set up Resend (Email)
183+
184+
1. Create an account at [Resend](https://resend.com)
185+
2. Get your API key from the dashboard
186+
3. Add it to your env file:
187+
188+
```bash
189+
# apps/api/.env
190+
RESEND_API_KEY=<YOUR_RESEND_API_KEY>
191+
```
192+
193+
### 10. Set up Tinybird (Analytics)
194+
195+
1. Create an account at [Tinybird](https://tinybird.co)
196+
2. Create a new project and get your token
197+
3. Add it to your env file:
198+
199+
```bash
200+
# apps/api/.env
201+
TINYBIRD_TOKEN=<YOUR_TINYBIRD_TOKEN>
202+
```
203+
204+
## Running the Apps
205+
206+
From the root you can run all apps:
207+
208+
```bash
209+
pnpm dev
210+
```
211+
212+
Or run individual apps:
213+
214+
```bash
215+
pnpm web:dev
216+
pnpm api:dev
217+
```
218+
219+
## Making Changes
220+
221+
### 1. Create a new branch
222+
223+
```bash
224+
git checkout -b feature/your-feature
225+
```
226+
227+
### 2. Code Style
228+
229+
Before committing your changes, run the lint command to catch any formatting errors:
230+
231+
```bash
232+
pnpm lint
233+
```
234+
235+
To fix formatting issues automatically:
236+
237+
```bash
238+
pnpm format
239+
```
240+
241+
### 3. Test your changes
242+
243+
Make sure they work and run a build:
244+
245+
```bash
246+
pnpm build
247+
```
248+
249+
### 4. Commit your changes
250+
251+
Use conventional commit messages:
252+
253+
```bash
254+
git commit -m "feat(api): add user targeting rules"
255+
git commit -m "fix(web): resolve flag toggle animation"
256+
git commit -m "docs: update SDK installation guide"
257+
```
258+
259+
## Pull Request Guidelines
260+
261+
- Your PR should reference an issue (if applicable) or clearly describe its impact
262+
- Include a clear description of the changes
263+
- Keep PRs small and focused. Large PRs are harder to review
264+
- Ensure consistency with the existing codebase
265+
- Include tests if applicable
266+
- Update documentation if your changes affect usage or API behavior
267+
268+
## Code Style
269+
270+
- Follow the existing code formatting in the project (use Biome for consistency)
271+
- Write clear, self-documenting code
272+
- Add comments only when necessary to explain complex logic
273+
- Use meaningful variable and function names
274+
- Follow TypeScript best practices
275+
276+
## Testing
277+
278+
- Run `pnpm build` to ensure all packages build successfully
279+
- Test your changes manually in the web interface
280+
- For SDK changes, test with the example applications
281+
- Ensure database migrations work correctly
282+
283+
## Reporting Issues
284+
285+
- Use the GitHub issue tracker
286+
- Provide a clear description of the issue
287+
- Include steps to reproduce the issue
288+
- Add relevant logs or screenshots
289+
290+
Feel free to send in prss!
291+
Thank you for contributing!

0 commit comments

Comments
 (0)