Skip to content

Latest commit

ย 

History

History
148 lines (101 loc) ยท 2.81 KB

File metadata and controls

148 lines (101 loc) ยท 2.81 KB

๐Ÿ› ๏ธ Commons API Master

Commons API Master is an Express.js + PostgreSQL backend that powers the Commons Master React frontend. It provides secure, filtered access to Canadian federal legislative data, including bill status, sessions, and machine-learned categories via uClassify.


๐Ÿ”— Live App

Frontend: https://commons-app.netlify.app
Backend: (deployed via Render, Railway, or local environment)


๐Ÿ“ฆ Features

  • ๐Ÿ“œ Fetch Canadian federal bills from LegisInfo
  • ๐Ÿง  Assign categories using uClassify API
  • ๐Ÿงฎ Filter by status (active/passed), session, house, category
  • ๐Ÿ”’ Secure login/registration via JWT
  • ๐Ÿ’พ PostgreSQL-backed storage
  • ๐ŸŒ RESTful API used by the Commons Master frontend

๐Ÿงญ API Endpoints

๐Ÿงช Bills

GET /api/bills

Query parameters:

  • status=active|passed
  • session=43-1
  • senateHouse=senate|commons
  • category=<uClassify category>
  • limit, offset
GET /api/bills/:id

Returns a single bill by its unique ID.


๐Ÿ—‚๏ธ Categories

GET /api/categories

Returns a list of all available categories.


๐Ÿ” Auth

POST /api/auth/register
POST /api/auth/login

Returns JWT on success.

Protected routes require:

Authorization: Bearer <token>

๐Ÿ› ๏ธ Tech Stack

  • Node.js + Express
  • PostgreSQL via pg
  • Sequelize ORM
  • JWT-based auth
  • CORS + Helmet + Rate Limiters
  • uClassify API for category classification

๐Ÿš€ Getting Started

1. Clone the Repo

git clone https://github.com/mxmitch/commons-api-master.git
cd commons-api-master
npm install

2. Configure Environment

Create a .env file in the root with:

PORT=5000
DATABASE_URL=postgres://<username>:<password>@<host>:<port>/<db>
JWT_SECRET=your_secret_key
UCLASSIFY_API_KEY=your_uclassify_api_key

3. Run Locally

npm run dev

๐Ÿงช Testing

Tests coming soon.


๐ŸŒ Deployment Notes

  • Works well on Render, Railway, or Heroku
  • Ensure the database is seeded before launch
  • Add environment variables in the deploy settings

๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ routes/           # billRoutes, authRoutes, categoryRoutes
โ”œโ”€โ”€ models/           # Sequelize models (Bill, User)
โ”œโ”€โ”€ middleware/       # Auth, rate limiting, etc.
โ”œโ”€โ”€ services/         # uClassify integration
โ””โ”€โ”€ index.js          # Entry point

๐Ÿ“ License

MIT โ€” see LICENSE


๐Ÿ™Œ Credits

Built by @mxmitch as part of the Commons Master project
Original legislative source: parl.ca/legisinfo
Classification powered by uClassify