A fullstack application that provides a user-friendly interface to search the Office of Foreign Assets Control (OFAC) sanctions lists, powered by the OpenSanctions API.
This project consists of two main components:
- Backend: Node.js/Express API server that serves as a proxy to the OpenSanctions API
- Frontend: React application with a modern UI built with TypeScript, Vite, and TailwindCSS
- Node.js (v18 or higher)
- npm or yarn
- OpenSanctions API key (Get one here)
-
Navigate to the server directory:
cd server -
Install dependencies:
npm install
-
Create a .env file based on the sample:
cp .env.sample .env
-
Add your OpenSanctions API key to the .env file:
OPENSANCTIONS_API_KEY="your_api_key_here" CACHE_TTL=600 -
Start the development server:
npm run dev
The server will start on port 5000 (or the port specified in the PORT environment variable).
-
Navigate to the client directory:
cd client -
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser and navigate to the URL shown in your terminal (typically http://localhost:5173)
cd server
npm install --productionThen use a process manager like PM2 to run the server in production.
cd client
npm run buildThis will generate a dist directory with optimized static files that can be deployed to any static hosting service.
The application follows a client-server architecture:
- Frontend: React SPA that communicates with the backend API
- Backend: Express.js server that proxies requests to the OpenSanctions API
- Node.js: JavaScript runtime
- Express: Web server framework
- Axios: HTTP client for API requests
- Node-Cache: In-memory caching to reduce API calls
- Dotenv: Environment variable management
GET /api/sanctions/search: Search sanctions- Query parameters:
query: The search term (required)type: Filter by entity type (all,individuals,entities)limit: Number of results per page (default: 10)offset: Pagination offset (default: 0)
- Query parameters:
The backend implements a caching mechanism using node-cache to reduce the number of calls to the OpenSanctions API and improve performance:
- Cache TTL (Time To Live) is configurable via the
CACHE_TTLenvironment variable (default: 600 seconds) - Cache keys are generated based on search parameters (query, type, limit, offset)
- React 19: UI library
- TypeScript: Type-safe JavaScript
- Vite: Build tool and development server
- TailwindCSS: Utility-first CSS framework
- React Query: Data fetching and state management
- Heroicons: SVG icon collection
- Axios: HTTP client
- App: Main application component that manages state and renders the UI
- SearchBar: Handles search input and filters
- ResultsList: Displays search results
- Pagination: Handles pagination of results
- React Query is used for server state management (caching, refetching)
- React's useState for UI state (search query, filters, pagination)
- Responsive design that works on mobile and desktop
- Dark/light mode toggle
- Pagination for large result sets
- Filter by entity type (individuals/organizations)
- Caching of search results
This project is licensed under the MIT License.