Join the new era of community-driven discussions. CacheUpp brings you the best of social media and forums — all in one place.
- User Authentication & Authorization: Secure sign-up/sign-in with email/password and Google OAuth, including OTP verification for email and password resets. Robust role-based access for regular users and administrators.
- Personalized User Profiles: Users can customize their profiles with a name, username, bio, and profile picture.
- Friendship System: Send, accept, reject, and cancel friend requests. View friend lists and discover mutual friends.
- Real-time Messaging: Engage in one-on-one private chats with friends, featuring real-time message exchange via WebSockets and image sharing.
- Dynamic Post Feed: Create and interact with posts containing text and images. Features include liking, commenting, saving, and reporting. The feed supports infinite scrolling.
- Community Forums: Participate in a structured forum environment with dedicated sections for various topics.
- Forum Hierarchy: Create and navigate through Forums, Threads, Posts, and Comments.
- Engagement: Like/dislike posts and comments, and contribute to discussions.
- Thread Watching: Subscribe to threads to receive real-time notifications for new posts and comments.
- Reporting System: Users can report inappropriate content across posts, comments, and threads.
- Semantic Search: A powerful search functionality for forums that leverages vector embeddings to provide semantically relevant results across forum titles, descriptions, threads, posts, and comments.
- Admin Dashboard: A dedicated interface for administrators to manage users, posts, comments, and forum requests. Monitor user activity, page views, and session durations.
- Image Optimization: Images uploaded by users are processed (converted to WebP) and stored efficiently using Cloudinary.
- Responsive UI & Dark Mode: A modern, responsive user interface designed with Tailwind CSS and Shadcn UI, supporting both light and dark themes.
- Scheduled Data Cleanup: Automated tasks to periodically purge soft-deleted data from the database.
Frontend:
- React: A JavaScript library for building user interfaces.
- TypeScript: A typed superset of JavaScript that compiles to plain JavaScript.
- Vite: A fast build tool that provides a leaner and faster development experience for modern web projects.
- Tailwind CSS: A utility-first CSS framework for rapidly styling applications.
- Shadcn UI: A collection of reusable components built using Radix UI and Tailwind CSS.
- Zustand: A small, fast, and scalable bear-necessities state-management solution.
- React Router DOM: Declarative routing for React.js.
- Framer Motion: A production-ready motion library for React.
Backend:
- Node.js: A JavaScript runtime built on Chrome's V8 JavaScript engine.
- Express.js: A fast, unopinionated, minimalist web framework for Node.js.
- TypeScript: Enhances code quality and maintainability.
- MongoDB: A NoSQL database for flexible data storage, managed with Mongoose.
- PostgreSQL: A powerful, open-source relational database, extended with
pgvectorfor vector embeddings, managed with Prisma. - Prisma: A next-generation ORM for Node.js and TypeScript, used to interact with PostgreSQL.
- Redis: Used for session storage to enhance scalability.
- JSON Web Tokens (JWT): For secure, stateless authentication.
- Bcrypt: For hashing and salting passwords.
- WebSockets (
ws): For real-time communication in chat and notifications. - Cloudinary: Cloud-based image and video management.
- Sharp: High-performance Node.js image processing.
- Hugging Face Transformers (
@huggingface/transformers): For generating text vector embeddings for semantic search. - Zod: TypeScript-first schema declaration and validation library.
- Nodemailer: Module for sending emails.
- PM2: A production process manager for Node.js applications.
- Axios: Promise-based HTTP client.
- Dotenv: Loads environment variables from a
.envfile.
Databases:
- MongoDB: Primary database for most application data (users, posts, messages, forum metadata).
- PostgreSQL with
pgvectorextension: Used specifically for storing and querying vector embeddings for the semantic search functionality.
Development & Deployment:
- Docker: For containerization of both frontend and backend services.
- Git: Version control.
To set up and run this project locally, follow these steps:
- Node.js (v20 or higher)
- npm (v10 or higher)
- MongoDB instance (local or cloud-hosted)
- PostgreSQL instance (local or cloud-hosted)
- Docker (optional, for containerized setup)
- Cloudinary account
- Hugging Face account (for model download, though pre-packaged)
- Google OAuth credentials
- Email service credentials (e.g., Gmail)
- Clone the repository:
git clone https://github.com/michael-020/CacheUp.git cd CacheUp - Navigate to the Backend directory:
cd Backend - Install dependencies:
npm install
- Configure environment variables:
Create a
.envfile in theBackenddirectory based on.env.example:MONGO_URL=your_mongodb_connection_string DATABASE_URL="postgresql://user:password@host:port/database?schema=public" # PostgreSQL connection string JWT_SECRET=a_very_secret_jwt_key SESSION_SECRET=another_very_secret_session_key CREATE_ADMIN_PASS=a_strong_password_for_admin_creation EMAIL_USER=your_email@gmail.com EMAIL_PASS=your_email_app_password # Or regular password if less secure CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret BACKEND_URL=http://localhost:3000 # Or your deployed backend URL FRONTEND_URL=http://localhost:5173 # Or your deployed frontend URL - Prisma Setup & Database Migration (PostgreSQL):
Ensure
pgvectorextension is enabled in your PostgreSQL database.npx prisma migrate deploy npx prisma generate
- Download AI Model (for vectorization):
npm run download:model
- Seed PostgreSQL Database (for initial vector data):
npm run seed:pg
- Build the backend:
npm run build
- Start the backend in development mode (with Nodemon):
Or for production build and start:
npm run nodemon
npm run prod:build npm start
- Navigate to the Web directory:
cd ../web - Install dependencies:
npm install
- Configure environment variables:
Create a
.envfile in thewebdirectory based on.env.example:VITE_API_URL=http://localhost:3000 # Must match your backend URL - Start the frontend development server:
The frontend will be accessible at
npm run dev
http://localhost:5173(or another port if 5173 is in use).
Once both the backend and frontend are running:
- Access the application: Open your web browser and navigate to
http://localhost:5173. - Sign Up/Sign In: Register a new account or log in using existing credentials or Google OAuth.
- Explore the Feed: View posts from other users, like, comment, and save content. Create your own posts with text and images.
- Connect with Friends: Send and accept friend requests. Engage in real-time private messages.
- Participate in Forums: Browse various forums, join discussions in threads, create new content, and utilize the semantic search to find relevant information.
- Admin Panel: If you are an administrator, navigate to
/admin/signinand log in with your admin credentials to access the administrative features.
CacheUp is a monorepo project structured into Backend and Web applications, facilitating a comprehensive social media and forum experience.
The Backend is a Node.js application built with Express.js and TypeScript. It serves as the API for the frontend and handles all data processing, authentication, and business logic.
- API Endpoints: Routes defined in
src/routesmanage user authentication, profile management, friend interactions, post operations, forum content, and real-time messaging. - Authentication & Session Management:
- Users can sign up/in using local credentials or Google OAuth (configured in
src/config/oauth.ts). - JWT (
jsonwebtoken) is used for secure session tokens. - Bcrypt ensures passwords are securely hashed.
- Sessions are stored in MongoDB using
connect-mongofor persistent user sessions. - Email verification and password reset functionalities are handled via Nodemailer (
src/emailService.ts) which sends OTPs.
- Users can sign up/in using local credentials or Google OAuth (configured in
- Database Layer:
- MongoDB: Utilized for storing the primary application data, including user profiles (
userModel), posts (postModel), chat messages (chatModel), and forum content metadata (forumModel,threadForumModel,postForumModel,commentForumModel). Mongoose acts as the ODM. - PostgreSQL with
pgvector: A relational database is employed for storing vector embeddings. Theprisma/schema.prismadefines the schema for vector storage, and Prisma is used as the ORM to interact with this database.
- MongoDB: Utilized for storing the primary application data, including user profiles (
- Vector Embeddings & Semantic Search:
- The application leverages Hugging Face Transformers (
@huggingface/transformers) to generate high-dimensional vector embeddings for text content (forum titles, descriptions, posts, comments). The model is downloaded and managed bysrc/downloadModel.tsandsrc/lib/vectorizeText.ts. - These vectors are stored in PostgreSQL using the
pgvectorextension (src/lib/vectorQueries.ts). - The
searchForumHandler.tsuses these vectors to perform semantic similarity searches, allowing users to find relevant content even if exact keywords aren't present. src/dbSync/seedPg.tsensures that MongoDB data is synchronized with PostgreSQL for vector processing, either by creating new vector entries or updating existing ones.
- The application leverages Hugging Face Transformers (
- Real-time Communication:
- WebSockets (
ws) are implemented insrc/websockets/index.tsto enable real-time features. - This includes instant messaging between users and live updates for online status and thread notifications.
- WebSockets (
- File Handling:
- Multer (
src/middlewares/upload.ts) processes image uploads from the frontend. - Sharp (
src/lib/imageReEncode.ts) is used to convert uploaded images to the WebP format for optimal performance. - Cloudinary (
src/lib/cloudinary.ts) stores all processed images in the cloud.
- Multer (
- Monitoring & Analytics:
src/services/loggingService.tsandsrc/services/timeTrackingService.tsrecord user activities like signups, logins, logouts, and page views, along with time spent on each page.- This data feeds into the Admin Dashboard for user statistics and activity monitoring.
- Scheduled Tasks:
src/lib/deleteCronJob.tsusesnode-cronto periodically clean up soft-deleted user data, posts, forums, and comments from MongoDB.
The Web application is a Single Page Application (SPA) built with React and TypeScript, powered by Vite for a fast development experience.
- User Interface: Styled with Tailwind CSS and augmented with pre-built, accessible components from Shadcn UI.
- State Management: Zustand is used for global state management, handling authentication (
AuthStore), posts (PostStore), real-time chat (chatStore), friend relations (FriendsStore), forum data (ForumStore), and UI concerns like theme (ThemeStore). - Routing: React Router DOM (
src/App.tsx) manages client-side navigation, providing a seamless user experience. - API Interaction: Axios (
src/lib/axios.ts) is the HTTP client for communicating with the backend API. - User Feedback:
react-hot-toastandsonnerare used for displaying ephemeral notifications, with a custom toast component for incoming chat messages. - Animations: Framer Motion (
src/lib/routeAnimation.ts) is integrated for smooth UI transitions and animations. - Theme Management: A global theme store (
useThemeStore.ts) allows users to toggle between light and dark modes, persisting their preference locally. - Optimizations: Techniques like debouncing (
useDebounce.ts) are used for search inputs to reduce API calls, and lazy loading of components contributes to performance.