Skip to content

bettersg/SchemesSG_v3

Repository files navigation

Schemes Reimagined

License: MIT Website Python 3.10 Node Contributions Welcome better.sg

Schemesv3 is a modern reimagining of Singapore's social support system search, built using Firebase Cloud Functions and Next.js. The system leverages Azure OpenAI's GPT models to provide intelligent scheme recommendations and natural language interactions.

The core functionality is powered by a sophisticated search system that combines:

  • Natural Language Search: Users can describe their situation in everyday language and receive relevant scheme recommendations
  • Intelligent Chat Interface: Contextual conversations powered by Azure OpenAI to help users understand scheme eligibility and application processes
  • Vector-Based Scheme Matching: FAISS similarity search to match user situations with the most relevant support schemes
  • Serverless Architecture: Firebase Cloud Functions with Python runtime for scalable, maintainable backend operations
  • Modern Web Interface: Responsive Next.js frontend with TypeScript for a seamless user experience

Prerequisites

Ensure you have the following installed:

  • Node.js (v14 or later): Download Node.js
  • npm (v6 or later): Comes with Node.js
  • Python (v3.10): Download Python
  • Firebase CLI: Install globally using npm install -g firebase-tools
  • Docker: Install Docker
  • Docker Compose: Included with Docker Desktop

Key branches

  • main branch contains frontend and backend code - push to Schemes prod
  • stg branch contains frontend and backend code - push to Schemes dev
  • telegram_bot branch contains telegram bot code - push to GCP
  • dataset-workflow branch contains files to update dataset and do webscraping adhoc
  • v3-archive-021224 contains mix of old and prototype scheemes code for reference

Required Files Setup

  1. Environment Variables and Model Files Download the following required files from Google Drive (contact maintainers for access):
  • .env file → place in backend/functions/
  • schemesv2-torch-allmpp-model/ → place in backend/functions/ml_logic/
  • schemesv2-torch-allmpp-tokenizer/ → place in backend/functions/ml_logic/
  • Required .npy files → place in backend/functions/ml_logic/
  • Required .faiss files → place in backend/functions/ml_logic/

Alternatively, you can build the model files yourself using model-creation-transformer-faiss.ipynb

Note: The .env file contains sensitive configuration for Azure OpenAI services and should never be committed to version control.

Project Structure

The project consists of two main components:

  1. Frontend: Next.js application with TypeScript

  2. Backend: Firebase Functions with Python 3.10 runtime

Development Workflow

  1. Frontend changes:

    • Branch from stg
    • Make changes
    • Test locally
    • Create PR to stg
    • When PR is merged, github action .github/workflows/firebase-hosting-staging.yml will be triggered to deploy to firebase hosting in Schemes dev
    • Then create PR to merge stg into main
    • When PR is merged, github action .github/workflows/firebase-hosting-production.yml will be triggered to deploy to firebase hosting in Schemes prod
  2. Backend changes:

    • Test using Firebase emulator
    • When stg branch is pushed, the github action .github/workflows/deploy_functions_dev.yml will be triggered to deploy to Schemes dev
    • When main branch is pushed, the github action .github/workflows/deploy_functions_prod.yml will be triggered to deploy to Schemes prod

Note: For local frontend development to work, you must have the backend running via Docker. Please refer to backend/README.md for Docker setup and running instructions.

Contributing

We welcome contributions from the community! Here's how you can help:

  1. Report Issues: Create issues for bugs or feature requests
  2. Submit Pull Requests:
    • Fork the repository
    • Create a feature branch from stg
    • Make your changes
    • Submit a pull request to stg
    • Once approved and merged to stg, create another PR to merge into main

Please ensure your PR:

  • Follows the existing code style
  • Includes appropriate tests
  • Updates documentation as needed
  • Describes the changes made

Community

  • Website: https://schemes.sg
  • Issues: Please report bugs and feature requests through GitHub issues
  • Discussions: Feel free to start discussions in the GitHub Discussions tab
  • Contact: For other inquiries, reach out to the maintainers through GitHub

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with support from better.sg
  • Powered by Azure OpenAI
  • Special thanks to all contributors and maintainers