ποΈ Monorepo Architecture
A monorepo (monolithic repository) is a single repository that holds the code and assets for multiple projects, apps, or packages. Forjnot is designed as a monorepo to help you scale, share code, and manage dependencies efficiently.
π¦ When Should You Use a Monorepo?
- You have multiple apps (backend, frontend, CLI, etc.) that share code or dependencies.
- Your team wants to enforce consistent tooling, linting, and formatting across all projects.
- You need to coordinate releases and updates across several packages or services.
- You want to simplify dependency management and avoid version drift between packages.
- You value a single source of truth for your codebase and developer experience.
π Why Use a Monorepo? (Advantages)
- Code Sharing: Easily share types, utilities, configs, and logic between apps and packages.
- Atomic Changes: Make cross-cutting changes in a single commit (e.g., update a shared type and all consumers at once).
- Consistent Tooling: Enforce the same lint, format, and test rules everywhere.
- Faster Onboarding: New team members only need to clone one repo to get started.
- Centralized Dependency Management: Keep dependencies in sync and avoid duplication.
- Better CI/CD: Run tests and builds only for affected projects with tools like Turborepo.
- Scalability: Add new apps or packages as your project grows, without restructuring.
π Extreme Positives of Forjnot's Monorepo
- Modern Tooling: Uses Turborepo for blazing-fast builds and caching.
- Shared Everything: Configs, types, DTOs, environment, logger, and utilities are all reusable.
- Production Ready: Biome, PM2, health checks, and more are set up out of the box.
- Optional Frontend: Next.js app is included but not requiredβremove or extend as needed.
- CLI Module Generator: Quickly scaffold new modules for the backend.
- Consistent DX: All apps and packages follow the same conventions and structure.
- Easy Deployment: Supports Vercel, Docker, and other modern deployment targets.
π¦ Example Monorepo Structure
forjnot/
βββ apps/
β βββ backend/ # NestJS application
β βββ frontend/ # Next.js application
βββ packages/
β βββ shared-configs/ # Shared configurations
β βββ shared-constants/ # Shared constants
β βββ shared-dtos/ # Shared DTOs
β βββ shared-env/ # Environment configuration
β βββ shared-logger/ # Shared logger
β βββ shared-types/ # Shared TypeScript types
β βββ shared-utils/ # Shared utilities
βββ package.json
π οΈ Initialize Your Own Monorepo
Clone the Forjnot monorepo template:
git clone https://github.com/aman-sharma-dev/forjnot.git