Production-grade, scalable folder structure
Hereβs a production-grade, scalable folder structure for building apps with Expo + Bun, designed the way senior teams structure real-world apps (clean, modular, maintainable).
ποΈ Production-Grade Expo + Bun Structure
Section titled βποΈ Production-Grade Expo + Bun StructureβmyApp/ββββ app/ # Expo Router (recommended)β βββ (auth)/ # Auth group (route grouping)β β βββ login.tsxβ β βββ register.tsxβ ββ βββ (tabs)/ # Main app tabsβ β βββ home.tsxβ β βββ profile.tsxβ ββ βββ _layout.tsx # Root layoutβ βββ index.tsx # Entry routeββββ src/ # Core app logicβ βββ components/ # Reusable UI componentsβ β βββ common/β β β βββ Button.tsxβ β β βββ Input.tsxβ β ββ β βββ layout/β β β βββ ScreenWrapper.tsxβ β ββ β βββ index.tsβ ββ βββ features/ # Feature-based modules (IMPORTANT)β β βββ auth/β β β βββ api.tsβ β β βββ hooks.tsβ β β βββ store.tsβ β β βββ types.tsβ β β βββ components/β β ββ β βββ user/β β β βββ api.tsβ β β βββ store.tsβ β β βββ types.tsβ ββ βββ services/ # Global servicesβ β βββ api/β β β βββ client.ts # Axios/fetch wrapperβ β β βββ interceptors.tsβ β ββ β βββ storage/ # AsyncStorage / SecureStoreβ β β βββ storage.tsβ β ββ β βββ analytics/β β βββ notifications/β ββ βββ store/ # Global state (Zustand/Redux)β β βββ index.tsβ ββ βββ hooks/ # Shared hooksβ β βββ useAuth.tsβ β βββ useDebounce.tsβ ββ βββ utils/ # Utility functionsβ β βββ helpers.tsβ β βββ validators.tsβ ββ βββ constants/ # App constantsβ β βββ colors.tsβ β βββ config.tsβ ββ βββ types/ # Global TS typesβ β βββ global.d.tsβ ββ βββ lib/ # Third-party configsβ βββ react-query.tsβ βββ i18n.tsββββ assets/ # Images, fonts, iconsβ βββ images/β βββ fonts/ββββ config/ # Environment configsβ βββ env.tsβ βββ eas.jsonββββ scripts/ # Automation scriptsββββ tests/ # Unit & integration testsβ βββ setup.tsββββ .env # Environment variablesβββ .env.productionβββ app.json # Expo configβββ bun.lockbβββ package.jsonβββ tsconfig.jsonβββ README.mdπ§ Architecture Principles (Why this works)
Section titled βπ§ Architecture Principles (Why this works)β1. Feature-Based Design (Scales Better)
Section titled β1. Feature-Based Design (Scales Better)βInstead of dumping everything in /components, each feature owns its logic:
features/ auth/ api.ts store.ts hooks.tsπ This keeps:
- Logic isolated
- Easy team collaboration
- Easier refactoring
2. Expo Router First (Modern Standard)
Section titled β2. Expo Router First (Modern Standard)βUsing /app directory:
- File-based routing (like Next.js)
- Clean navigation separation
- Supports layouts & groups
3. Service Layer Separation
Section titled β3. Service Layer Separationβservices/api/client.tsCentralized API handling:
- Token injection
- Error handling
- Retry logic
4. Global vs Feature State
Section titled β4. Global vs Feature Stateβ| Type | Location |
|---|---|
| Global state | /store |
| Feature-specific | /features/*/store.ts |
β‘ Recommended Stack (Production)
Section titled ββ‘ Recommended Stack (Production)βPair this structure with:
- State: Zustand (lightweight)
- API: React Query (TanStack Query)
- Styling: NativeWind (Tailwind for RN)
- Forms: React Hook Form + Zod
- Navigation: Expo Router
- Storage: SecureStore + MMKV
π₯ Example Import Style (Clean Code)
Section titled βπ₯ Example Import Style (Clean Code)βUse path aliases in tsconfig.json:
{ "compilerOptions": { "paths": { "@/*": ["src/*"] } }}Then:
import { Button } from '@/components/common/Button';import { useAuth } from '@/features/auth/hooks';π Bun-Specific Enhancements
Section titled βπ Bun-Specific Enhancementsβ- Fast installs:
bun install - Script running:
bun run dev - CLI usage:
bunx expo start
β οΈ Common Mistakes to Avoid
Section titled ββ οΈ Common Mistakes to Avoidββ Putting everything in /components
β Mixing API logic inside UI
β No feature separation
β Hardcoding configs instead of /config/env.ts
β Not using aliases β messy imports
π‘ Senior-Level Tip
Section titled βπ‘ Senior-Level TipβAs your app grows, evolve into domain-driven structure:
features/ payments/ chat/ notifications/Each becomes almost like a mini app.
If you want next level, I can give you:
- π₯ Full starter repo template (copy-paste ready)
- βοΈ Setup with NativeWind + Zustand + React Query
- π§ Enterprise patterns (offline sync, caching, error boundaries, logging)