CHS Lite - Evault
EVault (Society Document Safe) Implementation Plan
This document outlines the detailed implementation plan to introduce the EVault (Society Document Safe) feature to CHS Lite. It details schema modifications, backend server actions, the mobile-first frontend UI structure, security considerations, and advanced suggestions for enhancements.
Proposed Database Schema (Prisma & SQL Server)
To ensure consistency with the existing database design, we will define a new model named EVault which represents society-wide documents. All documents are segregated at the society level using chs_id.
[NEW] schema.prisma
model EVault {
id String @id @db.NVarChar(100)
chs_id String? @db.NVarChar(6)
docno String? @db.NVarChar(50)
docname String? @db.NVarChar(100)
description String? @db.NVarChar(Max)
valid_upto DateTime? @db.DateTime
access_level String? @db.NVarChar(50) // "Public" (all members of society), "MCOnly" (Managing Committee only)
created_at DateTime? @default(now()) @db.DateTime
// Ensure document numbers are unique within the same society
@@unique([chs_id, docno], map: "UQ_evault_Chs_DocNo")
@@map("evault")
}Proposed Operations (Next.js Server Actions)
We will implement the following operations in a new server action file app/actions/evault.ts:
getDocuments(): Fetch documents matching the current society’schs_idbased on the user’s role.- System/SA/Admin/Manager/Security: Fetch all documents (including
MCOnly). - User (Standard Resident): Fetch only
Publicdocuments belonging to their society.
- System/SA/Admin/Manager/Security: Fetch all documents (including
createDocument(data): Validates input, checks for duplicatedocnoinside the society, and saves record details. (Admin/Manager/System only)updateDocument(id, data): Updates document metadata. (Admin/Manager/System only)deleteDocumentRecord(id): Deletes the database record. (Strictly Admin/System only; Manager prohibited from deletion as per role guidelines).
Front-End UI Design System (Mobile-First)
The UI situated in app/evault/ will follow a clean, accessible layout:
- Dashboard/List View (
app/evault/page.tsx):- Filter by access level (e.g., Public Documents, MC Confidential).
- Search bar querying document name, number, or description.
- Expiry indicator badge (Green: Active, Amber: Expiring soon, Red: Expired) to easily flag renewal dates for society certifications.
- Dynamic cards showing details with quick actions.
- Add/Edit Form Modal (
app/evault/components/DocForm.tsx):- Form inputs matching the simplified schema.
- Visibility setting: Public (Visible to all society residents) or MC-Only (Visible to Managing Committee).
- Details Viewer Drawer (
app/evault/components/DocDetails.tsx):- Bottom sheet drawer showing full metadata and expiry warnings.
Suggestions for Improvement
To build a robust and user-friendly EVault system:
- Automated Expiry Notifications (Telegram Integration): Use the project’s Telegram Bot (
lib/telegram.ts) to send scheduled alerts to Managing Committee members 30 days and 7 days prior to thevalid_uptodate of critical society documents (e.g., Fire Safety, Lift license). - Audit Logging: Keep a simple history log of which Admins or Managers added, updated, or deleted society documents.