A robust backend system designed to process, analyze, and manage notes, attachments, and AI-powered document summarization. This project demonstrates clean architecture, scalability, and maintainable code, using TypeScript, Node Js, Express Js, and MongoDB database.
The API supports advanced AI integrations, such as OCR and text summarization, while adhering to best practices in software design and development.
- Notes Management: Create, retrieve, and delete notes.
- Attachments Handling: Upload and manage attachments with proper file validation.
- AI Summarization: Use GPT to summarize large documents.
- OCR Integration: Extract text from images or scanned documents.
- Scalable Architecture: Built using SOLID principles and separation of concerns.
- Rate Limiting: Protect AI APIs with advanced rate-limiting mechanisms.
- Logging: Centralized logging system for debugging and monitoring.
- Environment Management: Flexible configuration for different environments (development, production).
The system is designed with a modular and scalable architecture, consisting of the following components:
-
API Gateway
- Centralized entry for all requests, handling routing, authentication, rate limiting, and validation.
-
Node.js Server
- Core business logic with RESTful endpoints:
/api/v1/notes
for managing notes./api/v1/attachments
for file handling./api/v1/ai
for AI-powered processing.
- Core business logic with RESTful endpoints:
-
Middleware Layer
- Includes rate limiting, input validation, and error handling for API reliability and security.
-
Database Layer
- MongoDB for storing notes, metadata, tags, and attachment references with efficient querying.
-
File Storage
- Local storage for uploaded files, with extensibility for cloud storage integration.
-
AI Integration
- Uses OpenAI API for OCR, text summarization, and structured data extraction.
-
Client Layer
- External clients interacting with the API for creating notes, uploading files, and AI processing.
-
Logging and Monitoring
- Centralized logging and performance monitoring for debugging and reliability.
Follow these steps to set up the project on your local machine:
-
Clone the repository:
git clone https://github.com/aviroopjana/smart-notes-backend.git cd Induced-AI-Backend-SDE
-
Install Dependencies
npm install
-
Set Up Environment Variables Create a
.env
file in the root directory with the following content:PORT=3000 MONGO_URI=mongodb://localhost:27017/induced-ai OPENAI_API_KEY=your-openai-api-key FILE_STORAGE_PATH=uploads
Or
An example
.env.example
file for reference:PORT=3000 # The port number where the app will run MONGO_URI= # Your MongoDB connection string OPENAI_API_KEY= # OpenAI API key for GPT integration FILE_STORAGE_PATH= # Directory path for storing uploaded files (defaults to 'uploads')
- Copy
.env.example
to a new file named.env
. - Replace placeholder values with your actual credentials and configuration.
- Save changes and run the application.
- Copy
-
Run the Project
For Development Mode:
npm run dev
For Production Mode:
npm run build && npm start
-
Access the Application Open your browser and visit:
http://localhost:3000
-
Notes API (
/api/v1/notes
):-
POST /
- Create a new note. -
GET /
- Retrieve all notes. -
GET /:id
- Retrieve specific notes based on Id. -
PUT /:id
- Update specific notes based on Id. -
DELETE /:id
- Delete a specific note. -
GET /search
- Advance search notes based on input.
-
-
Attachments API (
/api/v1/attachments
):POST /upload
- Upload an attachment.GET /:id
- Retrieve a specific attachment.DELETE /:id
- Delete a specific attachment.
-
AI Summarization API (
/api/v1/ai/summarize
):POST /
- Summarize a given document.
-
OCR API (
/api/v1/ocr
):POST /
- Extract text from an uploaded image.
src/
├── config/ # Configuration files (e.g., database, environment variables)
├── controllers/ # Route handlers for various endpoints
├── errors/ # Custom error classes and types
├── middlewares/ # Middleware logic for request validation, rate limiting, etc.
├── models/ # Mongoose schemas and database models
├── routes/ # API route definitions
├── services/ # Business logic and external integrations
├── types/ # TypeScript types and interfaces
├── utils/ # Utility functions (e.g., logging, response formatting)
- Language: TypeScript
- Framework: Express Js, Node Js
- Database: MongoDB
- AI Integration: OpenAI GPT, Tesseract OCR
- Other Tools:
- Multer (File uploads)
- Winston (Logging)
- dotenv (Environment management)
- Comprehensive Testing: Add unit and integration tests for all APIs.
- Role-based Access Control: Add user authentication and authorization layers.
- Enhanced Logging: Use centralized logging with log rotation.
- Performance Optimization: Explore caching mechanisms for frequently accessed resources.
For any queries or contributions, feel free to reach out:
- Name: Aviroop Jana
- Email: [email protected]
- GitHub: github.com/aviroopjana
Thank you for exploring this project!