A comprehensive Point of Sale and Financial Management System for Study Association GEWIS
SudoSOS Backend is a comprehensive Point of Sale (POS) and financial management system designed specifically for Study Association GEWIS. It provides a robust API for managing transactions, user accounts, products, payments, and financial operations within the association.
Before you begin, ensure you have the following installed:
- Node.js 22+ - Download here
- Git - Download here
- OpenSSL - Usually pre-installed on most systems
- Database (choose one):
- SQLite (default for development) - No additional setup required
- MariaDB/MySQL - For production environments
- SQLite Viewer (optional) - DB Browser for SQLite or DataGrip
# Clone the repository
git clone https://github.com/GEWIS/sudosos-backend.git
cd sudosos-backend
# Install dependencies
npm install
# Copy environment configuration
cp .env.example .env# Generate RSA private key for JWT authentication
openssl genrsa -out config/jwt.key 2048Verify the key was created correctly:
# Should start with -----BEGIN RSA PRIVATE KEY-----
head -1 config/jwt.key# Generate swagger specification
npm run swagger
# Build the project
npm run build
# Run tests to verify everything works
npm run test[!WARNING] > IMPORTANT: Clear your database before initializing!
- For SQLite: Delete the
local.sqlitefile if it exists- For MariaDB: Drop all tables in your database
Quick Start for Development:
# For SQLite (recommended for development)
npm run init:schema# OR for MariaDB/MySQL
npm run init:migrateThis command will:
- Create the database schema
- Seed it with initial data
- Run maintenance tasks
- Set up default roles and permissions
# Start the development server with hot reload
npm run watchThe server will be available at http://localhost:3000
Visit http://localhost:3000/api-docs to access the Swagger UI for API documentation.
- Use the
/authentication/mockendpoint with a valid userId to get a JWT token - In Swagger UI, simply enter the JWT token returned by the
/authentication/mockendpoint - Use this token to authenticate API requests
For deposit functionality, configure Stripe with restricted keys only:
Required Environment Variables:
STRIPE_PUBLIC_KEY- Your Stripe publishable key (safe for frontend)STRIPE_PRIVATE_KEY- Your Stripe restricted secret key (see permissions below)STRIPE_WEBHOOK_SECRET- Webhook endpoint secret for validationSTRIPE_RETURN_URL- URL to redirect users after payment
Required Stripe Permissions: When creating your restricted API key, grant only these permissions:
- β "Write access on all webhooks"
- β "Write access on payment intents"
# Add these to your .env file
STRIPE_PUBLIC_KEY=pk_test_your_publishable_key_here
STRIPE_PRIVATE_KEY=sk_test_your_restricted_secret_key_here
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret_here
STRIPE_RETURN_URL=https://your-domain.com/return| Script | Description |
|---|---|
npm run build |
Compile TypeScript to JavaScript |
npm run watch |
Start development server with hot reload |
npm run test |
Run all tests |
npm run test-ci |
Run tests with schema setup |
npm run test-ci-migrate |
Run tests with migration setup |
npm run coverage |
Generate test coverage report |
npm run lint |
Run ESLint |
npm run lint-fix |
Fix ESLint issues automatically |
npm run schema |
Create/update database schema (SQLite) |
npm run migrate |
Run database migrations (MariaDB/MySQL) |
npm run seed |
Seed database with initial data |
npm run init:schema |
Complete setup for SQLite development |
npm run init:migrate |
Complete setup for MariaDB/MySQL development |
npm run maintenance |
Run maintenance tasks |
npm run cron |
Start cron job scheduler |
npm run serve |
Start production server |
- Development:
http://localhost:3000/api-docs - Production:
https://sudosos.gewis.nl/api/api-docs/
For detailed documentation, API references, and examples, visit the SudoSOS documentation site here:
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes
- Run tests:
npm run test, ornpm run test-file <path-to-test-file>to run a single test file - Run linting:
npm run lint-fix - Commit your changes:
git commit -m "feat: add your feature"(follow the conventional commits format) - Push to your branch:
git push origin feature/your-feature-name - Create a Pull Request
For easy ESLint integration:
- Go to Preferences β Languages & Frameworks β JavaScript β Code Quality Tools β ESLint
- Check "Run ESLint --fix on save"
- Apply changes
This project is licensed under the GNU Affero General Public License v3.0 or later. See the LICENSE file for details.
This project exists thanks to all the people who contribute code.
Made with β€οΈ by Study Association GEWIS
