Architecture Overview
Relevant source files
The following files were used as context for generating this wiki page:
- README.md
- package.json
- packages/core/README.md
- packages/core/src/app.module.ts
- packages/admin-web-angular/src/app/app.module.ts
- packages/admin-web-angular/angular.json
- packages/shop-web-angular/config/webpack.common.js
- packages/shop-mobile-expo/README.md
- packages/shop-web-gatsby/README.md
- packages/merchant-tablet-ionic/angular.json
Ever® Demand™ is an open-source, real-time, and reactive platform for collaborative, on-demand, and sharing economies. The architecture is designed as a full-stack TypeScript monorepo, featuring a headless backend and multiple frontend applications for various user roles. This structure allows for flexible development and deployment of different storefronts, admin UIs, and client apps.
The platform is built to be highly modular, leveraging modern frameworks and technologies to deliver a scalable and feature-rich e-commerce solution. Key architectural characteristics include a reactive, real-time API layer, a microservices-friendly backend, and a variety of client-side applications built with different technologies like Angular, Ionic, and React Native.
Sources: README.md
Monorepo Structure
The project is managed as a monorepo using Lerna and Yarn Workspaces. This approach centralizes package management and streamlines cross-project development. The packages directory contains all the distinct parts of the platform, including the core backend, shared libraries, and various frontend applications.
Sources: package.json:198-207
This diagram illustrates the high-level structure of the monorepo and the relationship between the core backend, shared libraries, and the various client applications.
Sources: package.json:198-207, README.md:65-71
Key Packages
| Package Name | Description | Location |
|---|---|---|
@ever-platform/core | The headless backend API server built with NestJS. | packages/core |
@ever-platform/common | Shared TypeScript code used across different packages. | packages/common |
@ever-platform/common-angular | Shared code and modules specifically for Angular-based frontends. | packages/common-angular |
@ever-platform/admin-web-angular | The main administration web interface, built with Angular and ngx-admin. | packages/admin-web-angular |
@ever-platform/shop-web-angular | The customer-facing e-commerce website, built with Angular. | packages/shop-web-angular |
@ever-platform/shop-mobile-ionic | A hybrid mobile shopping app for customers, built with Ionic/Angular. | packages/shop-mobile-ionic |
@ever-platform/merchant-tablet-ionic | A tablet application for merchants to manage orders and deliveries, built with Ionic. | packages/merchant-tablet-ionic |
@ever-platform/carrier-mobile-ionic | A mobile app for carriers/drivers to manage deliveries, built with Ionic. | packages/carrier-mobile-ionic |
@ever-platform/shop-mobile-expo | A work-in-progress mobile shopping app using React Native and Expo. | packages/shop-mobile-expo |
@ever-platform/shop-web-gatsby | A work-in-progress shopping website using Gatsby. | packages/shop-web-gatsby |
Sources: package.json:200-206, README.md:65-71
Technology Stack
The platform utilizes a full-stack TypeScript approach, ensuring type safety and code consistency from the database to the user interface.
| Category | Technology | Description |
|---|---|---|
| Backend | NestJS, Node.js | A progressive Node.js framework for building scalable server-side applications. |
| GraphQL | Primary API query language for flexible data fetching. | |
| REST & WebSockets | Additional API protocols for specific use cases and real-time communication (via Socket.io). | |
| RxJS | Used extensively for reactive programming and managing asynchronous events. | |
| Database | MongoDB | The primary database, used with the Mongoose ORM. |
| TypeORM, Prisma | Support for SQL databases (MySQL, PostgreSQL, etc.) is a work in progress. | |
| Frontend | Angular | Used for the Admin and main Shopping websites. |
| Ionic | Used for the hybrid mobile and tablet applications. | |
| React Native / Expo | Used for an alternative mobile shopping app (WIP). | |
| Gatsby | Used for an alternative shopping website (WIP). | |
| Monorepo | Lerna, Yarn Workspaces | Tools for managing the multi-package repository. |
| Deployment | PM2, Docker | Used for process management and containerization. A move to Kubernetes is planned. |
Sources: README.md:57-78, packages/core/README.md:16-25, packages/core/src/app.module.ts:121-141
Backend Architecture (@ever-platform/core)
The backend is a headless commerce framework built on NestJS. It exposes a rich set of APIs and is designed to be the single source of truth for all frontend applications.
Sources: README.md:33, packages/core/README.md:3
The diagram below shows the main components of the backend system.
API Layer
The backend provides three types of APIs to serve different client needs:
- GraphQL API: The primary interface for frontend applications. It allows clients to request exactly the data they need. The API is configured in
packages/core/src/app.module.tsusing@nestjs/graphql. - REST API: Used for specific endpoints, implemented as standard NestJS controllers.
- WebSocket API: Implemented using Socket.io and integrated with GraphQL subscriptions for real-time updates across the platform. This is handled by the
SubscriptionsModule.
Sources: README.md:33, packages/core/src/app.module.ts:178-187, packages/core/README.md:4-5
Core Modules
The backend is organized into modules, a key concept in NestJS. The main ApplicationModule imports feature-specific modules that encapsulate a specific domain of the application.
// packages/core/src/app.module.ts:143
@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({ ... }),
InvitesModule,
DevicesModule,
ProductModule,
WarehousesModule,
GeoLocationsModule,
UsersModule,
OrdersModule,
CarriersModule,
// ... and more
],
})
export class ApplicationModule implements NestModule, OnModuleInit {
// ...
}
Sources: packages/core/src/app.module.ts:143-189
Database Layer
The platform primarily uses MongoDB with Mongoose. However, there is an ongoing effort to introduce support for SQL databases through TypeORM. The ApplicationModule configures a TypeORM connection, indicating a transition towards a multi-database architecture. The configuration supports SSL connections to the database.
Sources: README.md:73-77, packages/core/src/app.module.ts:101-141
Frontend Architecture
The platform includes multiple frontend applications tailored for different users and devices. This separation is a core tenet of the headless architecture.
Web Applications (Angular)
The Admin and Shopping websites are built with Angular. Their build configurations are defined in angular.json files within their respective packages. The shop-web-angular project uses a custom Webpack configuration (webpack.common.js) to manage the build process, including handling of assets, defining environment variables, and optimizing the final bundles with plugins like HtmlWebpackPlugin and CopyWebpackPlugin.
Sources: README.md:69-71, packages/admin-web-angular/angular.json, packages/shop-web-angular/config/webpack.common.js
Mobile Applications (Ionic, React Native)
For mobile, the platform provides hybrid apps built with Ionic and Angular for merchants, carriers, and shoppers. Additionally, a React Native/Expo version of the shopping app is in development, demonstrating the flexibility of the headless backend.
Sources: README.md:65-68, packages/shop-mobile-expo/README.md
Client-Server Communication
Frontend applications communicate with the backend primarily via GraphQL. The Angular frontends use apollo-angular to handle GraphQL operations. The configuration in packages/admin-web-angular/src/app/app.module.ts sets up the Apollo client with both HTTP and WebSocket links to support queries, mutations, and real-time subscriptions.
The following sequence diagram illustrates a typical data request flow from an Angular client to the backend.
Build and Deployment
The monorepo uses Yarn and Lerna to manage dependencies and run scripts across all packages.
Build Process
A unified build command can be triggered from the root of the project:
# Installs all dependencies for all packages
yarn bootstrap
# Builds all packages in the correct order
yarn build:all
These scripts are defined in the root package.json and use Lerna to execute the build script within each individual package.
Sources: package.json:28-49, README.md:126-133
Deployment
For production, the backend server is recommended to be run using pm2, a process manager for Node.js that provides clustering and fault tolerance. The project also contains mentions of Docker and a planned migration to Kubernetes, indicating a strategy towards containerization and orchestration for scalable deployments.
Sources: README.md:78, 101, packages/core/README.md:8