Overview
An overview of the Carbon repo
Project Structure
Carbon is a manufacturing system built with modern web technologies. It consists of three main applications:
- ERP (Enterprise Resource Planning) - Located at
/apps/erp/ - MES (Manufacturing Execution System) - Located at
/apps/mes/ - Academy (Training App) - Located at
/apps/academy/
Tech Stack
Frontend
- Framework: Remix (React-based)
- UI Components: Custom component library at
/packages/react/ - Styling: Tailwind CSS
- Forms: Custom form library at
/packages/form/ - TypeScript: Strict mode enabled
Backend
- Database: Supabase (PostgreSQL) at
/packages/database/supabase/ - Edge Functions: at
/packages/functions/database/supabase/functions/ - Authentication: Cookie based session and environment management via
/packages/auth/
Build Tools
- Monorepo: NPM workspaces with Turbo
- Bundler: Vite
- Linting: ESLint with custom config
- Formatting: Prettier
Package Structure
The monorepo uses NPM workspaces with packages located in /packages/:
auth- Authentication services and utilitiesdatabase- Database types and migrationsdocuments- PDF/Email/ZPL document generationform- Form components and validationkv- Key-value store (Redis)logger- Logging utilitiesnotifications- Notification servicesreact- Shared React componentsremix- Remix-specific utilitiesutils- Common utilities
Common Patterns
File Organization
Each app follows a consistent structure:
components/- React componentshooks/- Custom React hooksroutes/- Remix routesservices/- Business logic and API callsstores/- State management (appears to use nanostores)styles/- CSS filestypes/- TypeScript types and validatorsutils/- Utility functions
Module Organization
The ERP app organizes business logic into modules:
- Each module has its own folder in
/modules/ - Contains
.models.ts,.service.ts, and UI components - Examples: sales, purchasing, inventory, accounting, etc.
Database Access
- Uses Supabase client from
@carbon/auth - Type-safe queries with generated types from
@carbon/database - Service functions handle database operations
Routing
- Uses Remix flat routes
- Protected routes under
x+/prefix - Public routes under
_public+/prefix - API routes under
api+/prefix - File serving routes under
file+/prefix - External/shared routes under
share+/prefix
Path Configuration
In /apps/erp/app/utils/path.ts:
path.to.externalQuote(id)generates/share/quote/${id}- Quote sharing implemented in
QuoteHeader.tsxusingwindow.location.origin + path.to.externalQuote(externalLinkId)
Services
Each module defines a set of methods for interacting with the module. The convention is to have at least four methods for each table.
deleteCustomerPortal()- Delete customer portal linkgetCustomerPortals()- List customer portal linksgetCustomerPortal()- Get specific customer portalupsertCustomerPortal()- Create/update customer portal