- Create
.envfrom.env.example. - Install dependencies.
- Run the server.
npm run devnpm start
GET /healthGET /testPOST /auth/login(body:{ "username": "alice" })GET /auth/me(header:x-user-id: <id>)
Collections and relationships:
- Users: one user has many sections, notes, messages, and note shares.
- Sections: belongs to a user; contains many notes.
- Notes: belongs to a user and a section; may reference a source message; can be shared.
- Messages: belongs to a user and (future) conversation.
- Note shares: grants another user access to a note with a permission level.
Indexes (implemented in src/db/mongo.js):
- Users:
usernameNormalizedunique. - Sections:
{ userId, name }unique;{ userId, updatedAt }for listing. - Messages:
{ conversationId, createdAt }and{ userId, createdAt }for fast fetch. - Notes:
{ sectionId, updatedAt },{ userId, updatedAt }, and text index ontitle+content. - Note shares:
{ noteId, userId }unique and{ userId, createdAt }.
Why this scales:
- Partitioning by user/section keeps reads scoped and fast as data grows.
- Compound indexes align with common query patterns (by owner, by section, by time).
- Text index supports search without scanning full collections.
- Separate
noteSharesavoids duplication while enabling many-to-many sharing.
- Authentication is intentionally simple for Phase 1.
- MongoDB is required and configured via
MONGODB_URIandMONGODB_DB.