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
- pnpm - Installation guide (enabled via
corepack enableon Node.js 16.13+) - 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
pnpm 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
pnpm swagger
# Build the project
pnpm build
# Run tests to verify everything works
pnpm 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)
pnpm init:schema# OR for MariaDB/MySQL
pnpm 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
pnpm 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 |
|---|---|
pnpm build |
Compile TypeScript to JavaScript |
pnpm watch |
Start development server with hot reload |
pnpm test |
Run all tests |
pnpm test-ci |
Run tests with schema setup |
pnpm test-ci-migrate |
Run tests with migration setup |
pnpm coverage |
Generate test coverage report |
pnpm lint |
Run ESLint |
pnpm lint-fix |
Fix ESLint issues automatically |
pnpm schema |
Create/update database schema (SQLite) |
pnpm migrate |
Run database migrations (MariaDB/MySQL) |
pnpm seed |
Seed database with initial data |
pnpm init:schema |
Complete setup for SQLite development |
pnpm init:migrate |
Complete setup for MariaDB/MySQL development |
pnpm maintenance |
Run maintenance tasks |
pnpm cron |
Start cron job scheduler |
pnpm 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:
pnpm test, orpnpm test-file <path-to-test-file>to run a single test file - Run linting:
pnpm 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
