A TypeScript and MongoDB-based accounting application that enables financial data management and file uploads.
- Data Management: Store and retrieve accounting data
- File Upload: Secure file upload and storage
- Reports System: Generate and manage financial reports
- Duplicate Prevention: Duplicate checking when saving data
- RESTful API: Complete and secure API interface
- Comprehensive Testing: Automated testing system with Jest
- TypeScript: Safe and reliable code with strong typing
typescript-mongodb-app/
├── src/
│ ├── app.ts # Main entry point
│ ├── config/
│ │ └── database.ts # Database connection configuration
│ ├── controllers/
│ │ ├── dataController.ts # Data management controller
│ │ ├── fileController.ts # File upload controller
│ │ └── reportController.ts # Report management controller
│ ├── middleware/
│ │ └── upload.ts # File upload middleware
│ ├── models/
│ │ └── index.ts # MongoDB models
│ ├── routes/
│ │ ├── dataRoutes.ts # Data API routes
│ │ ├── fileRoutes.ts # File API routes
│ │ └── reportRoutes.ts # Report API routes
│ ├── services/
│ │ ├── dataService.ts # Data services
│ │ ├── fileService.ts # File services
│ │ └── reportService.ts # Report services
│ └── types/
│ └── index.ts # General type definitions
├── tests/ # Automated tests
├── uploads/ # Uploaded files directory
├── nodejs-portable/ # Portable Node.js
└── package.json
- Node.js 20.5.0+ (included in project)
- MongoDB (local or remote)
-
Install dependencies:
npm install
-
Build:
npm run build
-
Run in development mode:
npm run dev
-
Run in production mode:
npm start
The project includes a comprehensive testing system with Jest:
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Generate coverage report
npm run test:coverage
# Run tests with verbose output
npm run test:verbose- Unit Tests: Individual component testing
- Integration Tests: API integration testing
- Mocking: External module mocking
- Coverage: Complete coverage reporting
POST /api/data- Save new dataGET /api/data- Retrieve all data
POST /api/files/upload- Upload fileGET /api/files- Retrieve file list
GET /reports/generate- Generate a report from current dataGET /reports/summary- Get summary statistics of data
- Node.js 20.5.0 - Runtime environment
- TypeScript 5.1.6 - Development language
- Express.js 4.18.2 - Web framework
- MongoDB - Database
- Mongoose 7.5.0 - MongoDB ODM
- Multer 1.4.5 - File upload handling
- Jest 30.0.5 - Testing framework
- Supertest 7.1.4 - HTTP testing
- ts-jest 29.4.1 - Jest with TypeScript
- Validation: Input data validation
- Error Handling: Comprehensive error handling
- Type Safety: TypeScript for error prevention
- Duplicate Prevention: Data duplication prevention
const response = await fetch('/api/data', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'January Income',
value: 15000
})
});const formData = new FormData();
formData.append('file', fileInput.files[0]);
const response = await fetch('/api/files/upload', {
method: 'POST',
body: formData
});// Get summary statistics
const summaryResponse = await fetch('/reports/summary');
const summary = await summaryResponse.json();
// Generate full report
const reportResponse = await fetch('/reports/generate');
const report = await reportResponse.json();Create a .env file:
MONGODB_URI=mongodb://localhost:27017/accounting-app
PORT=3000
- Create Service in
src/services/ - Create Controller in
src/controllers/ - Create Routes in
src/routes/ - Add tests in
tests/
npm run test:watch- Code Coverage: Comprehensive test coverage
- Type Safety: 100% TypeScript
- Error Handling: Comprehensive error handling
- Testing: Complete test suite with multiple test files
Test Suites: 11 test files
├── app.test.ts # Application tests
├── database.test.ts # Database connection tests
├── dataController.test.ts # Data controller tests
├── dataService.test.ts # Data service tests
├── fileController.test.ts # File controller tests
├── fileService.test.ts # File service tests
├── reportController.test.ts # Report controller tests
├── reportService.test.ts # Report service tests
├── integration.test.ts # Integration tests
├── upload.test.ts # Upload middleware tests
└── setup.ts # Test setup configuration
- v1.0.0: Initial version with data management and file upload
- Future features: Reports, charts, data export
MIT License - see LICENSE file for details.
- Clone the repository
- Create a feature branch
- Add tests for new features
- Submit a Pull Request
Developed in Israel