A production-ready, multi-tenant Task Management System backend built with Node.js, TypeScript, Express, and Prisma (PostgreSQL).
This project uses PostgreSQL as its primary database. Below is the Entity-Relationship Diagram (ERD) mapping out the database schema, including Users, Projects, Memberships, Tasks, Comments, and Attachments.
erDiagram
User {
string id PK
string email UK
string passwordHash
string firstName
string lastName
datetime deletedAt
datetime createdAt
datetime updatedAt
}
Project {
string id PK
string name
string slug UK
string description
string status
string ownerId FK
datetime deletedAt
datetime createdAt
datetime updatedAt
}
ProjectMember {
string id PK
string projectId FK
string userId FK
string role
datetime createdAt
datetime updatedAt
}
Task {
string id PK
string title
string description
string status
string priority
datetime dueDate
string projectId FK
string assigneeId FK
string creatorId FK
datetime deletedAt
datetime createdAt
datetime updatedAt
}
Comment {
string id PK
string content
string taskId FK
string userId FK
datetime createdAt
datetime updatedAt
}
Attachment {
string id PK
string fileName
string fileUrl
int fileSize
string mimeType
string taskId FK
datetime createdAt
datetime updatedAt
}
%% Relationships
User ||--o{ Project : "owns"
User ||--|{ ProjectMember : "joins"
Project ||--|{ ProjectMember : "has"
Project ||--o{ Task : "contains"
User ||--o{ Task : "creates"
User |o--o{ Task : "assigned_to"
Task ||--o{ Comment : "has"
User ||--o{ Comment : "writes"
Task ||--o{ Attachment : "has"
- Runtime: Node.js
- Language: TypeScript
- Framework: Express.js
- ORM: Prisma
- Database: PostgreSQL
- Authentication: JWT (JSON Web Tokens) with stateless validation
- Node.js (v18+ recommended)
- npm or yarn
- PostgreSQL database instance
-
Clone the repository:
git clone https://github.com/Amresh-01/Task-Management-system.git cd Task_management_backend -
Install dependencies:
npm install
-
Configure environment variables. Create a
.envfile in the root directory:DATABASE_URL="postgresql://username:password@localhost:5432/task_management_db?schema=public" JWT_SECRET="your_jwt_secret_key" PORT=5000
-
Run database migrations:
npx prisma migrate dev
-
Start the development server:
npm run dev
├── prisma/ # Prisma schema and database migrations
├── src/
│ ├── controllers/ # Route handler controllers
│ ├── middlewares/ # Auth, Validation, & Error handling middleware
│ ├── models/ # TypeScript interfaces & types
│ ├── routes/ # API Endpoint routing definitions
│ ├── services/ # Business logic layer
│ └── app.ts # Express app configuration & server entry point
├── package.json
└── tsconfig.json