@company-manager/docs
Development

Project Structure

Complete overview of the Company Manager monorepo structure, applications, packages, and development patterns.

Project Structure

Company Manager is organized as a comprehensive monorepo containing multiple applications, shared packages, and infrastructure components. This document provides a complete overview of the project structure and organization.

📁 Root Directory Structure

company-manager-new/
├── apps/                    # Applications
├── packages/                # Shared packages
├── docs/                    # Documentation
├── infra/                   # Infrastructure configuration
├── scripts/                 # Automation scripts
├── tools/                   # Development tools
├── proto/                   # Protocol buffer definitions
├── newsletters/             # Email templates
├── functions/               # Serverless functions
├── logs/                    # Log files
├── tasks/                   # Task management
├── package.json             # Root package configuration
├── turbo.json              # Turborepo configuration
├── bun.lockb               # Dependency lock file
└── README.md               # Project documentation

🚀 Applications (apps/)

Web Applications

  • app/ - Main Next.js application (primary interface)
  • website/ - Marketing website
  • docs/ - Documentation site (Fumadocs)

Desktop Applications

  • desktop-app/ - Production desktop application
  • desktop-app-dev/ - Development desktop application

Mobile Applications

  • app-mobile/ - React Native mobile application

Browser Extensions

  • chrome-extension/ - Production Chrome extension
  • chrome-extension-dev/ - Development Chrome extension
  • vscode-extension/ - Visual Studio Code extension

Go Microservices

  • queue-manager-go/ - Queue management service
  • asynq-job-queue/ - Async job processing service
  • infra-dashboard-go/ - Infrastructure monitoring dashboard

Base Applications

  • app-base/ - Base application template

📦 Packages (packages/)

Core Packages

packages/
├── db/                     # Database layer (Prisma)
├── common/                 # Shared utilities and types
├── utils/                  # Common utility functions
├── trpc/                   # TRPC API configuration
└── cli/                    # Command-line interface

UI Packages

packages/
├── ui/                     # Shared UI components (ShadCN)
├── plate-ui/               # Rich text editor components
├── mobile-components/      # React Native components
├── ui-mobile/              # Mobile-specific UI components
└── navigation/             # Navigation components

Development Packages

packages/
├── mcp-server/             # Model Context Protocol server
├── browser-testing/        # Automated testing utilities
├── tests/                  # Shared testing utilities
├── typescript-config/      # TypeScript configurations
└── eslint-config/          # Linting configurations

Mobile & Native Packages

packages/
├── expo-config/            # React Native Expo configuration
├── mobile-utils/           # Mobile utility functions
└── proto-go/               # Protocol buffer Go definitions

Queue & Task Management

packages/
├── queue-manager/          # Task queue management
├── queue-task/             # Task definitions and handlers
└── proto-go/               # Protocol buffer definitions

🏗️ Detailed Application Structure

Main Application (apps/app/)

apps/app/
├── src/
│   ├── app/                # Next.js App Router
│   │   ├── (app)/          # Main application routes
│   │   ├── api/            # API routes
│   │   ├── auth/           # Authentication pages
│   │   └── globals.css     # Global styles
│   ├── components/         # React components
│   │   ├── ui/             # Base UI components
│   │   ├── forms/          # Form components
│   │   ├── layout/         # Layout components
│   │   ├── charts/         # Chart components
│   │   ├── data-table/     # Table components
│   │   └── features/       # Feature-specific components
│   ├── lib/                # Utility libraries
│   │   ├── auth.ts         # Authentication logic
│   │   ├── db.ts           # Database connection
│   │   ├── utils.ts        # Utility functions
│   │   └── validations.ts  # Zod schemas
│   ├── hooks/              # Custom React hooks
│   ├── stores/             # Zustand stores
│   ├── types/              # TypeScript definitions
│   ├── styles/             # Styling files
│   └── utils/              # Utility functions
├── public/                 # Static assets
│   ├── images/             # Image assets
│   ├── icons/              # Icon assets
│   └── data/               # Static data files
├── prisma/                 # Database schema (symlinked)
├── next.config.js          # Next.js configuration
├── tailwind.config.js      # Tailwind CSS configuration
├── package.json            # Package configuration
└── tsconfig.json           # TypeScript configuration

Database Package (packages/db/)

packages/db/
├── prisma/
│   ├── schema.prisma       # Database schema
│   ├── migrations/         # Migration files
│   ├── seed.ts            # Seed data script
│   └── data/              # Sample data files
├── src/
│   ├── client.ts          # Prisma client configuration
│   ├── types.ts           # Database types
│   ├── utils/             # Database utilities
│   │   ├── seed-utils.ts  # Seeding utilities
│   │   ├── validation.ts  # Schema validation
│   │   └── helpers.ts     # Query helpers
│   └── index.ts           # Package exports
├── package.json           # Package configuration
└── tsconfig.json          # TypeScript configuration

🛠️ Development Tools Structure

Scripts (scripts/)

scripts/
├── e2e-queue/             # End-to-end queue testing
├── queue-manager/         # Queue management scripts
├── utils/                 # Utility scripts
├── analyze-performance.mjs # Performance analysis
├── check-build-dependencies.mjs # Build dependency check
├── docker-setup.mjs       # Docker setup automation
└── query-db.ts           # Database query utility

Infrastructure (infra/)

infra/
├── docker-compose.yml     # Docker Compose configuration
├── redis/                 # Redis configuration
├── temporal/              # Temporal workflow configuration
├── certs/                 # SSL certificates
├── PORT_MAPPING.md        # Port allocation documentation
└── README.md              # Infrastructure documentation

📋 Configuration Files

Root Configuration

  • package.json - Root package with workspace configuration
  • turbo.json - Turborepo build configuration
  • bun.lockb - Dependency lock file
  • .gitignore - Git ignore rules
  • .env.example - Environment variable template

TypeScript Configuration

packages/typescript-config/
├── base.json              # Base TypeScript config
├── nextjs.json            # Next.js specific config
├── react-library.json     # React library config
└── package.json           # Package configuration

ESLint Configuration

packages/eslint-config/
├── library.js             # Library ESLint config
├── next.js                # Next.js ESLint config
├── react-internal.js      # Internal React config
└── package.json           # Package configuration

🔄 Build System & Monorepo

Turborepo Configuration

The project uses Turborepo for efficient builds and caching:

{
  "pipeline": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": [".next/**", "dist/**"]
    },
    "dev": {
      "cache": false,
      "persistent": true
    },
    "lint": {},
    "test": {
      "dependsOn": ["build"]
    }
  }
}

Workspace Configuration

{
  "workspaces": ["apps/*", "packages/*"]
}

📊 Dependencies Overview

Runtime Dependencies

  • Frontend: React 18+, Next.js 15+, TypeScript
  • Backend: Node.js, Go 1.21+, Prisma, TRPC
  • Database: PostgreSQL, Redis
  • UI: Tailwind CSS, ShadCN/UI, Radix UI
  • State: Zustand, React Query
  • Forms: React Hook Form, Zod

Development Dependencies

  • Build: Turborepo, Bun, ESBuild
  • Testing: Vitest, Playwright, React Testing Library
  • Linting: ESLint, Prettier, TypeScript
  • Tools: Prisma CLI, Docker, Kubernetes

🚀 Development Workflow

Getting Started

  1. Clone repository: git clone <repo-url>
  2. Install dependencies: bun install
  3. Setup environment: Copy .env.example files
  4. Start infrastructure: bun run infra:start
  5. Start development: bun run dev:app

Common Commands

# Development
bun run dev:app              # Start main application
bun run dev:docs             # Start documentation
bun run dev:website          # Start website

# Building
bun run build                # Build main app
bun run build:all            # Build all packages
bun run build:packages       # Build shared packages

# Testing
bun run test                 # Run tests
bun run test:e2e             # Run E2E tests
bun run lint                 # Run linting

# Infrastructure
bun run infra:start          # Start all services
bun run infra:stop           # Stop all services
bun run infra:status         # Check service status

Development Patterns

Package Dependencies

  • Packages depend on other packages via workspace references
  • Applications import packages using @company-manager/package-name
  • Shared types are defined in @company-manager/common

Code Organization

  • Components follow atomic design principles
  • Business logic is separated into custom hooks
  • API logic is centralized in TRPC routers
  • Database operations use Prisma ORM

Testing Strategy

  • Unit tests for utilities and components
  • Integration tests for API endpoints
  • E2E tests for critical user flows
  • Visual regression tests for UI components

📈 Scalability Considerations

Horizontal Scaling

  • Go microservices can be scaled independently
  • Frontend can be deployed to multiple regions
  • Database read replicas for improved performance
  • Queue workers can be scaled based on load

Code Organization

  • Modular package structure allows for easy extraction
  • Clear separation of concerns between layers
  • Standardized interfaces for external integrations
  • Feature flags for gradual rollouts

Performance Optimization

  • Bundle splitting and lazy loading
  • Image optimization and CDN usage
  • Database query optimization
  • Caching strategies at multiple levels

🔒 Security & Compliance

Security Measures

  • Multi-tenant data isolation
  • Role-based access control
  • Input validation and sanitization
  • Secure environment variable management

Code Quality

  • TypeScript for type safety
  • ESLint for code consistency
  • Prettier for code formatting
  • Automated testing and CI/CD

📚 Documentation Structure

Documentation Types

  • API Documentation: Auto-generated from TRPC schemas
  • Component Documentation: Storybook stories
  • User Documentation: Markdown files in /docs
  • Developer Documentation: This documentation site

Documentation Maintenance

  • Documentation is version-controlled alongside code
  • Examples are tested and validated
  • Links are automatically checked
  • Documentation is updated with each release

This project structure supports rapid development, easy maintenance, and horizontal scaling while maintaining code quality and security standards. For specific implementation details, refer to the individual application and package documentation.