Prerequisites
Before you begin, ensure you have the following installed:Node.js
Version 20.x or higher
npm
Version 10.x or higher
Git
Latest version
Installation
Configure environment variables
Create a
.env.local file in the root directory with the required variables:The
NEXT_PUBLIC_API_URL should point to your backend API. For development, this might be a local server or a staging environment.Environment Variables
Required Variables
| Variable | Description | Example |
|---|---|---|
NEXT_PUBLIC_API_URL | Backend API base URL | https://api.example.com |
SESSION_SECRET | Secret key for session encryption | your-secret-key-here |
Backend API Considerations
MicroCBM requires a running backend API to function properly. Without a connected backend:- Authentication pages will render but login will fail
- Protected pages will show loading states or errors
- Data-dependent features will not display information
The backend API hosted on Render’s free tier may require 30-60 seconds for cold starts on the first request.
Package Dependencies
Core Dependencies
Key packages used in MicroCBM:- Next.js
- React Query
- Zustand
- React Hook Form
Next.js 15.5.9 - React framework with App Router
- Server Components by default
- File-based routing
- Built-in API routes
- Server Actions support
UI Component Libraries
Radix UI
Radix UI
Unstyled, accessible UI components:
- Dialog/Modal
- Dropdown Menu
- Select
- Tabs
- Checkbox
- Radio Group
- Switch
- Popover
- Scroll Area
Recharts
Recharts
Composable charting library built on React components:
- Area charts for trend analysis
- Bar charts for comparisons
- Pie charts for distributions
- Line charts for time series data
XYFlow
XYFlow
Node-based UI library for building interactive diagrams:
- Used for Logic Tree visualization in RCA module
- Drag-and-drop node creation
- Custom node types
- Auto-layout capabilities
Framer Motion
Framer Motion
Animation library for React:
- Page transitions
- Modal animations
- Loading states
- Interactive feedback
Development Scripts
Available Commands
- dev
- build
- start
- lint
Starts the Next.js development server with:
- Hot Module Replacement (HMR)
- Fast Refresh for instant updates
- Error overlay for debugging
- Runs on
http://localhost:3000
IDE Setup
VS Code (Recommended)
Recommended extensions:TypeScript Configuration
MicroCBM uses strict TypeScript settings:@/ path alias allows importing from the src/ directory:
Middleware & Security
MicroCBM includes authentication middleware that protects all routes except/auth/*:
The middleware excludes static assets, API routes, and public metadata files from authentication checks.
Troubleshooting
Port 3000 already in use
Port 3000 already in use
If port 3000 is already occupied:
Backend API connection errors
Backend API connection errors
If you see API connection errors:
- Verify
NEXT_PUBLIC_API_URLis correct in.env.local - Check if the backend API is running
- Wait 30-60 seconds for cold start if using Render free tier
- Check browser console for detailed error messages
Module not found errors
Module not found errors
If you encounter module resolution errors:
TypeScript errors
TypeScript errors
For TypeScript compilation issues:
Next Steps
Project Structure
Understand the codebase organization
Routing
Learn about Next.js App Router patterns