├── public ├── logo.png └── screenshot.jpeg ├── src ├── app │ ├── @modal │ │ ├── default.tsx │ │ └── (.)settings │ │ │ └── page.tsx │ ├── favicon.ico │ ├── settings │ │ └── page.tsx │ ├── layout.tsx │ ├── api │ │ └── chat │ │ │ └── route.ts │ ├── (journal) │ │ ├── use-journal-updates.tsx │ │ ├── page.tsx │ │ └── use-journals.tsx │ ├── globals.css │ ├── chat │ │ ├── page.tsx │ │ └── [id] │ │ │ └── page.tsx │ ├── knowledge │ │ ├── page.tsx │ │ └── knowledge-dialog.tsx │ └── notes │ │ └── [id] │ │ └── page.tsx ├── lib │ ├── db │ │ ├── schema │ │ │ ├── chat.ts │ │ │ ├── embedding.ts │ │ │ ├── chat-message.ts │ │ │ └── note.ts │ │ └── index.ts │ ├── utils.ts │ ├── fonts.ts │ ├── ai │ │ ├── provder.ts │ │ └── embedding.ts │ ├── settings.ts │ └── chat.ts ├── instrumentation.ts ├── components │ ├── ui │ │ ├── skeleton.tsx │ │ ├── collapsible.tsx │ │ ├── textarea.tsx │ │ ├── label.tsx │ │ ├── input.tsx │ │ ├── separator.tsx │ │ ├── sonner.tsx │ │ ├── badge.tsx │ │ ├── switch.tsx │ │ ├── tooltip.tsx │ │ ├── button.tsx │ │ ├── dialog.tsx │ │ ├── sheet.tsx │ │ ├── form.tsx │ │ ├── alert-dialog.tsx │ │ ├── context-menu.tsx │ │ └── sidebar.tsx │ ├── form-button.tsx │ ├── icons.tsx │ ├── logo.tsx │ ├── chat │ │ ├── messages.tsx │ │ ├── skeletons.tsx │ │ ├── markdown.tsx │ │ ├── message.tsx │ │ ├── chat-input.tsx │ │ └── chat-container.tsx │ ├── editor.tsx │ ├── settings │ │ ├── embeddings-settings.tsx │ │ ├── provider-settings.tsx │ │ └── settings-modal.tsx │ └── app-sidebar.tsx ├── hooks │ ├── use-mobile.tsx │ └── use-scroll-to-bottom.ts ├── config │ └── site.ts └── contexts │ └── chat-store.tsx ├── next.config.ts ├── .prettierrc ├── postcss.config.mjs ├── eslint.config.mjs ├── .dockerignore ├── components.json ├── .gitignore ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── tsconfig.json ├── env.ts ├── Dockerfile ├── package.json ├── tailwind.config.ts ├── README.cn.md └── README.md /public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/celerforge-dev/freenote/HEAD/public/logo.png -------------------------------------------------------------------------------- /src/app/@modal/default.tsx: -------------------------------------------------------------------------------- 1 | export default function Default() { 2 | return null; 3 | } 4 | -------------------------------------------------------------------------------- /src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/celerforge-dev/freenote/HEAD/src/app/favicon.ico -------------------------------------------------------------------------------- /public/screenshot.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/celerforge-dev/freenote/HEAD/public/screenshot.jpeg -------------------------------------------------------------------------------- /src/lib/db/schema/chat.ts: -------------------------------------------------------------------------------- 1 | export type Chat = { 2 | id: string; 3 | title?: string; 4 | createdAt: Date; 5 | updatedAt: Date | null; 6 | }; 7 | -------------------------------------------------------------------------------- /src/lib/db/schema/embedding.ts: -------------------------------------------------------------------------------- 1 | export type Embedding = { 2 | id: number; 3 | noteId: number; 4 | content: string; 5 | embedding: number[]; 6 | }; 7 | -------------------------------------------------------------------------------- /next.config.ts: -------------------------------------------------------------------------------- 1 | import type { NextConfig } from "next"; 2 | 3 | const nextConfig: NextConfig = { 4 | output: "standalone", 5 | }; 6 | 7 | export default nextConfig; 8 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "prettier-plugin-organize-imports", 4 | "@trivago/prettier-plugin-sort-imports", 5 | "prettier-plugin-tailwindcss" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /postcss.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('postcss-load-config').Config} */ 2 | const config = { 3 | plugins: { 4 | tailwindcss: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /src/lib/db/schema/chat-message.ts: -------------------------------------------------------------------------------- 1 | export type ChatMessage = { 2 | id: string; 3 | chatId: string; 4 | role: "system" | "user" | "assistant" | "data"; 5 | content: string; 6 | createdAt: Date; 7 | }; 8 | -------------------------------------------------------------------------------- /src/instrumentation.ts: -------------------------------------------------------------------------------- 1 | // import { registerOTel } from "@vercel/otel"; 2 | // import { LangfuseExporter } from "langfuse-vercel"; 3 | 4 | export function register() { 5 | // registerOTel({ 6 | // serviceName: "freenote", 7 | // traceExporter: new LangfuseExporter(), 8 | // }); 9 | } 10 | -------------------------------------------------------------------------------- /src/lib/db/schema/note.ts: -------------------------------------------------------------------------------- 1 | export enum NoteType { 2 | Journal = "journal", 3 | Knowledge = "knowledge", 4 | } 5 | 6 | export type Note = { 7 | id: number; 8 | title: string; 9 | type: NoteType; 10 | content: string; 11 | createdAt: Date; 12 | updatedAt: Date | null; 13 | embeddingUpdatedAt: Date | null; 14 | }; 15 | -------------------------------------------------------------------------------- /src/components/ui/skeleton.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from "@/lib/utils" 2 | 3 | function Skeleton({ 4 | className, 5 | ...props 6 | }: React.HTMLAttributes) { 7 | return ( 8 |
12 | ) 13 | } 14 | 15 | export { Skeleton } 16 | -------------------------------------------------------------------------------- /src/components/ui/collapsible.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as CollapsiblePrimitive from "@radix-ui/react-collapsible" 4 | 5 | const Collapsible = CollapsiblePrimitive.Root 6 | 7 | const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger 8 | 9 | const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent 10 | 11 | export { Collapsible, CollapsibleTrigger, CollapsibleContent } 12 | -------------------------------------------------------------------------------- /src/app/@modal/(.)settings/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import SettingsModal from "@/components/settings/settings-modal"; 4 | import { useRouter } from "next/navigation"; 5 | 6 | export default function SettingsInterceptedPage() { 7 | const router = useRouter(); 8 | 9 | const handleClose = () => { 10 | router.back(); 11 | }; 12 | 13 | return ; 14 | } 15 | -------------------------------------------------------------------------------- /src/app/settings/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import SettingsModal from "@/components/settings/settings-modal"; 4 | import { useRouter } from "next/navigation"; 5 | 6 | export default function SettingsPage() { 7 | const router = useRouter(); 8 | 9 | const handleClose = () => { 10 | router.push("/", { scroll: false }); 11 | }; 12 | 13 | return ; 14 | } 15 | -------------------------------------------------------------------------------- /src/lib/utils.ts: -------------------------------------------------------------------------------- 1 | import { clsx, type ClassValue } from "clsx"; 2 | import { twMerge } from "tailwind-merge"; 3 | 4 | export function cn(...inputs: ClassValue[]) { 5 | return twMerge(clsx(inputs)); 6 | } 7 | 8 | export function objEnum(enumValues: readonly T[]) { 9 | const enumObject = {} as { [K in T]: K }; 10 | for (const enumValue of enumValues) { 11 | enumObject[enumValue] = enumValue; 12 | } 13 | return enumObject; 14 | } 15 | -------------------------------------------------------------------------------- /src/lib/fonts.ts: -------------------------------------------------------------------------------- 1 | import { 2 | JetBrains_Mono as FontMono, 3 | Inter as FontSans, 4 | Outfit, 5 | } from "next/font/google"; 6 | 7 | export const fontSans = FontSans({ 8 | subsets: ["latin"], 9 | variable: "--font-sans", 10 | }); 11 | 12 | export const fontMono = FontMono({ 13 | subsets: ["latin"], 14 | variable: "--font-mono", 15 | }); 16 | 17 | export const fontOutfit = Outfit({ 18 | subsets: ["latin"], 19 | variable: "--font-outfit", 20 | }); 21 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { dirname } from "path"; 2 | import { fileURLToPath } from "url"; 3 | import { FlatCompat } from "@eslint/eslintrc"; 4 | 5 | const __filename = fileURLToPath(import.meta.url); 6 | const __dirname = dirname(__filename); 7 | 8 | const compat = new FlatCompat({ 9 | baseDirectory: __dirname, 10 | }); 11 | 12 | const eslintConfig = [ 13 | ...compat.extends("next/core-web-vitals", "next/typescript"), 14 | ]; 15 | 16 | export default eslintConfig; 17 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | node_modules 3 | .pnp 4 | .pnp.js 5 | 6 | # Testing 7 | coverage 8 | 9 | # Next.js 10 | .next 11 | out 12 | 13 | # Production 14 | build 15 | 16 | # Misc 17 | .DS_Store 18 | *.pem 19 | 20 | # Debug 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | .pnpm-debug.log* 25 | 26 | # Local env files 27 | .env*.local 28 | .env 29 | 30 | # Vercel 31 | .vercel 32 | 33 | # TypeScript 34 | *.tsbuildinfo 35 | next-env.d.ts 36 | 37 | # Git 38 | .git 39 | .github -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.ts", 8 | "css": "src/app/globals.css", 9 | "baseColor": "zinc", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils", 16 | "ui": "@/components/ui", 17 | "lib": "@/lib", 18 | "hooks": "@/hooks" 19 | }, 20 | "iconLibrary": "lucide" 21 | } -------------------------------------------------------------------------------- /src/lib/ai/provder.ts: -------------------------------------------------------------------------------- 1 | import { SETTINGS } from "@/lib/settings"; 2 | import { createOpenAI } from "@ai-sdk/openai"; 3 | import { getCookies } from "next-client-cookies/server"; 4 | 5 | export const getProvider = async () => { 6 | const cookies = await getCookies(); 7 | const baseUrl = cookies.get(SETTINGS.ai.provider.baseUrl); 8 | const apiKey = cookies.get(SETTINGS.ai.provider.apiKey); 9 | if (!baseUrl || !apiKey) { 10 | return null; 11 | } 12 | const provider = createOpenAI({ 13 | baseURL: baseUrl, 14 | apiKey: apiKey, 15 | }); 16 | return provider; 17 | }; 18 | -------------------------------------------------------------------------------- /src/lib/settings.ts: -------------------------------------------------------------------------------- 1 | export const SETTINGS = { 2 | ai: { 3 | provider: { 4 | baseUrl: "settings.ai.provider.baseUrl", 5 | apiKey: "settings.ai.provider.apiKey", 6 | }, 7 | embeddings: { 8 | autoUpdate: "settings.ai.embeddings.autoUpdate", 9 | }, 10 | }, 11 | } as const; 12 | 13 | // Type helper for getting nested values 14 | type SettingsValue = 15 | T extends Record 16 | ? { [K in keyof T]: SettingsValue } 17 | : string; 18 | 19 | // Inferred settings type 20 | export type Settings = SettingsValue; 21 | -------------------------------------------------------------------------------- /src/hooks/use-mobile.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | const MOBILE_BREAKPOINT = 768 4 | 5 | export function useIsMobile() { 6 | const [isMobile, setIsMobile] = React.useState(undefined) 7 | 8 | React.useEffect(() => { 9 | const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`) 10 | const onChange = () => { 11 | setIsMobile(window.innerWidth < MOBILE_BREAKPOINT) 12 | } 13 | mql.addEventListener("change", onChange) 14 | setIsMobile(window.innerWidth < MOBILE_BREAKPOINT) 15 | return () => mql.removeEventListener("change", onChange) 16 | }, []) 17 | 18 | return !!isMobile 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.* 7 | .yarn/* 8 | !.yarn/patches 9 | !.yarn/plugins 10 | !.yarn/releases 11 | !.yarn/versions 12 | 13 | # testing 14 | /coverage 15 | 16 | # next.js 17 | /.next/ 18 | /out/ 19 | 20 | # production 21 | /build 22 | 23 | # misc 24 | .DS_Store 25 | *.pem 26 | 27 | # debug 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | .pnpm-debug.log* 32 | 33 | # env files (can opt-in for committing if needed) 34 | .env* 35 | 36 | # vercel 37 | .vercel 38 | 39 | # typescript 40 | *.tsbuildinfo 41 | next-env.d.ts 42 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /src/components/ui/textarea.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { cn } from "@/lib/utils" 4 | 5 | const Textarea = React.forwardRef< 6 | HTMLTextAreaElement, 7 | React.ComponentProps<"textarea"> 8 | >(({ className, ...props }, ref) => { 9 | return ( 10 |