Documentation
Apps and libs
Documentation on the difference between apps and libs
Overview
Nitrokit is an Angular boilerplate designed to supercharge your development workflow by offering scalable solutions and enabling rapid shipping. It integrates a variety of generators and enforces best practices for building large-scale monorepos, ensuring that your architecture remains clean, modular, and maintainable.
Workspaces and Encapsulation
Apps vs. Libs
Workspaces in Nitrokit are structured around two key building blocks: apps and libs.
- Apps are deployable entities, functioning as empty shells without business logic. Their role is to structure and manage the complexity contained within libraries.
- Libs are the backbone of your application, containing all the logic, types, and functionality needed to power your apps.
Elements of the Architecture
Nitrokit encourages the use of the following key elements to ensure a clean, modular architecture:
- Component: Smart or UI components
- Directive: Behavioral enhancements for DOM elements
- Pipe: Functions for data transformation in templates
- Type/Interface: Definition of data structures
- State Machine: Injectable service that manages state
- Util: Pure functions or sets of functions
- Guard: Protects routes or prevents navigation
- Service: Encapsulates business logic
- Data Service: Handles API communication
- Interceptor: Modifies HTTP requests or responses
- Constant: Immutable values such as configurations
Consistent Filenames
Maintaining consistent naming conventions is crucial in Nitrokit to ensure readability and maintainability:
- Component:
*.ui-component.ts
or*.smart-component.ts
- Directive:
*.directive.ts
- Pipe:
*.pipe.ts
- Type/Interface:
*.type.ts
or*.interface.ts
- State Machine:
*.state-machine.ts
- Util:
*.util.ts
- Guard:
*.guard.ts
- Service:
*.service.ts
- Data Service:
*.data-service.ts
- Interceptor:
*.interceptor.ts
- Constant:
*.const.ts
Each of these elements has a specific generator in Nitrokit
What Are Apps?
In Nitrokit, apps represent the deployable, physical applications that live in the apps directory. While apps don't contain logic themselves, they serve as containers for the complexity handled by the libraries. A workspace can contain multiple apps, which can be built using frameworks like Angular, React, Nest, or Qwik.
What Are Libs?
Libs, located in the libs directory, are the core building blocks of an application. They contain all the logic, types, and functionality required to drive the application. Unlike apps, libs are not deployable entities but are instead used across the workspace to modularize the codebase. Nitrokit ensures that every piece of real code belongs in a lib, promoting a clean, scalable architecture.
Types of Projects
Nitrokit organizes your workspace into 9 distinct types of projects: 1 app type and 8 different lib types. This distinction enforces a single responsibility principle and encapsulation, ensuring that each project serves a specific purpose and adheres to strict rules about where code belongs. This structure helps maintain a clean architecture that is scalable and maintainable across large-scale monorepos.
Have questions?
Still have questions? Talk to support.