🗄️ 4. Database & Schema
TaskNexus uses a PostgreSQL database managed by Prisma ORM.
🧬 Schema Overview (prisma/schema.prisma)
The schema is the single source of truth for our data models.
Primary Models
1. User
The central entity.
- Roles:
SUPER_ADMIN,ADMIN,MANAGER,EMPLOYEE,CUSTOMER. - Relationships: Owns Projects, Submitted Requirements, Assigned Jobs/Tasks.
- Security: Stores
violationCountandmustChangePasswordflags.
2. Project
A container for work, managed by a Manager.
- Contains multiple
Requirements.
3. Requirement
A feature request from a Customer.
- Status Workflow:
DRAFT->PENDING_REVIEW->APPROVED->REJECTED. - AI Fields:
securityLevel(Low/Med/High),category(Functional/Non-Functional).
4. Job
A technical unit of work derived from a Requirement.
- e.g., "Implement Login API".
- Assigned to a single Employee.
- Has an
estimatedEffort(hours).
5. Task
A granular step within a Job.
- e.g., "Write SQL Query", "Create Unit Test".
- Tracked on the Kanban board.
- Relationships: Linked to a
Joband optionally aSprint. - Status:
BACKLOG,TODO,IN_PROGRESS,REVIEW,DONE.
6. Sprint
A time-boxed period for executing tasks.
- Managed in the Scrum Manager.
- Fields:
startDate,endDate,status(PLANNING,ACTIVE,COMPLETED). - Workflow: Tasks are assigned to a Sprint during planning and tracked until closure.
Audit Models
AuditLog: Immutable history of actions.{ actor: "UserA", action: "DELETED_PROJECT", target: "ProjectB" }
ViolationLog: Records of failed AI safety checks.AccountSuspension: Active and past suspension records.
🛠️ Prisma Workflows
Making Schema Changes
- Modify
prisma/schema.prisma. - Push Changes (Development): Warning: This may reset data if there are breaking changes.
- Generate Client: Next.js requires restarting the dev server after this.
Viewing Data
Use Prisma Studio, a built-in GUI.
Opens onhttp://localhost:5555.
Seeding Data
We use a seed script to populate default users (Super Admin) and generic data.
Check package.json for the seed command, or run: