Nitrokit Nitrokit - Ship faster with AI - No more heavy lifting, build Angular apps at NITROSPEED!

Documentation

Types of libs

Documentation on the types of libs in Nitrokit

Workspaces and Encapsulation

Types of Libraries

In this section, we will break down the different types of libraries and how they help in organizing your code. Properly structuring your libraries is key to maintaining scalability and improving workflow efficiency.

Types of Lib Projects

  • πŸš€ feat (lib): Contains feature logic like Smart and UI components.
  • πŸ–ΌοΈ ui (lib): Contains only reusable UI components.
  • πŸ”„ state (lib): Manages state machines that can be reused across features.
  • πŸ”§ util (lib): Houses utilities that are reused across different libs.
  • πŸ”Œ data-access (lib): Contains logic that connects to APIs or other IO operations.
  • πŸ“‘ type (lib): Stores reusable types and interfaces.
  • πŸ›‘ guard (lib): Holds reusable guards for route protection.
  • πŸ”’ const (lib): Contains reusable constants.
  • πŸ’Ύ backend (lib): Contains backend stuff.

These library categories are essential to scaling massive workspaces. Their clear purposes enable clean architecture and efficient feature implementation.


Feat Library πŸš€

A feat library acts as the presentation layer of a specific feature.

  • Contains: UI components, Smart components, interceptors, directives, pipes, types, interfaces, state-machines, utilities, guards, services, constants.
  • Lazy-loaded to improve performance.
  • Exposes: Only Smart components (if reusable) and route configurations.
  • Example: feat-user-management

Only expose what is necessary to maintain a clean, modular architecture.


UI Library πŸ–ΌοΈ

A ui library is dedicated to reusable UI components.

  • Contains: UI components, directives, pipes, types, interfaces, utilities, services, state-machines, constants.
  • Exposes: UI components, directives, pipes, and their types.
  • No Smart components allowed.
  • Example: ui-forms, ui-design-system

Create UI libs only when components need to be reused. Keep it lean by exposing only what’s required.


State Library πŸ”„

State libraries manage reusable state machines.

  • Contains: State-machines, types, interfaces, utilities, services, constants.
  • Exposes: State-machines, types.
  • Example: state-global, state-chatbox, state-users

State libraries should be as lightweight as possible, focusing only on what's needed for efficient state management.


Util Library πŸ”§

A util library contains utilities and helper functions.

  • Contains: Utilities, types, constants, services (but not data-services).
  • Exposes: Utilities and services.
  • Example: Use for reusable pure functions.

Create util libraries only when utilities need to be reused across different libs.


Data Access Library πŸ”Œ

Data-access libraries manage communication with APIs and external data sources.

  • Contains: Data-services, types, interfaces, utilities, interceptors, constants.
  • Exposes: Data-services, interceptors.
  • Example: data-access-user-service

All data-related operations should be kept here, separate from feature logic.


Type Library πŸ“‘

The type library stores reusable types and interfaces.

  • Contains: Types, interfaces.
  • Exposes: Types, interfaces.
  • Example: type-user

This library should be used only for types and interfaces, without any logic.


Guard Library πŸ›‘

Guard libraries store reusable guards for route protection.

  • Contains: Guards, types, interfaces, constants.
  • Exposes: Guards.
  • Example: guard-auth

Guards must be able to access the data-access layer for security and routing purposes.


Const Library πŸ”’

Const libraries contain reusable constants.

  • Contains: Constants.
  • Exposes: Constants.

This library exists to avoid circular references between constants and types.


Backend Library πŸ’Ύ

Backend libraries contain reusable constants.

  • Contains: backend stuff.
  • Exposes: backend stuff.

Library Import Rules

The table below illustrates the allowed dependencies between different library types:

feat data-access ui type util state guard const backend
feat βœ… βœ… βœ… βœ… βœ… βœ… βœ… βœ… 🚫
data-access 🚫 βœ… 🚫 βœ… βœ… 🚫 🚫 βœ… 🚫
ui 🚫 🚫 βœ… βœ… βœ… 🚫 🚫 βœ… 🚫
type 🚫 🚫 🚫 βœ… 🚫 🚫 🚫 βœ… 🚫
util 🚫 🚫 🚫 βœ… βœ… 🚫 🚫 βœ… 🚫
state 🚫 βœ… 🚫 βœ… βœ… βœ… 🚫 βœ… 🚫
guard 🚫 βœ… 🚫 βœ… βœ… βœ… βœ… βœ… 🚫
const 🚫 🚫 🚫 βœ… 🚫 🚫 🚫 βœ… 🚫
backend 🚫 🚫 🚫 βœ… βœ… 🚫 🚫 βœ… βœ…

This matrix ensures modularity by defining clear import boundaries between different library types.


This forms the foundation for scalable architecture in Nitrokit.

Have questions?

Still have questions? Talk to support.

Previous
Tech stack