Barchalani MIS
The Barchalani Management Information System (MIS) is a large-scale, production-ready ERP platform designed to digitize and modernize the logistics and customs brokerage industry in Afghanistan.
The system replaces fragmented manual workflows with a centralized, secure, and scalable platform capable of handling high concurrency, financial precision, and strict data isolation across hundreds of independent brokerage companies.
Project Objectives
- Digital Transformation: Replace manual and fragmented processes with a unified digital platform.
- Financial Accuracy: Ensure precise tracking of payments, balances, and financial reports.
- Multi-Tenant Isolation: Support multiple independent companies securely within a single system.
- Government Compatibility: Generate ASYCUDA-compatible XML and official logistics documents.
- Scalability: Handle 400+ concurrent users without performance degradation.
Project Scope
- ERP System Development: Built a full logistics and financial management system from scratch.
- Multi-Tenant Architecture: Designed secure tenant isolation using scoped database queries.
- Financial Engine: Implemented transaction-safe operations with ACID guarantees.
- Document Generation: Automated invoices, packing lists, and ASYCUDA XML exports.
- Search System: Developed a Persian/Arabic normalized search engine for reliable results.
- SaaS Billing: Integrated subscription and credit-based usage system.
Process and Methodology
The project followed a discovery-driven and iterative development process due to initially unclear requirements.
Through real-world workflow analysis and continuous refinement, the system evolved from a simple record-keeping tool into a full ERP platform.
Key architectural decisions—such as implementing financial locking mechanisms and yearly numbering systems—were introduced during development and required careful refactoring without compromising existing data.
Challenges
- Undefined Requirements: Initial scope was unclear and required deep domain analysis.
- Financial Data Integrity: Ensuring atomic operations across multiple related collections.
- High Concurrency: Supporting hundreds of users performing simultaneous operations.
- MongoDB Transaction Issues: Handling transaction limitations in a single-node replica set.
- Nginx Caching Problems: Debugging stale assets and deployment inconsistencies.
- Language Normalization: Handling Persian and Arabic character inconsistencies in search.
Solutions
- Iterative Architecture Design: Continuously refined system design based on real usage patterns.
- Manual Transaction Management: Implemented controlled session handling for financial consistency.
- Sequential Write Strategy: Eliminated concurrency issues in MongoDB transactions.
- Optimized Nginx Configuration: Fixed caching and buffering issues for stable deployments.
- Custom Normalization Engine: Built regex-based normalization for reliable multilingual search.
- Performance Optimization: Used
.lean()queries and connection pooling to reduce load.
Results and Impact
The system successfully transformed logistics operations for multiple brokerage firms:
- Full Digital Workflow: Eliminated manual paperwork and improved operational speed.
- Financial Transparency: Accurate real-time tracking of balances and transactions.
- Scalable Infrastructure: Supports 400+ concurrent users in production.
- Improved Efficiency: Reduced errors and increased processing speed significantly.
- Government Readiness: Enabled standardized document generation for customs integration.
System Highlights
- Multi-tenant SaaS architecture
- Financial locking & audit-ready system
- ASYCUDA XML integration
- Real-time scalable infrastructure
What I Did
- Full-Stack ERP System Architecture
- Multi-Tenant System Design
- Financial Transaction System (ACID)
- Security Implementation (RBAC, Fail2Ban, CSP)
- Performance Optimization & Scaling
- DevOps & Docker Deployment
Technology Stack
- Next.js 14
- Node.js
- MongoDB
- Mongoose
- Docker
- Nginx
- NextAuth.js
- Zod
- TypeScript
- aaPanel