🚀 Diagramers API
A comprehensive Node.js API framework built with TypeScript, Express, MongoDB, and built-in authentication and permission management.
🎯 Quick Start
Prerequisites
- Node.js 18+
- MongoDB 6+
- npm or yarn
Installation
npm install
cp .env.example .env
npm run dev
Environment Setup
# Database
MONGODB_URI=mongodb://localhost:27017/diagramers
MONGODB_DB=diagramers
# JWT
JWT_SECRET=your-secret-key
JWT_EXPIRES_IN=1h
# Server
PORT=3000
NODE_ENV=development
🏗️ Project Structure
src/
├── core/ # Core system components
│ ├── app.ts # Application setup
│ ├── server/ # Server management
│ ├── database/ # Database connection & seeding
│ └── middleware/ # Authentication & permission middleware
├── modules/ # Business logic modules
│ ├── auth/ # Authentication module
│ ├── user/ # User management
│ └── permission/ # Permission system
├── shared/ # Shared utilities and types
│ ├── types/ # TypeScript interfaces
│ ├── utils/ # Utility functions
│ └── constants/ # System constants
└── routes/ # Route definitions
🔐 Authentication & Permissions
The API includes a comprehensive permission system:
- JWT-based authentication with multiple provider support
- Role-based access control with fine-grained permissions
- Dynamic permission middleware for route protection
- Resource-based permissions for ownership checks
📚 Documentation
For comprehensive development guides, examples, and best practices, see:
🚀 Complete Developer Guide
The developer guide covers:
- Module development from A to Z
- Database design and entity creation
- API endpoint development
- Permission system setup
- CLI commands and automation
- Testing and deployment
- Troubleshooting and best practices
🎛️ Available Scripts
Development
npm run dev
npm run build
npm run start
Database
npm run seed
npm run setup:permissions
npm run setup:admin
Module Generation
npm run generate:module
npm run generate:table
npm run generate:endpoint
Utilities
npm run lint
npm run type-check
npm run format
npm run docs
🌐 API Endpoints
Base URL
http://localhost:3000/api
Available Endpoints
GET /health
- Health check
POST /auth/login
- User authentication
GET /users
- Get all users (requires authentication)
POST /users
- Create new user (requires authentication)
Authentication
Include JWT token in Authorization header:
Authorization: Bearer <your-jwt-token>
x-request-id: MODULE_ACTION_UUID (optional)
x-correlation-id: <correlation-id> (optional)
🧪 Testing
npm run test:permissions
npm test
🚀 Deployment
npm run build
npm start
npm run docker:build
npm run docker:run
🔧 Configuration
Environment Variables
NODE_ENV
- Environment (development/production)
PORT
- Server port
MONGODB_URI
- MongoDB connection string
JWT_SECRET
- JWT signing secret
JWT_EXPIRES_IN
- JWT expiration time
Database Configuration
- MongoDB with Mongoose ODM
- Automatic schema management
- Built-in seeding and migration tools
📖 Examples
Creating a New Module
npm run generate:module -- --name=products --description="Product management"
Permission Setup
npm run setup:permissions
npm run setup:admin
🆘 Support
- Documentation: Complete Developer Guide
- Issues: Create issues in the project repository
- Examples: Check existing modules in
src/modules/
📄 License
This project is licensed under the MIT License.
For complete development guides and examples, see the Developer Guide