Skip to content

A NestJS API server with PostgreSQL database, Better Auth authentication, and real-time collaboration features for a notes application.

Notifications You must be signed in to change notification settings

kubilayture/collaborative.notes.backend

Repository files navigation

Collaborative Notes Backend 🚀

TypeScript NestJS PostgreSQL Socket.io

📖 About

The backend API for my collaborative notes application - a robust NestJS server that powers real-time note editing, user authentication, and hierarchical folder management. Built to handle multiple users collaborating on documents simultaneously with seamless real-time synchronization.

✨ Features

  • 🔐 Secure Authentication - Better Auth integration with session management
  • 📁 Hierarchical Folders - Nested folder structure with unlimited depth
  • 📝 Real-time Collaboration - Live note editing with Socket.io
  • 💬 Real-time Messaging - Built-in chat system for collaborators
  • 📊 RESTful API - Clean, documented endpoints with Swagger
  • 🔒 Security First - Helmet middleware, CORS, input validation
  • 🗃️ PostgreSQL Database - Reliable data persistence with connection pooling
  • 📋 API Documentation - Auto-generated Swagger docs

🛠️ Tech Stack

  • Framework: NestJS (Node.js)
  • Language: TypeScript
  • Database: PostgreSQL
  • Authentication: Better Auth
  • Real-time: Socket.io
  • Validation: class-validator, class-transformer
  • Documentation: Swagger/OpenAPI
  • Security: Helmet, CORS
  • Testing: Jest

🚀 Quick Start

Prerequisites

  • Node.js (v18 or higher)
  • PostgreSQL database
  • npm or yarn

Installation

  1. Clone the repository

    git clone https://github.com/kubilayture/collaborative.notes.backend.git
    cd collaborative.notes.backend
  2. Install dependencies

    npm install
  3. Environment Setup

    Create a .env file in the root directory:

    # Database Configuration
    DB_HOST=localhost
    DB_PORT=5432
    DB_USERNAME=your_db_username
    DB_PASSWORD=your_db_password
    DB_NAME=collaborative_notes
    
    # Authentication
    BETTER_AUTH_SECRET=your_secret_key_here
    
    # Server Configuration
    PORT=4000
    FRONTEND_URL=http://localhost:5173
  4. Database Setup

    Make sure PostgreSQL is running and create the database:

    CREATE DATABASE collaborative_notes;
  5. Start the server

    # Development with hot reload
    npm run start:dev
    
    # Production build
    npm run build
    npm run start:prod

📚 API Documentation

Once the server is running, visit:

🧪 Testing

# Run unit tests
npm run test

# Run tests in watch mode
npm run test:watch

# Run e2e tests
npm run test:e2e

# Generate test coverage
npm run test:cov

🏗️ Project Structure

src/
├── lib/                 # Shared utilities and configurations
│   └── auth.ts         # Better Auth configuration
├── modules/            # Feature modules (when added)
├── main.ts            # Application entry point
└── app.module.ts      # Root module

test/                  # E2E tests

🔧 Development Scripts

npm run start:dev      # Start development server with hot reload
npm run build          # Build for production
npm run start:prod     # Start production server
npm run lint           # Run ESLint with auto-fix
npm run format         # Run Prettier formatting
npm run test           # Run unit tests
npm run test:e2e       # Run end-to-end tests

🌐 Related Projects

📝 License

This project is part of my personal portfolio. Feel free to explore the code!

🤝 Contributing

This is a personal project, but I'm open to suggestions and feedback. Feel free to open an issue or reach out!


Built with ❤️ using NestJS and TypeScript

About

A NestJS API server with PostgreSQL database, Better Auth authentication, and real-time collaboration features for a notes application.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published