Skip to main content

Root Directory Layout

Here’s the complete structure of an EverShop application:
Important: Never modify files in .evershop/ or node_modules/. These directories are auto-generated.

Extension Structure

Extensions contain all business logic for your application. Here’s the detailed structure:

Example: Sample Extension

directory
REST API endpoints with route configurationStructure: api/[endpointName]/
  • route.json - Defines HTTP methods, path, and access control
  • [middleware]handler.ts - Request handlers with middleware chain
directory
React page components for admin or frontStoreStructure: pages/[area]/[pageName]/ComponentName.tsx
  • Exports default component, layout, and optionally query
directory
GraphQL type definitions and resolversStructure: graphql/types/[TypeName]/
  • TypeName.graphql - Schema definition
  • TypeName.resolvers.js - Query/mutation resolvers
directory
Event handlers that respond to system eventsStructure: subscribers/[event_name]/handler.ts
directory
Scheduled background jobsStructure: crons/jobName.ts
  • Registered in bootstrap.ts
file
Extension initialization file that runs on startup
  • Register cron jobs
  • Set up database connections
  • Configure services

Real Example: API Endpoint

Here’s how the sample extension defines a REST API:
The [bodyParser] prefix means this middleware runs after the bodyParser middleware in the chain.

Theme Structure

Themes handle visual presentation only. They should NOT contain business logic.

Example: Anasuplements Theme

directory
Components that appear on every pageExamples:
  • Header navigation
  • Footer
  • Cookie consent banners
directory
Components for account-related pagesExamples:
  • Login forms
  • Registration
  • Dashboard
directory
Components for the homepage onlyExamples:
  • Hero sections
  • Featured products
  • Promotional banners

Real Example: Header Component

themes/anasuplements/src/pages/all/Header.tsx
The theme uses custom colors (#2D5A3D for primary green) defined in the design system.

File Naming Conventions

API Endpoints

Rules:
  • Middleware prefix [name] determines execution order
  • Alphabetical sorting: [authenticate] runs before [bodyParser]
  • The final handler typically has the endpoint name

Page Components

Rules:
  • Use PascalCase for component files
  • Area determines where component renders: all, frontStore, admin, account
  • Must export default function and layout object

GraphQL Types

Subscribers

Cron Jobs

TypeScript Configuration

Both extensions and themes use TypeScript:
extensions/sample/tsconfig.json
Extensions and themes are compiled separately during the build process.

Package Structure

Root Package

package.json

Extension Package

extensions/sample/package.json

Theme Package

themes/anasuplements/package.json

Static Assets

Place public files in the public/ directory:
Files in public/ are served at the root URL. For example, public/favicon.ico is accessible at /favicon.ico.

Translations

Store internationalization files in translations/:

Build Output

During build, EverShop generates:
These directories are in .gitignore and should never be committed to version control.

Working with Structure

1

Create Extension

2

Register in Config

Add to config/default.json:
3

Add TypeScript Config

Copy tsconfig.json from extensions/sample/
4

Build and Run

Next Steps

Configuration System

Learn how config files control extensions and themes

Create Extension

Build your first custom extension