Project Structure
Relevant source files
The following files were used as context for generating this wiki page:The Ever Demand platform is a full-stack TypeScript project structured as a monorepo. It is designed as a headless commerce framework, providing a core backend API and multiple frontend applications for different user roles and platforms. The monorepo approach is managed using Yarn Workspaces and Lerna, which facilitates dependency management and coordinated execution of scripts across various packages.
The architecture separates the backend logic, which exposes GraphQL, REST, and WebSocket APIs, from the various client-side implementations. This includes web applications built with Angular and mobile applications built with Ionic, React Native (Expo), and Flutter. This separation allows for flexible development and deployment of different storefronts and administrative interfaces.
Sources: README.md:14-17, README.md:40-43, package.json:80-92
Monorepo Management
The project utilizes a monorepo strategy to manage its multiple packages. This is configured through Yarn Workspaces and orchestrated with Lerna.
Sources: README.md:120-123, package.json:80-92
Workspace Configuration
The root package.json file defines the workspaces, which include all subdirectories within packages/, libs/, apps/, and tools. This allows for shared dependencies and cross-package linking.
{
"workspaces": {
"packages": [
"libs/*",
"apps/*",
"tools",
"packages/*",
"packages/plugins/*"
],
"nohoist": [
"**/@types/jasmine",
"**/@types/jasminewd2",
"**/@nebular",
"**/@angular*/**",
"**/@ngtools/**"
]
}
}
Sources: package.json:80-92
The nohoist configuration prevents certain dependencies from being hoisted to the root node_modules directory, which is often necessary to avoid version conflicts or issues with frameworks like Angular that have specific dependency resolution requirements.
Core Scripts
The root package.json contains scripts for managing the entire monorepo. Lerna is used to execute commands across all packages.
| Script | Description |
|---|---|
bootstrap | Installs all dependencies using yarn and then links cross-dependencies within the monorepo using lerna bootstrap. |
build | Builds the common packages and then runs the build script in parallel for all other packages. |
build:all | Builds all packages sequentially, ensuring dependencies are built before the packages that depend on them. |
run:server | Builds and runs the API server (@ever-platform/core). |
run:admin | Starts the admin web application (@ever-platform/admin-web-angular). |
run:shopweb | Starts the shopping web application (@ever-platform/shop-web-angular). |
Sources: package.json:14-46
This diagram shows the relationship between the monorepo management tools and the packages.
Sources: package.json, README.md
High-Level Component Architecture
The platform is divided into a central backend API and several frontend applications, each serving a specific purpose.
| Component | Technology | Description |
|---|---|---|
| Core API | NestJS, Node.js, MongoDB | Headless commerce backend providing GraphQL, REST, and WebSocket APIs. |
| Admin Website | Angular, ngx-admin | Web interface for managing all platform features and settings. |
| Shopping Website | Angular | E-commerce website for customers. |
| Shopping Mobile App | Ionic, React Native (Expo), Flutter | Mobile apps for customers to place on-demand orders. |
| Merchant Tablet App | Ionic | App for merchants to manage orders and deliveries. |
| Carrier Mobile App | Ionic | App for drivers/carriers to manage deliveries. |
Sources: README.md:40-50
The following diagram illustrates the overall architecture, with the Core API serving various frontend clients.
Sources: README.md:40-58
Backend Structure (@ever-platform/core)
The backend is a NestJS application that serves as the heart of the platform.
Sources: packages/core/README.md
Directory Layout
The packages/core directory is organized as follows:
/src: Contains all the source code./app.module.ts: The root NestJS module, importing all other feature modules./modules: Contains shared modules used within the backend project./graphql: Contains GraphQL-specific modules, resolvers, and schema definitions./controllers: Contains REST API controllers./services: Contains business logic services.
/build: Output directory for the transpiled TypeScript code./.env.template: A template for environment variables.
Sources: packages/core/README.md:41-53
Module Composition
The main application module, ApplicationModule, imports all the necessary feature modules to construct the application. This modular design separates concerns such as users, products, orders, and authentication.
// packages/core/src/app.module.ts
@Module({
controllers: [TestController],
providers: [...CommandHandlers, ...EventHandlers],
imports: [
DataModule,
ServicesModule,
CqrsModule,
AuthModule,
AdminsModule,
AppsSettingsModule,
ConfigModule,
// ...
TypeOrmModule.forRoot(connectionSettings),
TypeOrmModule.forFeature(entities),
SubscriptionsModule.forRoot(env.GQLPORT_SUBSCRIPTIONS),
GraphQLModule.forRoot({
typePaths: ['./**/*.graphql'],
// ...
}),
InvitesModule,
DevicesModule,
ProductModule,
WarehousesModule,
// ... and many more
],
})
export class ApplicationModule implements NestModule, OnModuleInit {
// ...
}
Sources: packages/core/src/app.module.ts:114-152
The diagram below shows how ApplicationModule is composed of various feature modules.
Frontend Structures
The project contains multiple frontend applications built with different frameworks, each with its own distinct structure.
Angular Web Apps (admin-web-angular, shop-web-angular)
Both the admin and shop web apps are built with Angular. Their structure is defined by the angular.json configuration file.
Key properties in angular.json for admin-web-angular:
outputPath: "build" - The directory for build artifacts.index: "src/index.html" - The main HTML file.main: "src/main.ts" - The main entry point of the application.assets: Specifies static assets to be copied, including images fromleafletand icons fromionicons.styles: Lists global CSS/SCSS files, including Bootstrap, FontAwesome, and theme styles.scripts: Includes third-party JavaScript libraries likepace-jsandtinymce.
Sources: packages/admin-web-angular/angular.json:12-70
The shop-web-angular application uses a custom webpack configuration (webpack.common.js) instead of the default Angular CLI builder. This allows for more advanced build customizations, such as using NormalModuleReplacementPlugin to provide browser-compatible placeholders for Node.js-specific modules like mongoose and typeorm.
Sources: packages/shop-web-angular/config/webpack.common.js:93-113
React Native App (shop-mobile-expo)
This mobile shopping app is built with React Native and Expo.
Its package structure is organized as follows:
src/assets: Contains images, fonts, etc.src/client: Holds Apollo GraphQL queries and mutations.src/components: Reusable React components.src/screens: Components representing application screens.src/environments: Environment-specific configuration.App.tsx: The root component of the application.
Sources: packages/shop-mobile-expo/README.md:21-32
Flutter App (shop-mobile-flutter)
A version of the shopping mobile app is also being developed with Flutter.
Its project structure is:
assets: Contains fonts, i18n files, colors, and images.lib: Contains all Dart source code, organized into models, screens, middlewares, etc.test: Contains all tests for the application.