A production-ready, feature-based architecture for React — built with Vite, TypeScript, TanStack Query, and shadcn/ui.
- ⚡ Vite – lightning-fast bundler
- ⚛️ React 19.2 + TypeScript – latest React features with the React Compiler
- 🎨 shadcn/ui – atomic UI components
- 🔁 TanStack Query – client-state & caching
- 🌐 Axios – centralized API handling
- 🔐 Feature-based routing
- 🧩 Reusable UI & shared components
Most projects collapse under their own weight because they group files by technical type (e.g., all hooks in one folder, all components in another). This leads to:
- Scattered logic: Business logic for a single feature is spread across multiple folders.
- Tight coupling: Changes in one area ripple unpredictably through the codebase.
- Scaling pain: Adding new features becomes a game of "Where does this go?"
This boilerplate enforces Feature-Based Architecture to solve these problems.
| Benefit | Description |
|---|---|
| Encapsulation | Logic for auth or settings is isolated. Changes in one cannot break the other. |
| Scalability | Add 50+ features without the src/components folder becoming unmanageable. |
| Speed | Developers find everything related to a domain in one folder. No hunting across the tree. |
| Safety | Removing a feature is as simple as deleting one folder. |
├── components/
│ ├── ui/ # Atomic shadcn components (No business logic)
│ └── shared/ # App-specific reusable components (Modals, Tables)
├── features/ # Modular business logic (Auth, Settings, etc.)
├── pages/ # Route-level composition layer (Thin wrappers, no business logic)
├── config/ # API Clients, TanStack keys, and Env config
├── router/ # Split routing (Admin, Auth, Public)
├── hooks/ # Domain-agnostic hooks (e.g., use-debounce)
├── types/ # Global API and Model interfaces
└── utils/ # Browser helpers (LocalStorage, Icon mapping)
features/
└── auth/
├── components/ # Feature-specific UI
├── hooks/ # Feature hooks (useLogin)
├── api.ts # Axios requests
└── types.ts # Interfaces & types
features/: The heart of the app. Contains feature-specific components, hooks, and API logic. Features should not depend on other features "sideways."config/: Centralizes setup logic. Includesaxios-instance.tsfor interceptors and tanstack-keys.ts for standardized caching.pages/: These are "thin" wrappers. They handle layout and compose various features but contain zero business logic.router/: Explicitly split intoauth-routes.tsx,admin-routes.tsx, etc., to make access control readable.
User Action → Page (layout & composition) → Feature Hook (business logic) → API Client → Axios Instance (interceptors, tokens, error handling) → Backend Response → TanStack Query Cache → Feature Layer → UI Update
This boilerplate uses a centralized API layer to ensure predictable data flow:
-
axios-instance.ts: Pre-configured with interceptors for token injection and error handling. -
api-endpoints.ts: The single source of truth for all backend URLs. -
tanstack-keys.ts: Centralized query keys to prevent cache-busting bugs and duplication. -
api-types.ts: Contract-first development with strict TypeScript interfaces for all responses.
This boilerplate is configured to handle multiple environments out-of-the-box using Vite's built-in mode detection. This eliminates the manual headache of switching URLs between local development and live production.
.env.development: Automatically loaded duringbun run dev. Use this for your local or staging API URLs..env.production: Automatically loaded duringbun run build. Use this for your live production endpoints..env.example: A template file containing all required keys. Always keep this updated for new collaborators.
Note: Never commit .env.development or .env.production to version control. They are already included in the .gitignore to protect your secrets.
In your code, access environment variables using Vite’s built-in import.meta.env:
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL;
// or using config helper
import { env } from "@/config/env";
const apiBaseUrl = env.VITE_API_BASE_URL;-
Developers building production-grade applications
-
Teams that care about structure and long-term maintainability
-
Projects expected to scale beyond MVP
-
Engineers who prefer clear boundaries over scattered logic
git clone https://github.com/Vorlyn/vorlyn.git
cd vorlyn
bun install
Create your local environment files based on the example.
cp .env.example .env.development
cp .env.example .env.production
bun run dev
bun run build
Contributions are welcome. Please read the CONTRIBUTING.md file before opening a pull request.
- Fork the repository and create a new branch.
- Follow the project’s coding style (TypeScript, Prettier, ESLint).
- Write clear, descriptive commit messages (e.g.,
feat: add dark mode support,fix: resolve login API bug). - Test your changes to ensure they work as expected.
- Open a Pull Request (PR) with a detailed description of your changes.
For major changes or new features, please open an issue first to discuss the proposed changes.
This project is licensed under the MIT License. See the LICENSE file for details.
This boilerplate prioritizes clarity over cleverness. If your app grows, this structure grows with it. Built for predictable growth and long-term maintainability.