A sophisticated personal knowledge management system built with Node.js, Express, TypeScript, and MongoDB. This system allows users to store, organize, and interact with various types of content (articles, tweets, YouTube videos) using AI-powered features.
- Multiple Auth Methods:
- JWT-based authentication
- Google OAuth integration
- Session-based authentication
- Secure password hashing using bcrypt
- Protected Routes: Middleware-based route protection
- Cookie-based Sessions: Secure session management
- Multi-Content Support:
- Articles with metadata extraction
- Twitter posts
- YouTube videos
- Document links
- AI-Powered Features:
- Content summarization using LLaMA2
- Smart content analysis
- URL metadata extraction
- Tag Management System:
- Create and manage custom tags
- Tag-based content organization
- Tag filtering and search
- Content Sharing:
- Share multiple items
- Custom share messages
- Time-based share expiry
- Share count tracking
- User Profiles:
- Profile customization
- Bio and profile picture
- Saved items management
- Learning Progress:
- Track reading/watching progress
- Interest management
- AI-powered recommendations
src/
βββ config/ # Configuration setup
β βββ connection.ts # Database connection
β βββ openai.config.ts # AI configuration
β βββ passport.ts # Auth configuration
βββ controllers/ # Request handlers
β βββ ai.controller.ts
β βββ auth.controllers.ts
β βββ savedItems.controller.ts
β βββ shared.controller.ts
β βββ tag.controller.ts
βββ middlewares/ # Custom middlewares
β βββ auth.middlewares.ts
βββ models/ # Database schemas
β βββ db.ts # MongoDB models
βββ routes/ # API routes
β βββ ai.routes.ts
β βββ auth.routes.ts
β βββ savedItems.routes.ts
β βββ shared.routes.ts
β βββ tag.routes.ts
βββ services/ # Business logic
βββ utils/ # Helper functions
βββ validations/ # Input validation
βββ app.ts # Express app setup
βββ server.ts # Server entry point
interface User {
name: string
email: string
password?: string
authprovider: "email" | "googleId"
profilePicture: string
bio?: string
savedItems: Types.ObjectId[]
createdAt: Date
updatedAt: Date
}interface SavedItems {
user: Types.ObjectId
title: string
url: string
description: string
tags: string[]
folder?: string
aiSummary?: string
sharedCount: number
createdAt: Date
updateAt: Date
}interface SharedItems {
User: Types.ObjectId
savedItems: Types.ObjectId[]
shareId: string
message?: string
createdAt: Date
expiresAt?: Date
}POST /api/auth/signup- User registrationPOST /api/auth/signin- User loginPOST /api/auth/logout- User logoutGET /api/auth/google- Google OAuth loginGET /api/auth/google/callback- Google OAuth callbackGET /api/auth/me- Get current user
POST /items/addItem- Save new contentGET /items/getItem- Get saved itemsPUT /items/updateItem/:id- Update saved itemDELETE /items/deleteItem/:id- Delete saved item
POST /tags/addTag- Create new tagGET /tags/getTags- Get all tagsDELETE /tags/deleteTag/:name- Delete tag
GET /ai/getSummary/:id- Get AI summary of content
POST /share/shareItems- Share multiple items
- Clone the repository
git clone <repository-url>
cd second-brain- Install dependencies
npm install- Environment Setup Create a .env file with:
PORT=5000
URL=<mongodb-connection-url>
JWT_SECRET=<your-jwt-secret>
GOOGLE_CLIENT_ID=<your-google-client-id>
GOOGLE_CLIENT_SECRET=<your-google-client-secret>
CLIENT_URL=http://localhost:3000- Start Development Server
npm run dev
# or with auto-reload
npm run dev:watch- Build for Production
npm run build
npm startnpm run build # Build TypeScript files
npm run start # Start production server
npm run dev # Start development server
npm run dev:watch # Start development server with auto-reload
npm run lint # Run ESLint
npm run lint:fix # Fix ESLint issues
npm run format # Format code with Prettier
npm run clean # Clean build directory-
Authentication Security:
- JWT token encryption
- Secure password hashing
- HTTP-only cookies
- Session management
-
Request Security:
- CORS configuration
- Input validation using Zod
- MongoDB injection prevention
- Request sanitization
-
Data Protection:
- Encrypted user data
- Secure cookie handling
- Protected routes middleware
- Runtime: Node.js
- Framework: Express.js
- Language: TypeScript
- Database: MongoDB with Mongoose
- Authentication: JWT, Passport.js
- Validation: Zod
- AI Integration: LLaMA2
- Other Tools:
- Bcrypt for password hashing
- Cheerio for web scraping
- Axios for HTTP requests
- CORS for cross-origin requests
- Helmet for security headers
PORT=5000 # Server port
URL= # MongoDB connection URL
JWT_SECRET= # JWT secret key
GEN_SALT= # Password hashing salt rounds
GOOGLE_CLIENT_ID= # Google OAuth client ID
GOOGLE_CLIENT_SECRET= # Google OAuth client secret
CLIENT_URL= # Frontend application URL- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ using Node.js, Express, TypeScript, and MongoDB