A comprehensive Learning Management System with integrated gamification features, marketplace functionality, and digital wallet system.
- Course creation and enrollment
- Assignment management with submissions
- Automated grading system
- Announcements and notifications
- Student performance tracking
- XP and leveling system
- Achievement badges
- Leaderboards (weekly, monthly, all-time)
- Progress tracking and milestones
- Product catalog with search
- Shopping cart functionality
- Secure checkout process
- Order management and tracking
- Virtual currency system
- PIN-protected transactions
- Peer-to-peer transfers
- Transaction history
- Multi-role user management (Student, Teacher, Admin, Staff)
- Role-based access control (RBAC)
- Comprehensive audit logging
- College/institution management
- Runtime: Node.js 18+
- Framework: Express.js 5.2
- Database: PostgreSQL 14+
- ORM: Prisma 7.3
- Authentication: JWT with HTTP-only cookies
- Validation: Zod
- Security: bcrypt for password hashing
- Language: JavaScript
- Node.js 18.0.0 or higher
- PostgreSQL 14.0 or higher
- npm or yarn
-
Clone the repository
git clone https://github.com/harshhhh1/Bbrains.git cd Bbrains/Backend -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Edit
.envand configure:DATABASE_URL="postgresql://username:password@localhost:5432/Bbrains" JWT_SECRET="your-secret-key-min-32-characters" PORT=3000 NODE_ENV=development
-
Set up the database
# Run migrations npx prisma migrate dev # Generate Prisma Client npx prisma generate # (Optional) Seed database with sample data npm run db:seed
-
Start the server
npm start
The API will be available at http://localhost:3000
📁Backend/
├── 📁controllers/ # Request handlers
├── 📁routes/ # API route definitions
├── 📁middleware/ # Express middleware (auth, validation, etc.)
├── 📁services/ # Business logic layer
├── 📁utils/ # Helper functions and utilities
├── 📁prisma/ # Database schema and migrations
├── server.js # Application entry point
└── package.json # Dependencies and scripts
Comprehensive documentation is available:
- API Documentation - Complete API reference with all endpoints
- Technical Documentation - Architecture, database schema, deployment
- Developer Guide - Setup, coding standards, contribution guide
POST /register- Create new user accountPOST /login- Authenticate userPOST /logout- End user session
GET /user/me- Get current user profileGET /user/students- List all studentsGET /user/teachers- List all teachersPOST /user/claim-daily- Claim daily rewards
GET /academic/assignments- List assignmentsPOST /academic/assignments- Create assignmentPOST /academic/submissions- Submit assignmentGET /academic/announcements- View announcements
GET /market/products- Browse productsPOST /market/cart- Add to cartPOST /market/checkout- Purchase items
GET /wallet/me- Get wallet balancePOST /wallet/transfer- Transfer fundsGET /wallet/history- Transaction history
See API_DOCUMENTATION.md for the complete list of 100+ endpoints.
The system uses PostgreSQL with 24 main tables:
- Core: User, UserDetails, College, Address
- Academic: Course, Assignment, Submission, Grade, Enrollment
- Gamification: Xp, Level, Achievement, Leaderboard
- Commerce: Product, Cart, Order, OrderItem, Wallet, TransactionHistory
- System: Role, AuditLog, Announcement
See TECHNICAL_DOCUMENTATION.md for detailed schema information.
- JWT-based authentication with HTTP-only cookies
- Password hashing with bcrypt (10 salt rounds)
- Role-based access control (RBAC)
- PIN protection for wallet transactions
- Input validation with Zod schemas
- SQL injection prevention via Prisma ORM
- Comprehensive audit logging
# Run tests (coming soon)
npm test
# View database in Prisma Studio
npx prisma studio- Student - Access courses, submit assignments, use marketplace
- Teacher - Create assignments, grade submissions, manage courses
- Admin - Full system access, user management, system configuration
- Staff - Limited administrative capabilities
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'feat: Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
See DEVELOPER_GUIDE.md for detailed contribution guidelines.
npm start # Start development server with nodemon
npm run db:seed # Seed database with sample data
npx prisma studio # Open Prisma Studio (database GUI)
npx prisma migrate dev # Create and run new migrationPort already in use:
lsof -i :3000
kill -9 <PID>Database connection issues:
- Verify PostgreSQL is running:
pg_isready - Check DATABASE_URL in
.env - Ensure database exists
Prisma Client errors:
npx prisma generateSee DEVELOPER_GUIDE.md for more troubleshooting tips.
This project is licensed under the ISC License.
Harsh
- GitHub: @harshhhh1
- Discord: golem.uwu
- Express.js team for the excellent web framework
- Prisma team for the amazing ORM
- All contributors and supporters of this project
Built with ❤️ for modern education