BrainCache is a personal "second brain" for the web. Instead of DM-ing yourself links on WhatsApp whenever you find a useful article, tweet, YouTube video, or resource, BrainCache gives you a dedicated place to save and revisit everything.
You can log in, add content with a title/link/description, browse it later in a dashboard, and share individual items via public links. In the future, a search feature will let you quickly find items you saved long ago.
- Save any useful URL (articles, tweets, videos, docs, etc.) with a title and optional description
- Authenticated dashboard showing all of your saved items
- Public share links for individual items (read-only views)
- Cookie + JWT–based authentication
- Planned: full-text search over saved content so you can retrieve old links by keywords
BrainCache is a full-stack TypeScript app:
- Backend – Node.js + Express + TypeScript + MongoDB (under
backend/) - Frontend – React + TypeScript + Vite (under
frontend/)
- Entry point:
backend/src/index.ts- Loads environment variables from
backend/envusingdotenv - Connects to MongoDB via
backend/src/db/index.ts - Boots the Express app from
backend/src/app.ts
- Loads environment variables from
- App wiring:
backend/src/app.ts- Configures CORS and JSON body parsing
- Attaches cookie parsing
- Mounts routers:
/api/v1/auth→ auth routes/api/v1/content→ content CRUD + sharing
- Models (Mongoose):
User– auth users, hashed passwords, JWT helpersContent– saved items (title, link, description, owner, share flags)Share– mapping fromContentto share IDs/URLs
- Controllers:
user.controller.ts– signup, login, logout, token managementcontent.controller.ts– add/update/delete/list content, generate/clear share links, resolve content by share ID
- Middleware:
auth.middleware.ts– verifies JWT access tokens (cookie orAuthorizationheader) and populatesreq.user
- Entry point:
frontend/src/main.tsx- Wraps the app in
AuthProvider(auth context) - Renders the router (
App.tsx) and global toast notifications
- Wraps the app in
- Routing:
frontend/src/App.tsx/login,/signup– auth pages; redirect to/dashboardif already logged in/dashboard– main authenticated dashboard (protected byPrivateRoute)/share/content/:shareId– public read-only view for a shared item/*– default route that sends unauthenticated users to login, and authenticated users to/dashboard
- State & auth:
frontend/src/context/AuthContext.tsx- Stores the current user in React state and
localStorage - Exposes a
useAuth()hook used throughout the app
- Stores the current user in React state and
- API layer:
frontend/src/services/http.ts- Shared Axios instance with
baseURLpointing at the deployed backend API - Sends cookies (
withCredentials: true) and attachesAuthorization: Bearer <token>fromlocalStorage
- Shared Axios instance with
- UI pages & components:
pages/Dashboard.tsx– fetches and renders saved content, wires up share/unshare/delete and the "Add Content" modalpages/Login.tsx&pages/Signup.tsx– handle auth flows against the backendpages/ShareContent.tsx– loads a shared item using its share ID and renders a public viewpages/LandingPage.tsx– marketing/landing experience usingNavbar+Hero
- Node.js and npm
- MongoDB instance (local or hosted)
git clone <your-repo-url>
cd BrainCacheIn backend/, create a file named env (no leading dot). At minimum, define:
MONGODB_URI=
DB_NAME=
ACCESS_TOKEN_SECRET=your-access-token-secret
ACCESS_TOKEN_EXPIRY=
REFRESH_TOKEN_SECRET=your-refresh-token-secret
REFRESH_TOKEN_EXPIRY=
CORS_ORIGIN=
PORT=8000Adjust values for your environment. For local development with the frontend at
http://localhost:5173, you may want to include that origin in CORS or changeCORS_ORIGINand the CORS setup inbackend/src/app.ts.
From the repo root:
cd backend
npm install
cd ../frontend
npm installFrom backend/:
npm run devThis compiles the TypeScript and starts the API server on PORT from your env file (default 8000).
From frontend/:
npm run devBy default Vite serves the app at http://localhost:5173.
Make sure the frontend is configured to talk to your backend URL in frontend/src/services/http.ts.
From backend/:
npm run dev– build TypeScript and start the servernpm run build– compile TypeScript todist/npm start– run the compiled server fromdist/index.js
From frontend/:
npm run dev– start Vite dev servernpm run build– type-check + production buildnpm run lint– run ESLintnpm run preview– preview the production build
Planned improvements include:
- Search across saved content by title, description, or link so you can quickly find items saved long ago
- Additional quality-of-life features around organizing and filtering saved items




