Skip to content

A modern marketplace platform for students to buy and sell study notes. Built with Next.js 16, TypeScript, and MongoDB.

Notifications You must be signed in to change notification settings

moyshik7/notes-web

Repository files navigation

Notenibo πŸ“š

A modern marketplace platform for students to buy and sell study notes. Built with Next.js 16, TypeScript, and MongoDB.

🌟 Features

  • πŸ“ Note Marketplace: Browse, search, and purchase study notes from fellow students
  • πŸ’° Wallet System: Integrated balance management for seamless transactions
  • πŸ” Secure Authentication: Sign in with Google or email/password using NextAuth
  • πŸ“€ Upload & Sell: Submit your notes for approval and earn money
  • πŸ‘¨β€πŸ’Ό Admin Dashboard: Review submitted notes, manage users, and monitor platform statistics
  • πŸ”” Telegram Integration: Automated notifications to admins for new submissions and balance requests
  • ☁️ Cloud Storage: Reliable file storage powered by Cloudflare R2
  • 🎨 Modern UI: Beautiful, responsive interface with Tailwind CSS and Framer Motion animations

πŸš€ Tech Stack

  • Framework: Next.js 16 (App Router)
  • Language: TypeScript
  • Database: MongoDB with Mongoose ODM
  • Authentication: NextAuth.js (Google OAuth & Credentials)
  • File Storage: Cloudflare R2 (S3-compatible)
  • Styling: Tailwind CSS v4
  • Animations: Framer Motion
  • Icons: Lucide React
  • Notifications: Telegram Bot API

Screenshots








πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js >= 22.0.0
  • npm or yarn package manager
  • MongoDB database (local or cloud instance like MongoDB Atlas)
  • Cloudflare R2 bucket and credentials
  • Google OAuth credentials (optional, for Google sign-in)
  • Telegram Bot token and channel ID (optional, for admin notifications)

πŸ› οΈ Installation

  1. Clone the repository
git clone https://github.com/yourusername/notenibo.git
cd notenibo
  1. Install dependencies
npm install
  1. Set up environment variables

Create a .env.local file in the root directory:

# Database
MONGODB_URI=your_mongodb_connection_string

# NextAuth
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your_nextauth_secret_key

# Google OAuth (optional)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret

# Cloudflare R2
R2_ACCOUNT_ID=your_r2_account_id
R2_ACCESS_KEY_ID=your_r2_access_key_id
R2_SECRET_ACCESS_KEY=your_r2_secret_access_key
R2_BUCKET_NAME=your_bucket_name

# Telegram (optional)
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
TELEGRAM_CHANNEL_ID=your_telegram_channel_id

πŸ”‘ Setting up Environment Variables

MongoDB URI
  • Sign up for MongoDB Atlas (free tier available)
  • Create a new cluster
  • Click "Connect" β†’ "Connect your application"
  • Copy the connection string and replace <password> with your database user password
NextAuth Secret

Generate a random secret key:

openssl rand -base64 32
Google OAuth
  1. Go to Google Cloud Console
  2. Create a new project or select existing one
  3. Enable Google+ API
  4. Go to "Credentials" β†’ "Create Credentials" β†’ "OAuth 2.0 Client ID"
  5. Add authorized redirect URI: http://localhost:3000/api/auth/callback/google
  6. Copy Client ID and Client Secret
Cloudflare R2
  1. Sign up for Cloudflare
  2. Go to R2 Storage β†’ Create bucket
  3. Go to "Manage R2 API Tokens" β†’ Create API token
  4. Copy Account ID, Access Key ID, and Secret Access Key
Telegram Bot
  1. Message @BotFather on Telegram
  2. Send /newbot and follow instructions
  3. Copy the bot token
  4. Create a Telegram channel for admin notifications
  5. Add your bot as an admin to the channel
  6. Get the channel ID (use @userinfobot)

πŸƒ Running the Application

Development Mode

npm run dev

Visit http://localhost:3000 to see the application.

Production Build

npm run build
npm start

Docker Deployment

docker build -t notenibo .
docker run -p 3000:3000 --env-file .env.local notenibo

πŸ“ Project Structure

notenibo/
β”œβ”€β”€ app/                    # Next.js App Router pages
β”‚   β”œβ”€β”€ api/               # API routes
β”‚   β”œβ”€β”€ dashboard/         # User dashboard
β”‚   β”œβ”€β”€ notes/             # Browse and view notes
β”‚   β”œβ”€β”€ admin/             # Admin panel
β”‚   β”œβ”€β”€ sell/              # Upload notes
β”‚   └── ...
β”œβ”€β”€ components/            # React components
β”œβ”€β”€ lib/                   # Utility libraries
β”‚   β”œβ”€β”€ auth.ts           # NextAuth configuration
β”‚   β”œβ”€β”€ mongodb.ts        # MongoDB connection
β”‚   β”œβ”€β”€ r2.ts             # Cloudflare R2 utilities
β”‚   └── telegram.ts       # Telegram notifications
β”œβ”€β”€ models/                # Mongoose models
β”‚   β”œβ”€β”€ User.ts
β”‚   β”œβ”€β”€ Note.ts
β”‚   β”œβ”€β”€ Transaction.ts
β”‚   └── BalanceRequest.ts
β”œβ”€β”€ types/                 # TypeScript type definitions
└── public/               # Static assets

πŸ‘€ User Roles

Student (Default)

  • Browse and purchase notes
  • Upload notes for sale (pending admin approval)
  • Request balance top-ups
  • View purchase history

Admin

  • Approve/reject submitted notes
  • Manage balance requests
  • View platform statistics
  • Delete notes
  • Access admin dashboard

Creating an Admin User

After registering, manually update the user's role in the MongoDB database:

db.users.updateOne(
  { email: "admin@example.com" },
  { $set: { role: "admin" } }
)

πŸ”’ Security Notes

  • Never commit .env.local to version control
  • Use strong, unique passwords for all services
  • Regularly rotate API keys and secrets
  • Enable 2FA on all service accounts
  • Keep dependencies updated: npm audit fix

πŸ“ API Routes

Key API endpoints:

  • POST /api/auth/register - Register new user
  • POST /api/notes/upload - Upload a new note
  • GET /api/notes - Get all approved notes
  • POST /api/notes/[id]/buy - Purchase a note
  • GET /api/notes/[id]/download - Download purchased note
  • POST /api/user/add-balance - Request balance top-up
  • GET /api/user/dashboard - Get user dashboard data
  • GET /api/admin/stats - Get admin statistics

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.

πŸ› Bug Reports & Feature Requests

If you encounter any bugs or have feature requests, please file an issue on the GitHub Issues page.

πŸ“§ Contact

For questions or support, please open an issue on GitHub.


Made with ❀️ for students, by students

About

A modern marketplace platform for students to buy and sell study notes. Built with Next.js 16, TypeScript, and MongoDB.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages