diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 695839d..aae7691 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,7 +22,8 @@ We welcome contributions! Here's how to get started: 5. Start development server: ```bash - pnpm run dev + pnpm run dev:web + pnpm run dev:backend # Not actually doing anything yet ``` ### Problems with tailwind during development @@ -30,10 +31,13 @@ We welcome contributions! Here's how to get started: If you encounter problems with tailwind during development, try the following: ```bash -rm -rf node_modules/ .next/ -rm -f pnpm-lock.yaml -pnpm install -pnpm run dev +pnpm clean +# or +pnpm fullclean + +pnpm i +pnpm run dev:web +pnpm run dev:backend ``` ## Reporting Issues @@ -52,7 +56,7 @@ pnpm run dev 4. Run tests (when available) and ensure linting passes: ```bash - pnpm run lint + pnpm lint check-types test ``` 5. Ensure that build passed and everything is working: @@ -68,9 +72,10 @@ pnpm run dev ## Code Style - Follow existing TypeScript patterns +- Most of types are setup in a way that you can use autocomplete - Use Prettier formatting - Add comments for complex logic -- Always use tailwind classes over custom CSS +- Always use tailwind classes over custom CSS, but you can use custom CSS for things that tailwind doesn't support - Use consistent naming conventions - Always include types - Use pnpm as the package manager diff --git a/README.md b/README.md index 799ebbf..3cedc97 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,13 @@ # NextWiki -![NextWiki Main Page](./assets/nextwiki-home.png) ![NextWiki Main Page Dark](./assets/nextwiki-home-dark.png) +

+ + Live Demo + +

+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) An open-source wiki system built with modern web technologies, inspired by WikiJS. NextWiki provides a flexible, extensible platform for creating and managing knowledge bases. @@ -10,43 +15,46 @@ An open-source wiki system built with modern web technologies, inspired by WikiJ ## 🚀 Features - **Modern Stack**: Built with Next.js 15, React 19, Drizzle ORM, tRPC, NextAuth, Tailwind CSS, Codemirror, Shadcn UI, and more -- **Version History**: Track changes (in progress) - **Markdown Support**: Write content using simple Markdown syntax - **Direct Image Upload**: Upload images directly with paste or drag and drop - **Syntax Highlighting**: Syntax highlighting for code blocks - **Page/Folder Moving Functionality**: Move/rename pages and folders to different locations - **Authentication**: Secure login with credentials or OAuth providers (only password login is implemented for now) - **Advanced Search**: Full-text and fuzzy search -- **Tags & Categories**: Organize your content effectively (in progress) +- **Tags & Categories**: Organize your content effectively +- **Asset Manager**: Upload, delete, and manage assets (images, videos, PDFs, etc.) +- **Permissions**: Group and granular permission based access control +- **Settings**: Centralized settings for the wiki, manageable by the admin ## 🛠️ Tech Stack -- **Framework**: [Next.js](https://nextjs.org) +- **Framework**: [Next.js](https://nextjs.org) (for the frontend and core features) +- **Backend**: Optional [NestJS](https://nestjs.com) on Fastify (for features like WebSockets, planned for Yjs integration) - **Database**: PostgreSQL with [Drizzle ORM](https://orm.drizzle.team) -- **API**: Type-safe APIs with [tRPC](https://trpc.io) +- **API**: Type-safe APIs with [tRPC](https://trpc.io) (primarily within Next.js) - **Authentication**: [NextAuth.js](https://next-auth.js.org) - **Search**: PostgreSQL full-text search with trigram similarity for fuzzy matching - **Styling**: Tailwind CSS -- **Deployment**: Compatible with Vercel, Netlify, or self-hosted +- **Monorepo Management**: Turborepo +- **Deployment**: Compatible with Vercel, Netlify, or self-hosted (NestJS backend requires a Node.js environment) + +*Note*: Most functionality resides within the Next.js application and can run on serverless platforms like Vercel. The NestJS backend is included to support optional self-hosted WebSocket functionality, anticipating future integration with Yjs for real-time collaboration, without relying on external providers. ## 🔮 Planned Features -- [ ] **Permissions**: Control who can view and edit content -- [ ] **Centralized settings**: Manage your wiki from a central settings page, with everything stored in the database - [ ] **S3 Asset Storage**: Store assets in S3 or somewhere else -- [ ] **Tags & Categories**: Organize your content effectively -- [ ] **Better version history**: Track changes and revert to previous versions -- [ ] **Real-time Collaboration**: Multiple users can edit pages simultaneously -- [ ] **Typo tolerance**: Fuzzy search with typo tolerance -- [ ] **PDF Upload**: Upload PDFs to the wiki -- [ ] **Video Upload**: Upload videos to the wiki -- [ ] **Audio Upload**: Upload audio to the wiki +- [ ] **Version history**: Track changes and revert to previous versions +- [ ] **Visual editor**: A visual editor for creating and editing pages +- [ ] **Real-time Collaboration**: Multiple users can edit pages simultaneously using Yjs +- [ ] **Better Settings**: Better settings, ability to manage authentication providers, etc. +- [ ] **Different theme support**: Ability to switch between different themes +- [ ] **Import/Export**: Ability to import and export pages from and to other wiki systems ## 📦 Getting Started ### Prerequisites -- Node.js 18+ (pnpm recommended) +- Node.js 18+ (pnpm required) - PostgreSQL database (or Neon serverless PostgreSQL) ### Installation @@ -67,24 +75,25 @@ An open-source wiki system built with modern web technologies, inspired by WikiJ 3. Copy the environment file and configure it: ```bash - cp .env.example .env.local + cp apps/web/.env.example apps/web/.env + cp packages/db/.env.example packages/db/.env ``` - Update the values in `.env.local` with your database and authentication settings. + Update the values in `.env` with your database and authentication settings. -4. Set up the database: +4. Set up the database with one of the following commands: ```bash - pnpm run db:setup # Create the database in docker + pnpm run db:setup # Create the database in docker and seed it with example data - pnpm run db:generate # Generate migrations - pnpm run db:migrate # Apply migrations + pnpm run db:docker # Just create the database in docker without seeding it ``` 5. Start the development server: ```bash - pnpm run dev + pnpm run dev:web + pnpm run dev:backend ``` 6. Open [http://localhost:3000](http://localhost:3000) in your browser to see the wiki. @@ -100,35 +109,39 @@ NextWiki includes a powerful search system with several capabilities: 1. Exact vector matching (highest relevance) 2. Title matching (high relevance) 3. Content matching (medium relevance) - 4. Similarity matching for typos (lower relevance) _(in progress)_ + 4. Similarity matching for typos (lower relevance) When a user clicks a search result, they'll be taken directly to the page with all instances of the search term highlighted, and the view will automatically scroll to the first match. ## Project Structure +This project uses a Turborepo monorepo structure: + ```text -├── drizzle/ # Database migrations -├── public/ # Static assets -├── src/ -│ ├── app/ # Next.js app router -│ ├── components/ # React components -│ │ ├── auth/ # Authentication components -│ │ ├── layout/ # Layout components -│ │ ├── ui/ # UI components -│ │ └── wiki/ # Wiki-specific components -│ ├── lib/ # Shared libraries -│ │ ├── db/ # Database connection and schema -│ │ ├── utils/ # Utility functions -│ │ ├── services/ # Database service functions (one layer above the drizzle layer) -│ │ └── trpc/ # tRPC routers and procedures -│ └── types/ # TypeScript type definitions -└── ... configuration files +├── apps/ +│ ├── backend/ # Optional NestJS backend (Fastify) +│ └── web/ # Next.js frontend application +├── packages/ +│ ├── auth/ # Authentication utilities (NextAuth) +│ ├── db/ # Drizzle ORM schema, migrations, and seeding +│ ├── eslint-config/ # Shared ESLint configuration +│ ├── logger/ # Shared logger configuration +│ ├── tailwind-config/ # Shared Tailwind CSS configuration +│ ├── types/ # Shared TypeScript types +│ ├── typescript-config/ # Shared TypeScript configuration +│ └── ui/ # Shared React UI components (Shadcn UI) +├── .github/ # GitHub Actions workflows +├── schema.dbml # Database schema ER diagram +├── assets/ # Static assets like images for README +├── docs/ # Project documentation +└── ... configuration files (pnpm, turbo, prettier, etc.) ``` ## Screenshots ![NextWiki Main Page](./assets/nextwiki-home.png) ![NextWiki Main Page Dark](./assets/nextwiki-home-dark.png) +![NextWiki Main Page Admin](./assets/nextwiki-home-admin.png) ![NextWiki Search](./assets/nextwiki-search.png) @@ -138,6 +151,9 @@ When a user clicks a search result, they'll be taken directly to the page with a ![NextWiki Browser](./assets/nextwiki-browser.png) ![NextWiki Move Page](./assets/nextwiki-move.png) +![NextWiki Admin Dashboard](./assets/nextwiki-admin-dashboard.png) +![NextWiki Settings](./assets/nextwiki-admin-settings.png) + ## 🤝 Contributing We welcome contributions! Please see our [CONTRIBUTING.md](./CONTRIBUTING.md) guide for details on how to get started. Even non-code contributions like documentation improvements, bug reports, and feature suggestions are appreciated! diff --git a/apps/backend/README.md b/apps/backend/README.md index d30c946..5bb74e2 100644 --- a/apps/backend/README.md +++ b/apps/backend/README.md @@ -1,98 +1,44 @@ -

- Nest Logo -

- -[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 -[circleci-url]: https://circleci.com/gh/nestjs/nest - -

A progressive Node.js framework for building efficient and scalable server-side applications.

-

-NPM Version -Package License -NPM Downloads -CircleCI -Discord -Backers on Open Collective -Sponsors on Open Collective - Donate us - Support us - Follow us on Twitter -

- - -## Description - -[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. - -## Project setup +# NextWiki - Backend Application -```bash -$ pnpm install -``` +This directory contains the optional NestJS (using Fastify) backend application for the NextWiki project. -## Compile and run the project - -```bash -# development -$ pnpm run start +Its primary purpose is to provide WebSocket support for features like real-time collaboration (planned Yjs integration) for users who prefer self-hosting this capability instead of relying on external providers. -# watch mode -$ pnpm run start:dev +**Note:** This backend is *not* required for the core functionality of NextWiki, which resides in the `apps/web` Next.js application. -# production mode -$ pnpm run start:prod -``` +For a complete overview of the project structure, features, and setup instructions, please refer to the [root README.md](../../README.md). -## Run tests +## Getting Started -```bash -# unit tests -$ pnpm run test +### Prerequisites -# e2e tests -$ pnpm run test:e2e +Ensure you have installed dependencies from the root of the monorepo: -# test coverage -$ pnpm run test:cov +```bash +# Run from the project root +pnpm install ``` -## Deployment - -When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information. +### Running the Development Server -If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps: +To run the development server for this specific application (with hot-reloading): ```bash -$ pnpm install -g @nestjs/mau -$ mau deploy +# Run from the project root +pnpm run dev:backend ``` -With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure. +### Other Commands -## Resources - -Check out a few resources that may come in handy when working with NestJS: - -- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework. -- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy). -- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/). -- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks. -- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com). -- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com). -- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs). -- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com). - -## Support - -Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). - -## Stay in touch +```bash +# Run from the project root -- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec) -- Website - [https://nestjs.com](https://nestjs.com/) -- Twitter - [@nestframework](https://twitter.com/nestframework) +# Compile for production +pnpm run build:backend -## License +# Start production build +pnpm run start:backend -Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE). +# Run tests (unit & e2e) +pnpm run test:backend +``` diff --git a/apps/web/.env.example b/apps/web/.env.example index 9a825f3..e797564 100644 --- a/apps/web/.env.example +++ b/apps/web/.env.example @@ -2,7 +2,6 @@ DATABASE_URL=postgresql://user:password@localhost:5432/nextwiki # API -NEXT_PUBLIC_API_URL=http://localhost:3000/api/trcp NEXT_PUBLIC_WS_URL= # NextAuth diff --git a/apps/web/README.md b/apps/web/README.md index a98bfa8..477d9bb 100644 --- a/apps/web/README.md +++ b/apps/web/README.md @@ -1,36 +1,25 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/create-next-app). +# NextWiki - Web Application + +This directory contains the main Next.js frontend and API application for the NextWiki project. + +For a complete overview of the project structure, features, and setup instructions, please refer to the [root README.md](../../README.md). ## Getting Started -First, run the development server: +To run the development server for this specific application: ```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev +pnpm run dev:web ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. +This command should typically be run from the **root directory** of the monorepo. -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load Inter, a custom Google Font. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! +You can start editing the page by modifying `src/app/page.tsx`. The page auto-updates as you edit the file. -## Deploy on Vercel +## Deployment -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. +The easiest way to deploy this Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. +Refer to the main [NextWiki README.md](../../README.md) for more details on deployment strategies, especially when including the optional backend. diff --git a/apps/web/src/env.ts b/apps/web/src/env.ts index 1044430..e0ec60b 100644 --- a/apps/web/src/env.ts +++ b/apps/web/src/env.ts @@ -30,7 +30,6 @@ export const env = createEnv({ NEXT_PUBLIC_NODE_ENV: z .enum(["development", "production"]) .default("development"), - NEXT_PUBLIC_API_URL: z.string().url(), NEXT_PUBLIC_WS_URL: z.string().url().optional(), }, @@ -51,7 +50,6 @@ export const env = createEnv({ GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET, OVERRIDE_MAX_LOG_LEVEL: process.env.OVERRIDE_MAX_LOG_LEVEL, PROCESS_ORIGIN: process.env.PROCESS_ORIGIN, - NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL, NEXT_PUBLIC_WS_URL: process.env.NEXT_PUBLIC_WS_URL, // Client-side env vars // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR, diff --git a/apps/web/src/server/providers.tsx b/apps/web/src/server/providers.tsx index f77dfe4..3aea5b6 100644 --- a/apps/web/src/server/providers.tsx +++ b/apps/web/src/server/providers.tsx @@ -58,7 +58,7 @@ export function TRPCClientProvider({ children }: PropsWithChildren) { client: wsClient, }), false: httpBatchLink({ - url: `${env.NEXT_PUBLIC_API_URL}/api/trpc`, + url: `/api/trpc`, }), }), ], @@ -68,7 +68,7 @@ export function TRPCClientProvider({ children }: PropsWithChildren) { return createTRPCClient({ links: [ httpBatchLink({ - url: `${env.NEXT_PUBLIC_API_URL}/api/trpc`, + url: `/api/trpc`, }), ], }); diff --git a/assets/nextwiki-admin-dashboard.png b/assets/nextwiki-admin-dashboard.png new file mode 100644 index 0000000..61997ea Binary files /dev/null and b/assets/nextwiki-admin-dashboard.png differ diff --git a/assets/nextwiki-admin-settings.png b/assets/nextwiki-admin-settings.png new file mode 100644 index 0000000..fede94e Binary files /dev/null and b/assets/nextwiki-admin-settings.png differ diff --git a/assets/nextwiki-browser.png b/assets/nextwiki-browser.png index 6bce7d9..9a66d6d 100644 Binary files a/assets/nextwiki-browser.png and b/assets/nextwiki-browser.png differ diff --git a/assets/nextwiki-edit.png b/assets/nextwiki-edit.png index fed7435..7844644 100644 Binary files a/assets/nextwiki-edit.png and b/assets/nextwiki-edit.png differ diff --git a/assets/nextwiki-home-admin.png b/assets/nextwiki-home-admin.png new file mode 100644 index 0000000..b67fef4 Binary files /dev/null and b/assets/nextwiki-home-admin.png differ diff --git a/assets/nextwiki-home-dark.png b/assets/nextwiki-home-dark.png index 543893e..4103fd2 100644 Binary files a/assets/nextwiki-home-dark.png and b/assets/nextwiki-home-dark.png differ diff --git a/assets/nextwiki-home.png b/assets/nextwiki-home.png index f653fa0..1516a85 100644 Binary files a/assets/nextwiki-home.png and b/assets/nextwiki-home.png differ diff --git a/assets/nextwiki-move.png b/assets/nextwiki-move.png index 05958d0..47f6ca2 100644 Binary files a/assets/nextwiki-move.png and b/assets/nextwiki-move.png differ diff --git a/assets/nextwiki-page.png b/assets/nextwiki-page.png index d68878f..4a97e17 100644 Binary files a/assets/nextwiki-page.png and b/assets/nextwiki-page.png differ diff --git a/assets/nextwiki-search.png b/assets/nextwiki-search.png index f19c8d0..3246fa1 100644 Binary files a/assets/nextwiki-search.png and b/assets/nextwiki-search.png differ diff --git a/packages/db/.env.example b/packages/db/.env.example new file mode 100644 index 0000000..ce81892 --- /dev/null +++ b/packages/db/.env.example @@ -0,0 +1 @@ +DATABASE_URL=