A powerful backend API for managing and sharing your personal knowledge base. Save, organize, and selectively share your content collection with others through unique shareable links.
Secondbrain is a content management platform that allows users to create their own personal "second brain" - a curated collection of links, articles, and resources. Users can organize their content privately and optionally share their entire collection with others via unique, generated share links.
- User Authentication: Secure signup and signin with JWT-based authentication
- Password Security: Bcrypt password hashing for enhanced security
- Content Management: Create, read, and delete personal content items
- Shareable Brain: Generate unique links to share your entire content collection publicly
- Access Control: Middleware-protected routes ensure data privacy
- Input Validation: Zod schema validation for robust data integrity
- Runtime: Node.js
- Language: TypeScript
- Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: JSON Web Tokens (JWT)
- Password Hashing: bcrypt
- Validation: Zod
POST /api/v1/signup
Content-Type: application/json
{
"username": "string (3-55 chars)",
"password": "string (5-25 chars)"
}POST /api/v1/signin
Content-Type: application/json
{
"username": "string",
"password": "string"
}Response: Returns JWT token for authenticated requests
POST /api/v1/content
Authorization: Bearer <token>
Content-Type: application/json
{
"link": "string",
"type": "string",
"title": "string"
}GET /api/v1/content
Authorization: Bearer <token>Response: Returns all content items with populated user information
DELETE /api/v1/content
Authorization: Bearer <token>
Content-Type: application/json
{
"contentId": "string"
}POST /api/v1/brain/share
Authorization: Bearer <token>
Content-Type: application/json
{
"share": true/false
}Response: Returns unique hash for sharing (if share=true)
GET /api/v1/brain/:shareLinkResponse: Returns username and all content from the shared brain
- Clone the repository
git clone https://github.com/agananya03/Secondbrain.git
cd Secondbrain- Install dependencies
npm install- Set up environment variables (create a
.envfile)
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
PORT=3000- Build TypeScript
npm run build- Start the server
npm startSecondbrain/
├── src/
│ ├── index.ts # Main application file with routes
│ ├── db.ts # Database models and schemas
│ ├── middleware.ts # Authentication middleware
│ └── utils.ts # Utility functions (hash generation)
├── package.json
├── tsconfig.json
└── README.md
- User: Stores user credentials and authentication data
- Content: Stores user's saved content items (links, titles, types, tags)
- Link: Manages shareable brain links with unique hashes
- JWT-based authentication for secure API access
- bcrypt password hashing (salt rounds: 5)
- Middleware protection on sensitive routes
- Input validation using Zod schemas
Built with ❤️ using TypeScript and Express.js