A peer-to-peer money exchange web app for 1337 students. The idea is simple: if you have physical cash but need a CIH bank transfer (or vice versa), this platform matches you with a student on your campus who needs the exact opposite.
Finding someone to do a quick cash-to-bank exchange on campus usually means asking around or posting in Discord server. This app automates the process with a matching engine so you don't have to look for people manually.
- OAuth Authentication: Secure login using the 42 Intra API. Users are restricted to their primary campus automatically.
- Smart Matching Engine: A transaction-backed matching engine that automatically pairs complementary orders (e.g., matching a "Need Cash/Have CIH" order with a "Need CIH/Have Cash" order).
- Partial Fulfillment: Large orders can automatically be fulfilled by multiple smaller orders.
- Live Dashboard: A clean HTML/JS dashboard with real-time browser notifications for new matches.
- Discord Integration: One-click copy tool for sending Discord DMs to your matched counterpart to arrange the physical exchange.
- Node.js (v16+ recommended)
- PostgreSQL (v12+)
- 42 Intra API Credentials
Create a .env file in the root directory and configure the following variables:
PORT=3000
DATABASE_URL=postgres://user:password@localhost:5432/exchange_db
# 42 Intra API Credentials
UID=your_42_app_client_id
SECRET=your_42_app_client_secret
BASE_URL=http://localhost:3000
# Auth
JWT_SECRET=your_secure_random_string
# Environment ('dev' enables the /auth/dev-login route for testing)
NODE_ENV=dev-
Install Dependencies:
npm install
-
Initialize Database: Run the SQL script located in
src/config/init.sqlagainst your PostgreSQL database to create the necessary tables, types, and constraints.psql -U postgres -d exchange_db -f src/config/init.sql
or use it to create tables in your preferred database client.
-
Run the Application:
npm run start # or for development with auto-restart: node --watch src/server.jsThe app will be running at
http://localhost:3000.
When NODE_ENV is set to dev, you can use the /auth/dev-login endpoint to bypass the 42 OAuth flow and log in as test users.
curl -X POST http://localhost:3000/auth/dev-login -H "Content-Type: application/json" -d '{"username": "alice", "campus": 16}'Contributions are always welcome! Whether it's fixing bugs, adding new payment methods (like Attijari or PayPal), or improving the UI, feel free to jump in.
If you are modifying the backend:
- The matching engine (
src/services/matchService.js) handles concurrency using PostgreSQL transactions andFOR UPDATE SKIP LOCKED. - Make sure to test your code for race conditions, especially in the
/confirmand/cancelroutes, as this handles financial states.
- Fork the repository
- Create your feature branch (
git checkout -b feature/cool-new-feature) - Commit your changes
- Push to the branch (
git push origin feature/cool-new-feature) - Open a Pull Request
This project is intended for the internal use of 1337 students.