The application uses the following MongoDB schemas:
- Account - User account management
- Event - Event creation and management
- Team - Team formation and management
- Caft - Document creation and discussion system
- Stance - User stances and comments on Cafts
- Media - Media file management
- Role - User role management
{
username: String, // Required, unique, lowercase
prefix: String, // Optional title prefix
firstName: String, // Required, lowercase
lastName: String, // Optional, lowercase
age: Number, // Required, min: 5
gender: String, // Required, enum: ['m', 'f', 'o']
email: String, // Required, unique, validated
isEmailPublic: Boolean, // Default: false
phone: String, // Optional, unique, E.164 format
password: String, // Required, min: 8 chars, validated
affiliationInstitution: String, // Optional
affiliationTag: String, // Optional
educationQualification: String, // Required, enum values
nationality: String, // Required, country list, default: 'India'
nationalityProof: { // Object
type: String, // enum: ['Aadhaar Card', 'Passport', 'Voter ID', 'Driving License', 'Others']
nationalIdLink: String // Optional
},
isResidentIndian: Boolean, // Default: true
indianState: String, // Optional, enum of Indian states
district: String, // Optional, lowercase
participations: [ObjectId], // Array of Participation references
roles: [ObjectId], // Array of Role references
registrationDate: Date, // Default: Date.now
tokens: [{ // Array of objects
token: String // Required
}],
timestamps: true // createdAt, updatedAt
}{
organizerId: ObjectId, // Required, ref: 'Account'
certificateTypes: [String], // Array of certificate types
certificatesIssued: Boolean, // Default: false
description: String, // Required
title: String, // Required
eventType: String, // Required, enum: ['Workshop', 'Seminar', 'Conference', 'Competition', 'Hackathon', 'Webinar', 'Training', 'Other']
orgTeam: [ObjectId], // Array of Role references
participants: [ObjectId], // Array of Participation references
theme: String, // Required
typesOfDocs: [String], // Required array
location: String, // Required
dates: [{ // Array of date objects
start: Date, // Required
end: Date // Required
}],
timestamps: true // createdAt, updatedAt
}{
teamName: String, // Optional
members: [{ // Array of member objects
certificateTypes: [String], // Array, default: 'None'
accountId: ObjectId // ref: 'Account'
}],
eventId: ObjectId, // ref: 'Event'
timestamps: true // createdAt, updatedAt
}{
accountId: ObjectId, // Required, ref: 'Account', indexed
eventId: ObjectId, // Optional, ref: 'Event'
teamId: ObjectId, // Optional, ref: 'Team'
title: String, // Required, trimmed
content: String, // Optional, trimmed
discription: String, // Required, trimmed
media: [ObjectId], // Array of Media references
parentCaft: ObjectId, // Optional, ref: 'Caft', indexed (for comments/replies)
stanceCaftId: ObjectId, // Optional, ref: 'Caft' (Caft which contains a stance)
stanceCounts: { // Object
votes: Number, // Default: 0
vetoes: Number, // Default: 0
neutrals: Number, // Default: 0
remands: Number // Default: 0
},
submitted: Boolean, // Default: false
submissionDate: Date, // Default: Date.now
timestamps: true // createdAt, updatedAt
}{
accountId: ObjectId, // Required, ref: 'Account', indexed
stance: String, // Required, enum: ['votes', 'vetoes', 'neutrals', 'remands']
parentCaftId: ObjectId, // Optional, ref: 'Caft', indexed (Caft which contains this stance)
timestamps: true // createdAt, updatedAt
}{
type: String, // Required, enum: ['image', 'video', 'document']
url: String, // Required, trimmed
owner: ObjectId, // Required, ref: 'Caft'
timestamps: true // createdAt, updatedAt
}{
roleName: String, // Required, enum: ['host', 'coordinator', 'organizer', 'admin', 'participant'], default: 'participant'
accountId: ObjectId, // ref: 'Account'
eventId: ObjectId, // ref: 'Event'
createdAt: Date, // Default: Date.now
timestamps: true // createdAt, updatedAt
}- Cafts can have parent-child relationships (comments and replies) via
parentCaft - Stances are linked to Cafts via
parentCaftId - Cafts can reference other Cafts that contain stances via
stanceCaftId
- Account β Caft (one-to-many): Users can create multiple Cafts
- Account β Stance (one-to-many): Users can create multiple Stances
- Caft β Stance (one-to-many): Cafts can have multiple Stances via
parentCaftId - Caft β Caft (self-referencing): Parent-child Caft relationships via
parentCaft - Caft β Caft (stance reference): Cafts can reference stance-containing Cafts via
stanceCaftId
- GET /me - Get current user profile (requires authentication)
- POST /signup - Register new account
- POST /login - User login
- POST /logout - Logout from current device (requires authentication)
- POST /logout_all - Logout from all devices (requires owner authentication)
- DELETE /remove_account - Delete account (requires owner authentication)
- PATCH /edit/email - Update email address (requires refresh authentication)
- PATCH /edit/phone - Update phone number (requires refresh authentication)
- PATCH /edit/password - Update password (requires owner authentication)
- PATCH /edit/profile - Update profile information (requires authentication)
- POST /refresh_access_token - Refresh access token (requires refresh authentication)
- POST / - Create new Caft document (requires authentication)
- GET /:id - Get a specific Caft by ID
- GET /child/:p_id - Get child Cafts (comments) for a specific parent Caft
- PATCH /:id - Update a Caft (requires authentication, owner only)
- DELETE /:id - Delete a Caft (requires authentication, owner only)
- accessAuth - Validates access token for protected routes
- ownerAuth - Validates owner authentication for sensitive operations
- refreshAuth - Validates refresh token for token refresh operations
- sessionId - Creates session ID for new user sessions
- Email validation for email fields
- Phone number validation for phone fields
- Password length validation (minimum 8 characters)
- Profile field validation with appropriate constraints
- Gender enum validation
- Age validation (minimum 1)
- Account: username, email, phone (unique indexes)
- Caft: accountId, parentCaft, eventId (indexed for efficient queries)
- Stance: userId, parentCaftId (indexed for efficient queries)
- Media: owner, type, createdAt (indexed for efficient queries)
- Password hashing and validation
- JWT token-based authentication
- Session management
- Input validation and sanitization
- Role-based access control