Enterprise Resource Planning System built with N-Tier Architecture. Featuring a NestJS Backend, Next.js Admin Dashboard, and React Native Mobile App.
This repository uses a Monorepo structure managed by TurboRepo.
| Tier | Technology Stack | Location | Port |
|---|---|---|---|
| Logic (API) | NestJS, Prisma, PostgreSQL, Redis | apps/api |
3000 |
| Client (Web) | Next.js 16, Tailwind CSS 4 | apps/web |
3001 |
| Client (Mobile) | React Native (Expo) | apps/mobile |
8083 |
| Database | PostgreSQL 15 | Docker | 5432 |
| Cache | Redis 7 | Docker | 6379 |
- Multi-Tenancy: Data isolation via
tenantId. - RBAC: Role-Based Access Control (Admin, Manager, User).
- Real-time Notifications: Persistent alerts via WebSockets (Socket.io).
- Strict Typing: Shared DTOs and Logic.
- DevOps: Docker Orchestration & Nginx Reverse Proxy.
- Node.js v18 or later.
- Docker Desktop (for Database & Redis).
- Git
Clone the repository and install dependencies from the root:
git clone <repo-url>
cd n-tier-architecture
npm installLaunch PostgreSQL and Redis using Docker:
# Start DB and Cache in background
docker-compose -f docker-compose.dev.yml up -dApply the database schema (Prisma Migrations):
# Run this from the root
npx prisma migrate dev --name init --schema=apps/api/prisma/schema.prismaNote: We point explicitly to the schema file location.
Start API, Web, and Mobile simultaneously:
npm run devThis command uses TurboRepo to launch all apps in parallel.
- API: http://localhost:3000/api/v1
- Web Dashboard: http://localhost:3001
- Admin:
admin@example.com/password123 - Manager:
manager@example.com/password123
- Admin:
- Mobile App: Scan the QR code in your terminal with the Expo Go app (Android/iOS).
To reset and seed the database with default users:
cd apps/api
npx prisma db seedThe packages/ directory is reserved for Shared Libraries to be used across apps in the future:
packages/types(Planned): Shared TypeScript interfaces & DTOs.packages/ui(Planned): Shared UI components.packages/config(Planned): Shared ESLint/TSConfig settings.
If npm run dev fails because a port is taken:
# Windows (PowerShell) - Force kill processes
Stop-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess -Force
Stop-Process -Id (Get-NetTCPConnection -LocalPort 3001).OwningProcess -ForceIf the API fails with this error, regenerate the client:
cd apps/api
npx prisma generateEnsure apps/web/src/context/auth-context.tsx properly decodes the token. The repo includes a fix that uses jwt-decode to restore the user session on page load.
To simulate a real production environment with Nginx:
docker-compose -f docker-compose.prod.yml up --buildAccess the app at http://localhost (Port 80).
GitHub Actions are configured in .github/workflows/ci.yml to automatically Lint, Build, and Test on every push to main.
If Postgres fails to start due to permission errors on the postgres_data volume:
- Stop the containers:
docker-compose down - Prune volumes:
docker volume prune -f - Restart:
docker-compose -f docker-compose.dev.yml up -d