Simplifying Database Operations Through RESTful API Calls
- Overview
- Project Vision
- Key Features
- Architecture
- Technology Stack
- Project Structure
- Getting Started
- API Documentation
- Deployment
- Environment Configuration
- Development Guidelines
- Contributing
- License
- Author
CDN BaseJS is a revolutionary database interaction platform that eliminates the complexity of traditional database operations. By providing a simple, RESTful API interface, developers can perform complete CRUD (Create, Read, Update, Delete) operations through standard HTTP requests without requiring external libraries, SDKs, or complex integrations.
Modern database operations often require:
- Installing and managing multiple external dependencies
- Learning database-specific query languages
- Handling complex connection pooling and authentication
- Managing different SDKs for different platforms
- Dealing with version compatibility issues
CDN BaseJS provides a unified API interface where database operations are as simple as making an HTTP request. Whether you're building a web application, mobile app, or IoT device, if it can make HTTP requests, it can interact with your database.
Core Principle: Database operations should be accessible through simple URL calls, eliminating the need for external modules while maintaining security, performance, and scalability.
- Zero Installation Required - No npm packages, no dependencies to manage
- URL-Based Operations - Perform database operations with simple HTTP requests
- Universal Compatibility - Works with any platform that supports HTTP
- No External Modules - Pure API-driven database interactions
- CDN Distribution - Fast, global content delivery
- MongoDB Backend - Scalable NoSQL database infrastructure
- RESTful Architecture - Industry-standard API design
- Optimized Queries - Efficient database operations
- Intuitive API - Clean, predictable endpoints
- Comprehensive Documentation - Clear examples and use cases
- Standard HTTP Methods - GET, POST, PUT, DELETE operations
- JSON Response Format - Easy to parse and integrate
┌─────────────────┐
│ Client Apps │
│ (Any Platform) │
└────────┬────────┘
│ HTTP/HTTPS
▼
┌─────────────────┐
│ CDN BaseJS │
│ REST API │
└────────┬────────┘
│
▼
┌─────────────────┐
│ MongoDB │
│ Database │
└─────────────────┘
- Client makes HTTP request to API endpoint
- API validates request and authentication
- Database operation is executed on MongoDB
- Response is formatted as JSON
- Result is returned to client
- Framework: Next.js 15 (React 18)
- Language: TypeScript
- Styling: Tailwind CSS
- Deployment: Vercel
- UI Components: Custom component library
- Runtime: Node.js 18+
- Framework: Express.js
- Database: MongoDB
- ODM: Mongoose
- Authentication: JWT (JSON Web Tokens)
- Validation: Express Validator
- Deployment: Render / Railway / Heroku
- Version Control: Git
- Code Quality: ESLint, Prettier
- Testing: Jest, Supertest
- Documentation: Swagger/OpenAPI
cdn-base/
│
├── client/ # Frontend Application
│ ├── app/ # Next.js App Router
│ │ ├── page.tsx # Home page
│ │ ├── layout.tsx # Root layout with metadata
│ │ ├── robots.ts # SEO robots configuration
│ │ ├── sitemap.ts # Dynamic sitemap generation
│ │ └── manifest.ts # PWA manifest
│ │
│ ├── components/ # React components
│ │ └── UnderDevelopment.jsx
│ │
│ ├── public/ # Static assets
│ │ ├── next.svg
│ │ └── favicon.ico
│ │
│ ├── styles/ # Global styles
│ │ └── globals.css
│ │
│ ├── package.json # Frontend dependencies
│ ├── next.config.js # Next.js configuration
│ ├── tsconfig.json # TypeScript configuration
│ └── tailwind.config.js # Tailwind CSS configuration
│
├── server/ # Backend Application
│ ├── src/
│ │ ├── config/ # Configuration files
│ │ │ └── database.js # MongoDB connection
│ │ │
│ │ ├── models/ # Mongoose models
│ │ │ └── Data.js # Data schema
│ │ │
│ │ ├── routes/ # API routes
│ │ │ └── api.js # API endpoints
│ │ │
│ │ ├── controllers/ # Request handlers
│ │ │ └── dataController.js
│ │ │
│ │ ├── middleware/ # Custom middleware
│ │ │ ├── auth.js # Authentication
│ │ │ └── errorHandler.js
│ │ │
│ │ └── utils/ # Utility functions
│ │ └── validator.js
│ │
│ ├── package.json # Backend dependencies
│ └── server.js # Application entry point
│
├── docs/ # Documentation
│ ├── API.md # API documentation
│ └── DEPLOYMENT.md # Deployment guides
│
├── vercel.json # Vercel configuration
├── .gitignore # Git ignore rules
├── README.md # Project documentation
└── LICENSE # MIT License
- Node.js version 18.0 or higher
- npm or yarn package manager
- MongoDB instance (local or cloud)
- Git for version control
git clone https://github.com/adityarwt1/CDN-Base.git
cd CDN-Basecd client
npm installCreate .env.local file:
NEXT_PUBLIC_API_URL=http://localhost:5000
NEXT_PUBLIC_APP_URL=http://localhost:3000Start development server:
npm run devFrontend will be available at: http://localhost:3000
cd ../server
npm installCreate .env file:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/cdnbasejs
JWT_SECRET=your_jwt_secret_key
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000Start development server:
npm run devBackend API will be available at: http://localhost:5000
# Install MongoDB locally
# macOS
brew install mongodb-community
# Ubuntu
sudo apt-get install mongodb
# Start MongoDB service
# macOS
brew services start mongodb-community
# Ubuntu
sudo systemctl start mongodb- Create account at MongoDB Atlas
- Create a new cluster
- Add database user
- Whitelist IP address
- Get connection string
- Update
MONGODB_URIin.env
Development: http://localhost:5000/api
Production: https://your-api-domain.com/api
All protected endpoints require a valid JWT token in the Authorization header:
Authorization: Bearer <your_jwt_token>
GET /api/health
Check API status
Response:
{
"status": "success",
"message": "API is running",
"timestamp": "2024-01-15T10:30:00.000Z"
}GET /api/data
Retrieve all data entries
Query Parameters:
page(optional): Page number for pagination (default: 1)limit(optional): Items per page (default: 10)sort(optional): Sort field (default: -createdAt)
Response:
{
"status": "success",
"data": [
{
"_id": "507f1f77bcf86cd799439011",
"key": "example_key",
"value": "example_value",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 100,
"pages": 10
}
}GET /api/data/:id
Retrieve specific data entry by ID
Response:
{
"status": "success",
"data": {
"_id": "507f1f77bcf86cd799439011",
"key": "example_key",
"value": "example_value",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
}
}POST /api/data
Create a new data entry
Request Body:
{
"key": "example_key",
"value": "example_value"
}Response:
{
"status": "success",
"message": "Data created successfully",
"data": {
"_id": "507f1f77bcf86cd799439011",
"key": "example_key",
"value": "example_value",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
}
}PUT /api/data/:id
Update existing data entry
Request Body:
{
"key": "updated_key",
"value": "updated_value"
}Response:
{
"status": "success",
"message": "Data updated successfully",
"data": {
"_id": "507f1f77bcf86cd799439011",
"key": "updated_key",
"value": "updated_value",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T11:45:00.000Z"
}
}DELETE /api/data/:id
Delete data entry
Response:
{
"status": "success",
"message": "Data deleted successfully"
}All errors follow this format:
{
"status": "error",
"message": "Error description",
"code": "ERROR_CODE"
}Common Error Codes:
400- Bad Request401- Unauthorized403- Forbidden404- Not Found500- Internal Server Error
# Get all data
curl -X GET http://localhost:5000/api/data
# Create new entry
curl -X POST http://localhost:5000/api/data \
-H "Content-Type: application/json" \
-d '{"key": "test", "value": "example"}'
# Update entry
curl -X PUT http://localhost:5000/api/data/507f1f77bcf86cd799439011 \
-H "Content-Type: application/json" \
-d '{"key": "updated", "value": "new_value"}'
# Delete entry
curl -X DELETE http://localhost:5000/api/data/507f1f77bcf86cd799439011// Get all data
const response = await fetch('http://localhost:5000/api/data');
const data = await response.json();
// Create new entry
const response = await fetch('http://localhost:5000/api/data', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
key: 'test',
value: 'example'
})
});
const result = await response.json();- Go to Vercel Dashboard
- Import your GitHub repository
- Configure project settings:
- Root Directory:
client - Framework Preset: Next.js
- Build Command:
npm run build - Output Directory:
.next
- Root Directory:
- Add environment variables:
NEXT_PUBLIC_API_URL=https://your-backend-api.com - Deploy
cd client
npm install -g vercel
vercel login
vercel --prod- Create account at Render
- Create new Web Service
- Connect GitHub repository
- Configure:
- Root Directory:
server - Build Command:
npm install - Start Command:
npm start
- Root Directory:
- Add environment variables
- Deploy
- Create account at Railway
- Create new project
- Connect GitHub repository
- Configure root directory:
server - Add environment variables
- Deploy
cd server
heroku login
heroku create cdn-basejs-api
git subtree push --prefix server heroku main- Create cluster at MongoDB Atlas
- Create database user
- Whitelist IP addresses (0.0.0.0/0 for all)
- Get connection string
- Update environment variable:
MONGODB_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/cdnbasejs
Development (.env.local):
NEXT_PUBLIC_API_URL=http://localhost:5000
NEXT_PUBLIC_APP_URL=http://localhost:3000Production (Vercel Dashboard):
NEXT_PUBLIC_API_URL=https://your-backend-api.com
NEXT_PUBLIC_APP_URL=https://your-frontend.vercel.appDevelopment (.env):
PORT=5000
MONGODB_URI=mongodb://localhost:27017/cdnbasejs
JWT_SECRET=your_jwt_secret_key_development
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000Production:
PORT=5000
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/cdnbasejs
JWT_SECRET=your_secure_jwt_secret_key_production
NODE_ENV=production
CORS_ORIGIN=https://your-frontend.vercel.app- Follow ESLint and Prettier configurations
- Use TypeScript for type safety in frontend
- Write meaningful commit messages
- Keep functions small and focused
- Add comments for complex logic
# Create feature branch
git checkout -b feature/your-feature-name
# Make changes and commit
git add .
git commit -m "feat: add new feature description"
# Push to remote
git push origin feature/your-feature-name
# Create pull request on GitHubfeat: Add new feature
fix: Fix bug
docs: Update documentation
style: Format code
refactor: Refactor code
test: Add tests
chore: Update dependencies
cd client
npm run test
npm run test:coveragecd server
npm run test
npm run test:integration# Lint code
npm run lint
# Format code
npm run format
# Type check
npm run type-checkWe welcome contributions from the community. Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Make your changes
- Write or update tests
- Ensure all tests pass
- Submit a pull request
- Update README.md with details of changes if needed
- Update API documentation for endpoint changes
- Ensure code follows project style guidelines
- Add tests for new features
- Request review from maintainers
- Be respectful and inclusive
- Provide constructive feedback
- Focus on what is best for the community
- Show empathy towards other contributors
If you discover a security vulnerability, please email:
- Security Contact: security@cdnbasejs.com (if available)
- Alternative: Open a private security advisory on GitHub
- Never commit sensitive data (API keys, passwords)
- Use environment variables for configuration
- Keep dependencies updated
- Follow OWASP security guidelines
- Implement rate limiting on API endpoints
This project is licensed under the MIT License. See the LICENSE file for details.
MIT License
Copyright (c) 2024 Aditya Rawat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Aditya Rawat
- LinkedIn: Aditya Rawat
- GitHub: @adityarwt1
- Repository: CDN-Base
- Inspired by the need for simplified database operations
- Built with modern web technologies
- Thanks to the open-source community for tools and libraries
- Special thanks to all contributors
Version 1.0 (Q2 2024)
- Complete CRUD operations via REST API
- MongoDB integration
- Basic authentication system
- API documentation
- Frontend dashboard
Version 1.5 (Q3 2024)
- Advanced query capabilities
- Batch operations support
- Webhook notifications
- API rate limiting
- Enhanced security features
Version 2.0 (Q4 2024)
- GraphQL support
- Real-time subscriptions
- Multi-database support
- Advanced analytics
- Enterprise features
For support and questions:
- Documentation: Read the Docs (coming soon)
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@cdnbasejs.com (if available)
Q: Do I need to install any packages to use CDN BaseJS?
A: No, CDN BaseJS is designed to work with simple HTTP requests. No external packages required.
Q: What databases are supported?
A: Currently, we support MongoDB. Support for other databases is planned for future releases.
Q: Is CDN BaseJS free to use?
A: Yes, CDN BaseJS is open-source and free to use under the MIT License.
Q: Can I use CDN BaseJS in production?
A: The project is currently under development. Production-ready release is planned for Q2 2024.
Q: How do I report bugs?
A: Please open an issue on our GitHub repository.
Built with dedication for developers who value simplicity.
Last Updated: May 2026