Shared packages
The three @babyshop packages — shared types, the design system and config — and how the apps use them.
Three packages in packages/ hold the code that more than one app needs. The
storefront and admin dashboard depend on them as workspace:*. Changing a
type or a colour there updates both apps at once.
Directorypackages/
Directorytypes/
@babyshop/types— domain and API types, compiled to dist/- …
Directoryui/
@babyshop/ui— components, design tokens, BrandLogo (source only)- …
Directoryconfig/
@babyshop/config— shared constants- …
| Package | Used by | Build output |
|---|---|---|
@babyshop/types |
Storefront (about 51 files), admin (1 file) | tsc → dist/index.js + .d.ts |
@babyshop/ui |
Storefront, admin | None. Apps import the TypeScript source directly |
@babyshop/config |
Listed by the storefront only | None |
- 1Edit packages/*
- 2turbo build ^buildtypes → dist/
- 3Next transpilestranspilePackages
- 4Web + adminsame types, same look
@babyshop/types
Section titled “@babyshop/types”These are the TypeScript shapes of everything the API returns. A
Product or Order therefore means the same thing in every app.
| Group | Exports |
|---|---|
| Domain | User, Vendor, Address, AddressInput, Category, Brand, ProductType, SocialMedia, Review, Product, OrderItem, Order, CartItem, Cart |
| API and auth | ApiResponse, PaginatedResponse, CategoriesResponse, ProductsResponse, LoginCredentials, RegisterCredentials, AuthResponse |
| CMS pages | SectionType, SectionLayout, AutoRule, IHeroBanner, ISectionFilters, IBannerConfig, IPageSection, IResolvedPageSection, IPage, IPageWithSections, INavMenuPage, IProductBase, IProductBaseWithProducts |
The package compiles with tsc (Node16 modules, with declarations) into
dist/. Apps resolve main and types from that folder, so build the
packages before the first run. pnpm setup and pnpm build:packages do
this, and so does any Turborepo task that depends on ^build.
@babyshop/ui
Section titled “@babyshop/ui”This is the BabyMart design system. It has a few shadcn-style components, the colour tokens, and the logo.
- Components:
Button(withbuttonVariants),Badge,Input,Label,Textarea,Separator,Skeleton, and theCardfamily (CardHeader,CardTitle,CardDescription,CardAction,CardContent,CardFooter). - Helpers:
cn,formatCurrency,formatDate,formatDateTime. - Brand:
BrandMark, the “Little Bear” SVG drawn with the tokens, andBrandLogo, which is the mark plus the wordmark. - Tokens:
@babyshop/ui/styles/tokens.css, with:rootand.darkCSS variables.
The package ships source only (main is ./src/index.ts, and build is just
tsc --noEmit). Each app compiles it as part of its own build.
The palette
Section titled “The palette”The colours come from the product photography: cream, chocolate brown and
soft peach. Components use the token names (bg-primary,
text-muted-foreground), never raw hex values.
| Token | Light | Used for |
|---|---|---|
--background |
#f9eee8 cream |
Page background |
--foreground / --primary |
#381c0c chocolate |
Text and main buttons |
--secondary |
#f6e3d8 peach |
Soft washes, hover states |
--accent |
#8c4e32 sienna |
Links and highlights |
--muted-foreground |
#7a6256 |
Secondary text |
--border |
#eadfd6 |
Dividers and inputs |
--success / --warning / --destructive |
#2f6b45 / #9a6b1a / #9d2c24 |
Status colours |
.dark swaps these for a dark brown theme with background #1c1410 and
foreground #f9eee8.
@babyshop/config
Section titled “@babyshop/config”It exports three constant objects:
API_CONFIG:BASE_URL(fromNEXT_PUBLIC_API_URL, falling back tohttp://localhost:8000) and a map of the main/api/*endpoints.PAYMENT_CONFIG: the Stripe publishable key and the currencyUSD.APP_CONFIG: the name, description and version.
The storefront lists it in transpilePackages, but no app imports it today.
Each app reads its own environment variables instead.
How the apps are wired
Section titled “How the apps are wired”- Storefront:
next.config.mjshastranspilePackages: ["@babyshop/ui", "@babyshop/types", "@babyshop/config"].app/globals.cssimports@babyshop/ui/styles/tokens.cssand adds@source "../../../packages/ui/src"so Tailwind sees the package’s classes. - Admin dashboard:
src/index.cssimports the same tokens and its own@sourcepath. Vite compiles the TypeScript source directly. - Re-exports: both apps have files in
components/ui/that re-export the shared components, so app code imports from one local path.
Adding something shared
Section titled “Adding something shared”- Add a type to
packages/types/src/index.ts, or a component underpackages/ui/src/components/. - Export it. Add it to the package’s
src/index.ts. For a newuicomponent, also add an entry to theexportsmap inpackages/ui/package.json. - Rebuild the types:
pnpm build:packages(onlytypesproduces output). - Import it in the apps:
import type { Product } from "@babyshop/types"orimport { Button } from "@babyshop/ui".