The project is divided into the following folders:
apps
- Cross-platform applications and user-facing products.infra
- Infrastructure as code for local development and cloud providers.packages
- Shared internal packages for use across apps.scripts
- Scripts for random tasks, such as syncing the project with the template and graphing dependencies.tooling
- Shared development configuration and script helpers. If a configuration is used across workspaces and not related to a specific package, it should go here.
root
βββ apps # Cross-platform applications
β βββ app # Next.js web application
β βββ api # Hono API with RPC client, deployed on Cloudflare Workers
β βββ desktop # Tauri desktop application
β βββ docs # Documentation site
β βββ extensions # WXT browser extension
β βββ mobile # Expo mobile application
β βββ web # Next.js marketing site with content collections for blog and other static pages
β
βββ infra # Infrastructure as code for cloud providers
β βββ local # Docker Compose configuration for local development
β
βββ packages # Shared internal packages for use across apps
β βββ ai # AI utilities
β βββ analytics # Web and product analytics
β βββ auth # Authentication utilities
β βββ db # Database client and ORM using Drizzle
β βββ email # Email templating and sending service using Resend
β βββ env # Environment variable management and validation
β βββ kv # Redis client and vector database integration using Upstash
β βββ native-ui # Reusable UI components for React Native apps
β βββ observability # Logging, error tracking, and monitoring using Sentry and Axiom
β βββ payments # Payment processing utilities using Stripe
β βββ queue # Serverless job queue and workflow management using Upstash
β βββ security # Security utilities and best practices using Arcjet
β βββ storage # Shared storage utilities using UploadThing
β βββ ui # Reusable UI components and design system using Shadcn/UI
β βββ utils # Shared helpers and constants for packages and apps
β
βββ scripts # Scripts for random tasks
β
βββ tooling # Shared development and build tools
β βββ tsconfig # TypeScript configuration
β βββ helpers # Common utility functions for tooling and scripts
β
βββ turbo # Turborepo configuration for monorepo management
βββ generators # Code generators for packages and tooling
Each app has a src
folder that contains the source code for the app.
Apps are usually organized in three folders:
- The main router (e.g.,
app
for Next.js and Expo,routes
for Vite projects).- Some projects, like the browser extension, have an extra folder that can be considered part of the routing logic.
- A
shared
folder for shared utilities and components. - A
features
folder for feature-based modules.
We follow a unidirectional import flow between these three folders. The code only flows downwards to the routing folder, never going upwards. What this means is that the features
folder can import from the shared
folder, but the shared
folder cannot import from the features
folder. The app/routing
folder can import from either the features or the shared folder, but never the other way around. This makes the code more organized and easier to understand.
Feature folders are also vertical slices of the app and do not have any dependencies between them. This keeps the code organized and easier to understand. If you find yourself needing to import something from a different feature, you should first consider if it can be moved to the shared
folder.
This is a web application using Next.js.
apps/app
βββ src/ # Source code
β βββ app/ # App router for Next.js
β β βββ (unauthenticated)/ # Unauthenticated routes (sign in, sign up, etc.)
β β βββ (authenticated)/ # Authenticated routes (dashboard, settings, etc.)
β β βββ api/ # API routes
β β
β βββ shared/ # Shared utilities and helpers
β β βββ assets/ # Static assets shared across the app (images, icons, etc.)
β β βββ auth/ # Authentication client and helpers
β β βββ components/ # Reusable components
β β βββ hooks/ # Custom React hooks
β β βββ i18n/ # Internationalization setup
β β βββ middlewares/ # Global middleware to be imported into middleware.ts
β β βββ server/ # Server-side code
β β β βββ data/ # Data access layer (e.g., database queries)
β β β βββ loaders.ts # Shared data fetching functions for server components
β β β βββ actions.ts # Shared server actions for handling form submissions and mutations
β β βββ stores/ # Global state management stores
β β βββ env.ts # Environment variable configuration
β β βββ constants.ts # Constant values and enums
β β βββ safe-action.ts # Type-safe server actions client and middleware
β β βββ types.ts # TypeScript type definitions
β β βββ utils.ts # General utility functions
β β βββ validation.ts # Form and data validation schemas
β β
β βββ features/ # Feature-based modules
β β βββ[feature]/ # Specific feature (e.g., auth, dashboard, settings)
β β βββ assets/ # Feature-specific assets
β β βββ components/ # Feature-specific components
β β βββ actions.ts # Feature-specific server actions
β β βββ hooks.ts # Feature-specific custom hooks
β β βββ loaders.ts # Feature-specific data loaders
β β βββ stores.ts # Feature-specific state stores
β β βββ types.ts # Feature-specific type definitions
β β βββ utils.ts # Feature-specific utility functions
β β βββ validation.ts # Feature-specific validation schemas
β β
β βββ middleware.ts # Next.js middleware for request/response modification
β βββ instrumentation.ts # Monitoring and analytics instrumentation
β
βββ translations # Internationalization translation files
βββ global.d.ts # Global TypeScript declarations
apps/mobile
βββ src/ # Source code
β βββ app/ # App router
β β
β βββ shared/ # Shared utilities and helpers
β β βββ assets/ # Static assets shared across the app
β β β βββ styles/ # Global styles
β β βββ components/ # Shared components used across the entire app
β β βββ auth/ # Authentication client and helpers
β β βββ hooks/ # Custom React hooks
β β βββ i18n/ # Internationalization setup
β β βββ stores/ # Global state stores
β β βββ api.ts # Global API and query client
β β βββ constants.ts # Constant values and enums
β β βββ env.ts # Environment variables
β β βββ types.ts # Shared types
β β βββ utils.ts # Shared utilities for the app
β β βββ validation.ts # Shared validation schemas
β β
β βββ features/ # Feature based modules
β βββ[feature]/ # Specific feature (e.g. auth, dashboard, settings)
β βββ assets/ # Feature-specific assets
β βββ components/ # Feature-specific components
β βββ hooks.ts # Feature-specific hooks
β βββ mutations.ts # Feature-specific mutations
β βββ queries.ts # Feature-specific queries
β βββ stores.ts # Feature-specific global state stores
β βββ types.ts # Feature-specific types
β βββ utils.ts # Feature-specific utilities
β βββ validation.ts # Feature-specific validation schemas
β
βββ translations # Translations files
apps/api
βββ src/ # Source code
βββ index.ts # Entry point to the worker
βββ client.ts # RPC client type to be used in other apps
βββ routes/ # Routing
β βββ index.tsx # Router entrypoint
β βββ ... # Other routes
β
βββ shared/ # Shared utilities and helpers
β βββ middlewares/ # Global middleware
β βββ constants.ts # Constant values and enums
β βββ env.ts # Environment variables
β βββ types.ts # Shared types
β βββ utils.ts # General utility functions
β
βββ features/ # Feature based modules
βββ[feature]/ # Specific feature (e.g. auth, dashboard, settings)
βββ router.ts # Feature-specific router
βββ procedures.ts # Feature-specific procedures
βββ types.ts # Feature-specific types
βββ utils.ts # Feature-specific utilities
βββ validation.ts # Feature-specific validation schemas
apps/desktop
βββ src/ # Source code
β βββ main.tsx # Entry point to the desktop app
β βββ routes/ # Routing
β β
β βββ shared/ # Shared utilities and helpers
β β βββ assets/ # Static assets shared across the app
β β β βββ styles/ # Global styles
β β βββ components/ # Shared components used across the entire app
β β βββ auth/ # Authentication client and helpers
β β βββ hooks/ # Custom React hooks
β β βββ i18n/ # Internationalization setup
β β βββ stores/ # Global state stores
β β βββ api.ts # Global API and query client
β β βββ constants.ts # Constant values and enums
β β βββ env.ts # Environment variables
β β βββ types.ts # Shared types
β β βββ utils.ts # Shared utilities for the app
β β βββ validation.ts # Shared validation schemas
β β
β βββ features/ # Feature based modules
β βββ[feature]/ # Specific feature (e.g. auth, dashboard, settings)
β βββ assets/ # Feature-specific assets
β βββ components/ # Feature-specific components
β βββ hooks.ts # Feature-specific hooks
β βββ mutations.ts # Feature-specific mutations
β βββ queries.ts # Feature-specific queries
β βββ stores.ts # Feature-specific global state stores
β βββ types.ts # Feature-specific types
β βββ utils.ts # Feature-specific utilities
β βββ validation.ts # Feature-specific validation schemas
β
βββ translations # Translations files
βββ content # Blog and other static content
apps/extensions
βββ src/ # Source code
β βββ entrypoints/ # Entrypoints
β β βββ popup/ # Popup entrypoint
β β βββ background/ # Background script entrypoint
β β βββ ... # Other entrypoints
β β
β βββ shared/ # Shared utilities and helpers
β β βββ assets/ # Assets processed by WXT
β β β βββ styles/ # Global styles
β β βββ components/ # Shared components used across the entire extension
β β βββ services/ # Shared services
β β βββ stores/ # Global state stores
β β βββ api.ts # Global API and query client
β β βββ auth.ts # Authentication client and helpers
β β βββ constants.ts # Constant values and enums
β β βββ env.ts # Environment variables
β β βββ hooks.ts # Shared hooks
β β βββ i18n.ts # Internationalization
β β βββ types.ts # Shared types
β β βββ utils.ts # Shared utilities for the app
β β βββ validation.ts # Shared validation schemas
β β
β βββ features/ # Feature based modules
β β βββ[feature]/ # Specific feature (e.g. auth, dashboard, settings)
β β βββ assets/ # Feature-specific assets
β β βββ components/ # Feature-specific components
β β βββ hooks.ts # Feature-specific hooks
β β βββ mutations.ts # Feature-specific mutations
β β βββ queries.ts # Feature-specific queries
β β βββ services.ts # Feature-specific services
β β βββ stores.ts # Feature-specific global state stores
β β βββ types.ts # Feature-specific types
β β βββ utils.ts # Feature-specific utilities
β β βββ validation.ts # Feature-specific validation schemas
β β
β βββ routes/ # Routing shared by all entrypoints
β β βββ __root.tsx # Root route
β β βββ ... # Other routes
β β
β βββ static/ # Static assets not processed by WXT. Includes the extension icon.
β β
β βββ router.ts # Router instance
β βββ routeTree.gen.ts # Auto-generated route tree
β
βββ wxt.config.ts # WXT configuration
apps/docs
βββ src/ # Source code
β βββ app/ # App router for Next.js
β β
β βββ shared/ # Shared utilities and helpers
β β βββ assets/ # Static assets shared across the app
β β βββ components/ # Shared components
β β βββ constants.ts # Constant values and enums
β β βββ env.ts # Environment variables
β β βββ middlewares/ # Global middleware
β β βββ source.ts # Documentation source
β β βββ utils.ts # Shared utilities for the app
β β
β βββ instrumentation.ts # Monitoring and analytics instrumentation
β
βββ content/ # Documentation content in MDX format
Similar to the app, but focusing on static content like marketing pages. This leads to have a simpler structure, as it doesn't need to support authentication or server actions.
It uses content collections to manage the blog and other static pages, and has i18n support through routing.
apps/web
βββ src/ # Source code
β βββ app/ # App router for Next.js
β β βββ [locale]/ # Localized routes
β β
β βββ shared/ # Shared utilities and helpers
β β βββ assets/ # Static assets shared across the app (images, icons, etc.)
β β βββ components/ # Reusable components
β β βββ hooks/ # Custom React hooks
β β βββ i18n/ # Internationalization setup
β β βββ middlewares/ # Global middleware to be imported into middleware.ts
β β βββ stores/ # Global state management stores
β β βββ env.ts # Environment variable configuration
β β βββ constants.ts # Constant values and enums
β β βββ safe-action.ts # Type-safe server actions client and middleware
β β βββ types.ts # TypeScript type definitions
β β βββ utils.ts # General utility functions
β β βββ validation.ts # Form and data validation schemas
β β
β βββ middleware.ts # Next.js middleware for request/response modification
β βββ instrumentation.ts # Monitoring and analytics instrumentation
β
βββ translations # Internationalization translation files
βββ global.d.ts # Global TypeScript declarations
Packages don't have an strict structure. A general guideline is that all runtime code should be in the src
folder, while scripts should be in the scripts
folder.
packages/package-name
βββ src/ # Source code
βββ scripts/ # Scripts
You can create a new package using the following command:
pnpm generate
And then selecting the internal-package
option.