Skip to content

Soham192/notesharing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TextApp Backend (Phase 1)

Setup

  1. Create .env from .env.example.
  2. Install dependencies.
  3. Run the server.

Scripts

  • npm run dev
  • npm start

Endpoints

  • GET /health
  • GET /test
  • POST /auth/login (body: { "username": "alice" })
  • GET /auth/me (header: x-user-id: <id>)

Phase 2: Data Model (MongoDB)

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: usernameNormalized unique.
  • 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 on title + 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 noteShares avoids duplication while enabling many-to-many sharing.

Notes

  • Authentication is intentionally simple for Phase 1.
  • MongoDB is required and configured via MONGODB_URI and MONGODB_DB.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published