Welcome to CONA

CONA is a comprehensive business management system built with Next.js, Temporal, and Supabase.

Getting Started

This documentation will help you understand and work with the CONA codebase.

Overview

CONA follows a structured, modular architecture with:

  • Next.js App Router: Web application framework
  • TypeScript: For type-safe development
  • PNPM: Package management with workspaces
  • Temporal: Workflow automation
  • Supabase: Database
  • Auth0: Authentication

Monorepo Structure

CONA uses a monorepo architecture with PNPM workspaces for efficient package management and code sharing.

CONA/
├── apps/                              # Applications
│   ├── webapp/                        # Next.js web application
│   │   ├── app/                       # Next.js App Router pages
│   │   │   ├── (pages)/               # Route groups
│   │   │   ├── api/                   # API routes
│   │   │   ├── hooks/                 # React hooks
│   │   │   ├── lib/                   # App-specific libraries
│   │   │   │   ├── actions/           # Server actions
│   │   │   │   ├── auth/              # Authentication logic
│   │   │   │   ├── services/          # External services
│   │   │   │   ├── third-party-actions/ # Integration APIs
│   │   │   │   ├── types/             # App-specific types
│   │   │   │   ├── utils/             # App-specific utilities
│   │   │   │   └── workflows/         # Workflow definitions
│   │   │   ├── providers/             # React providers
│   │   │   └── ui/                    # UI components
│   │   │       ├── cards/             # Card components
│   │   │       ├── columns/           # Table columns
│   │   │       ├── comboboxes/        # Dropdown components
│   │   │       ├── elements/          # Composite elements
│   │   │       ├── forms/             # Form components
│   │   │       ├── modals/            # Modal dialogs
│   │   │       └── skeletons/         # Loading skeletons
│   │   └── ...                        # Config files, etc.
│   ├── temporal-workers/              # Temporal workflow workers
│   │   └── src/                       # Worker implementation
│   └── internal-docs/                 # Internal documentation

├── packages/                          # Shared packages
│   ├── core/                          # @cona/core
│   │   └── src/                       # Business logic & domain models
│   │       ├── accounting_periods/    # Accounting period operations
│   │       ├── actors/                # Actor management
│   │       ├── addresses/             # Address handling
│   │       ├── documents/             # Document processing
│   │       ├── entities/              # Entity management
│   │       ├── integrations/          # Integration core logic
│   │       ├── reconciliation/        # Transaction reconciliation
│   │       └── ...                    # Other business domains
│   ├── database/                      # @cona/database
│   │   ├── prisma/                    # Database schema & migrations
│   │   └── src/                       # Database client & utilities
│   ├── temporal-workflows/            # @cona/temporal-workflows
│   │   └── src/                       # Workflow definitions & activities
│   │       ├── activities/            # Temporal activities
│   │       ├── workflows/             # Workflow definitions
│   │       └── types/                 # Workflow types
│   ├── temporal-config/               # @cona/temporal-config
│   │   └── src/                       # Temporal client configuration
│   ├── ui/                            # @cona/ui
│   │   └── src/                       # Reusable UI components
│   │       └── components/            # Shadcn/UI components
│   ├── utils/                         # @cona/utils
│   │   └── src/                       # Shared utility functions
│   │       ├── encryption.ts          # Data encryption/decryption
│   │       ├── date.ts                # Date utilities
│   │       └── ...                    # Other utilities
│   ├── types/                         # @cona/types
│   │   └── src/                       # Shared TypeScript types
│   ├── config-eslint/                 # ESLint configuration
│   ├── config-typescript/             # TypeScript configuration
│   └── tailwind-config/               # Tailwind CSS configuration

├── package.json                       # Root package.json
├── pnpm-workspace.yaml                # PNPM workspace configuration
└── pnpm-lock.yaml                     # Dependency lock file

Package Architecture

Core Business Logic (@cona/core)

  • Purpose: Pure business logic and domain models
  • Usage: Imported by webapp and temporal workers
  • Contains: Database operations, business rules, data transformations
  • Import: import { functionName } from "@cona/core"

Database Layer (@cona/database)

  • Purpose: Database schema, migrations, and Prisma client
  • Usage: Shared across all applications
  • Contains: Prisma schema, migrations, database utilities
  • Import: import { prisma } from "@cona/database"

Temporal Workflows (@cona/temporal-workflows)

  • Purpose: Workflow definitions and activities
  • Usage: Used by temporal-workers application
  • Contains: Long-running workflows, background tasks
  • Import: import { workflowName } from "@cona/temporal-workflows"

Shared UI Components (@cona/ui)

  • Purpose: Reusable UI components based on Shadcn/UI
  • Usage: Imported by webapp and other frontends
  • Contains: Base components, design system elements
  • Import: import { Button } from "@cona/ui"

Utilities (@cona/utils)

  • Purpose: Shared utility functions
  • Usage: Used across all packages and applications
  • Contains: Encryption, date handling, formatting, validation
  • Import: import { encryptText } from "@cona/utils"

Types (@cona/types)

  • Purpose: Shared TypeScript type definitions
  • Usage: Used across all packages for type safety
  • Contains: API interfaces, domain models, shared types
  • Import: import type { ActionResponse } from "@cona/types"

Import Aliases

The webapp uses path aliases for cleaner imports:

// Webapp internal imports
import { something } from "@/app/lib/utils"     // ./app/lib/utils
import { Component } from "@/app/ui/components" // ./app/ui/components

// Shared package imports
import { coreFunction } from "@cona/core"
import { prisma } from "@cona/database"
import { Button } from "@cona/ui"
import { encryptText } from "@cona/utils"
import type { ActionResponse } from "@cona/types"

Key Features

  • Type-Safe Development: Full TypeScript support across all packages
  • Modular Architecture: Clear separation of concerns between packages
  • Efficient Package Management: PNPM workspaces for fast installs and builds
  • Shared Code Reuse: Common logic in packages, app-specific code in apps
  • Database Integration: Supabase with Prisma ORM and migrations
  • Workflow Automation: Temporal for background processing
  • Comprehensive UI Components: Shadcn/UI-based design system

Next Steps