Pixels Shop uses an Nx monorepo structure to manage multiple applications and shared libraries efficiently. The monorepo ensures consistent dependency management, code reuse, and modular development for a multi-tenant e-commerce platform.
apps/
account/ # User registration, login, and account flows
admin/ # Admin dashboard for store and product management
frontend/ # Main e-commerce frontend application
backend/ # API server (REST & GraphQL)
libs/ # Shared libraries
ui/ # Reusable UI components
utils/ # Utility functions (helpers, formatters, etc.)
package.json # Root dependencies and scripts
nx.json # Nx workspace configuration
graph TD
A[Nx Workspace] --> B[Apps]
B --> C[Account App]
B --> D[Admin App]
B --> E[Frontend App]
B --> F[Backend App]
A --> G[Shared Libraries]
G --> H[UI Components]
G --> I[Utilities]
- Handles user registration, login, password reset, and account management.
- Key files:
Create.jsx,SignIn.jsx. - API integration with
/api/v1/user/*endpoints. - Flow ensures secure token storage in
localStorage.
- Manages products, users, orders, and store settings.
- Key files:
about/page.jsx,products/page.jsx,users/page.jsx,settings/page.jsx. - Uses reusable UI components and centralized API calls.
- Supports role-based access control for admins.
- Customer-facing e-commerce UI.
- Core components:
Header,Navbar,Footer,HeroSection,ProductSection,CartIcon. - Pages: Homepage, ProductDetails, CategoryPage, Cart, Account, AboutUs, ContactUs, FAQ, Policies.
- Integrates GraphQL and REST APIs for product data, cart, orders, and content.
- Node.js + Express server.
- Handles REST for CRUD operations and GraphQL for complex nested queries.
- Middleware includes JWT authentication, role-based authorization, rate limiting, and file uploads.
- Two databases: MongoDB (main) and PostgreSQL (account/store data).
- Reusable React components.
- Standardized styling with Tailwind CSS.
- Includes
Button,Input,Modal,Card, etc.
- Helper functions and shared logic.
- Examples:
formatCurrency,validateEmail,imageUrlBuilder, API clients.
graph TD
Shared Libraries --> UI Components
Shared Libraries --> Utils
Account App --> UI Components
Admin App --> UI Components
Frontend App --> UI Components
Backend App --> Utils
- Generate a library:
npx nx g @nx/js:lib packages/pkg1 --publishable --importPath=@my-org/pkg1- Build a project:
npx nx build <project-name>- Run any task:
npx nx <target> <project-name>- Sync TypeScript project references:
npx nx sync- Check references in CI:
npx nx sync:check- Code Reuse: Shared UI and utility libraries reduce duplication.
- Consistency: Single source of truth for dependencies and configuration.
- Modular Development: Separate apps for account, admin, frontend, and backend.
- Scalability: Easy to add new apps or libraries without impacting others.
- Efficient CI/CD: Nx provides caching and task optimization for faster builds.
flowchart TD
User -->|Register/Login| Account App
Account App -->|JWT Token| Backend API
User -->|Browse Products| Frontend App
Frontend App -->|Fetch Data| Backend API
Admin App -->|Manage Products/Orders| Backend API
Backend API --> MongoDB
Backend API --> PostgreSQL
Backend API --> External Services
This diagram shows how the monorepo applications interact with each other and the databases, providing a clear view of data flow in the Pixels Shop multi-tenant platform.