Second Brain API is a backend service for managing and querying a personal content repository. It supports user authentication, content management, and content querying using embeddings for personalized searches.
- User Authentication: Sign up, sign in, and secure access using JWT.
- Content Management: Add, view, delete, and tag content with associated links and metadata.
- Embeddings and Search: Leverages embeddings for advanced querying.
- Shareable Links: Create and manage shareable links for public content access.
- Robust Validation: Ensures input data integrity using Zod schema validation.
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose
- Authentication: JWT
- Validation: Zod
- Embedding Queries: Pinecone API
- Endpoint:
POST /api/v1/signup
- Description: Creates a new user.
- Request Body:
{ "username": "<username>", "password": "<password>" }
- Endpoint:
POST /api/v1/signin
- Description: Authenticates a user and returns a JWT.
- Request Body:
{ "username": "<username>", "password": "<password>" }
- Endpoint:
POST /api/v1/content
- Middleware: Requires authentication (
userMiddleware
). - Request Body:
{ "type": "<content_type>", "link": "<content_link>", "title": "<content_title>", "tags": ["<tag1>", "<tag2>"] }
- Endpoint:
GET /api/v1/content
- Middleware: Requires authentication (
userMiddleware
). - Description: Retrieves all content for the authenticated user.
- Endpoint:
DELETE /api/v1/content
- Middleware: Requires authentication (
userMiddleware
). - Request Body:
{ "contentId": "<content_id>" }
- Endpoint:
POST /api/v1/brain/share
- Middleware: Requires authentication (
userMiddleware
). - Request Body:
{ "status": "boolean" }
- Endpoint:
GET /api/v1/brain/:shareLink
- Middleware: Requires authentication (
userMiddleware
).
- Endpoint:
POST /api/v1/brain/ask
- Middleware: Requires authentication (
userMiddleware
). - Request Body:
{ "query": "<search_query>" }
- Node.js: v18+
- MongoDB: v5+
- Start the server:
npm start
- Run in development mode:
npm run dev