flag0ut is a powerful feature flag management tool designed for modern development teams. It provides a centralized dashboard to manage, monitor, and optimize feature rollouts with ease. With features like percentage-based rollouts, role-based targeting, and AI-powered insights, flag0ut empowers developers to ship features fearlessly.
You can check out the live demo of the application here.
- User Authentication: Secure user authentication powered by Clerk.
- Feature Flag Management: Full CRUD functionality for feature flags.
- Percentage-based Rollouts: Gradually release features to a specific percentage of your users.
- Role-based Targeting: Target specific user segments like
BETA
,INTERNAL
, orPREMIUM
users. - API Key Management: Generate and manage API keys to securely interact with the flag0ut API.
- Recent Activity Tracking: Keep track of all the changes made to your feature flags.
- Dashboard: An intuitive dashboard with key metrics and recent activity.
- Framework: Next.js
- Styling: Tailwind CSS
- UI Components: shadcn/ui
- Authentication: Clerk
- Database: PostgreSQL
- ORM: Prisma
- API Communication: TanStack Query & Axios
- Schema Validation: Zod
The project follows a standard Next.js App Router structure.
/src
├── app
│ ├── (authenticated) # Protected routes
│ ├── (unauthenticated) # Public routes
│ └── api # API routes
├── components
│ ├── application # Application-specific components
│ └── ui # Reusable UI components
├── context # React context providers
└── lib # Libraries, helpers, and utilities
├── axios # Axios instance configuration
├── tanstack # TanStack Query configuration
│ ├── api # API call definitions
│ └── hooks # Custom hooks for API calls
└── zod-schemas # Zod schemas for validation
This endpoint allows you to evaluate a feature flag for a given user.
- URL:
/api/v1/flags/evaluate
- Method:
GET
- Headers:
X-flagout-key
: Your API key.
- Query Parameters:
slug
(string, required): The slug of the feature flag.user_role
(string, optional): The role of the user (e.g.,BETA
,PREMIUM
).user_id
(string, required): A unique identifier for the user.
To get a local copy up and running, follow these simple steps.
- Node.js (v18 or higher)
- npm or yarn
- PostgreSQL
-
Clone the repository:
git clone https://github.com/Sreejit-Sengupto/flagout.git cd flagout/client
-
Install dependencies:
npm install
-
Set up environment variables:
Create a
.env.local
file in the root of theclient
directory and add the following environment variables:DATABASE_URL="your_postgresql_database_url" NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="your_clerk_publishable_key" CLERK_SECRET_KEY="your_clerk_secret_key"
-
Run database migrations:
npx prisma migrate dev --name init
-
Run the development server:
npm run dev
This project follows a structured approach for making API calls and managing server state, primarily using TanStack Query.
-
API Call Definition:
All API calls are defined in the
src/lib/tanstack/api
directory. Each file corresponds to a specific resource (e.g.,feature-flag.ts
,api-key.ts
). These functions use anaxios
instance and define the return types for the API responses. -
TanStack Query Hooks:
For each API call, a corresponding custom hook is created in the
src/lib/tanstack/hooks
directory. These hooks use theuseQuery
oruseMutation
hooks from TanStack Query to manage the server state, caching, and re-fetching logic. -
Component Usage:
Components then use these custom hooks to fetch and display data, or to trigger mutations. This pattern keeps the data fetching logic separate from the UI components, making the code more modular and easier to maintain.
-
Schema Validation:
Zod is used for schema validation on both the client and server sides. Zod schemas are defined in the
src/lib/zod-schemas
directory. -
Custom API Errors:
A custom
ApiError
class is used to handle API errors in a structured way. This allows for consistent error handling across the application.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.