This web application helps me to manage my everyday expenses.
You need to have installed Node.js.
No database server is required.
To launch the application for the first time, you shall clone it to your PC:
git clone --recurse https://github.com/idenisovs/money-saver.git backend
Then, go inside and run the following commands:
npm run setup
npm start
From now, web application should be accessible by passing the following link: http://localhost:9001
Default user login is user1
with password demo1
.
By default it is listening the port 9001
. You can change it in Source/config.json
file.
Because I wanted to get new skills and gather some more experience with development of web applications by using the technologies like Node.js.
In the Source directory:
Usage: node daemon.js [options]
-p, --port - select the port to listen;
-b, --database - give a path to the database;
-v, --verbose - run in verbose mode (by default, it will run with INFO loglevel;
-d, --debug - add some verbosity to output by setting loglevel to DEBUG;
-t, --trace - set loglevel to TRACE, extra verbosity;
--testable - run application in testable mode.
-h - show help;
As example:
node daemon.js -vd -p 8000 - will run application in verbose mode with DEBUG loglevel on port 8000;
Note: testable mode means that application will use in-memory SQLite3 database to store the data. Such mode is necessary to run integration tests provided with Money Saver application.
- Angular.js (1.x.x) and Bootstrap to make UI.
- chart.js to make beautifull charts.
- Bower dependency management.
- Grunt to perform some routine actions, like version management or frontend files minification.
Frontend files located under the following path: money-saver/Source/ui
.
- Node.js to run everything.
- Express to make web application on top of Node.js
- Memcached mainly used for session storage.
- Passport authentication management.
- log4js logging framework.
Backend application
+------------------------------------+ finance.db
+--------+ REST API | +-----+ +----+ +-----+ | +----+
| Client | ----------|->| API | <--> | BL | <--> | DAL |<-|--->| DB |
+--------+ | +-----+ +----+ +-----+ | +----+
| | |
| | +--------------+ |
+---------------|->| Static files | |
| +--------------+ |
+------------------------------------+
- API layer modules, like
intervals
orpayments
process REST API requests, calls BL and makes responses.- Some pre-process and validation functions is moved to Express middleware.
- BL (Business Logic) layer has processing and calculations functions and make calls to DAL.
- DAL (Data Access Layer) perform database requests.
Each layer is organized in tree-like structure:
+--- ( get-interval-by-id )
|
+---- intervals---+--- ( get-latest-interval )
/ |
api------ payments +--- ( get-intervals )
\
+---- properties
The same is for BL and DAL:
+--- ( get-by-id )
|
+---- intervals---+--- ( get-latest )
/ |
bl------ payments +--- ( get-all )
\
+---- properties
So, typically, any API module (like get-interval-by-id
) may call any BL function like this:
const bl = require('../../bl');
bl.intervals.getById(id, success, fail);
- In the future async / await approach will be applied here.
At the moment (2018-07-17) no database server is required and no database server can be used by application. To store and manage the data it uses the SQLite3 engine.
It's database is located within finance.db
file. It can be observerd by SQLite CLI application, SQLite Studio or any modern IDE (wiki), by using appropriate plugins.
REST API reference is available here
You may launch unit tests by running the following command:
npm test
- Mocha - test framework.
- mocha-junit-reporter - to make reports in JUnit style.
- Chai - BDD / TDD assertion library.
- chai-as-promised - supports assertion for Promises.
- sinon - makes standalone test spies, stubs and mocks.
- proxyquire - dependency injection for modules under testing.
Some modules, like db
(in Source/dal/db
) makes some action in the moment, when they are called by require(...)
at the first time (it might be system startup, for example).
To avoid such behaviour during testing, use noCallThru option of proxyquire
.
You may launch Integration tests by running the next command:
npm run integration
It will run the whole application in testing mode. Tests will call the different REST API endpoints of application with differnet arguments.
-
build (default) - concat and minify UI source files (JS);
--local - build the minified version of app for running on local machine;
--testable - for testing purposes on local machine;
--cloud - for running in the cloud (see config.prod.json);
By default (without any params) Grunt will build the minified version for cloud usage;
-
clean:cleanup - to remove downloaded libs, modules and log files;
You have a right to fork it, study it, change it, share it, blame it and use it if you're brave enough.