A production-ready REST API that estimates a student's chance of admission to universities. Built with NestJS, MongoDB (Mongoose), and OpenAI, it handles user accounts, multi-provider authentication, AI-driven admission predictions, and Stripe-based subscription billing.
- Authentication — email/password with email verification, JWT access & refresh tokens (httpOnly cookies), password reset, plus Google, Microsoft, and Facebook OAuth.
- Predictions — students submit their academic profile (exams, GPA, activities, honors) and receive an AI-generated admission chance via OpenAI.
- Universities — CRUD catalog of universities used as prediction targets.
- Plans & Subscriptions — configurable subscription plans and per-user subscription tracking.
- Payments — Stripe Checkout sessions and webhook handling for subscription lifecycle.
- Users — user management and profiles.
- Global request throttling,
class-validatorDTO validation, and CORS with credentials.
| Concern | Technology |
|---|---|
| Framework | NestJS 11 |
| Database | MongoDB via Mongoose |
| Auth | Passport (JWT, Google, Microsoft, Facebook) |
| AI | OpenAI |
| Payments | Stripe |
| Nodemailer / Brevo (SendinBlue) / SendGrid | |
| Language | TypeScript |
| Testing | Jest |
- Node.js 20+
- MongoDB (local or Atlas)
- Accounts/keys for OpenAI, Stripe, and any OAuth providers you enable
npm installCreate a .env file in the project root:
NODE_ENV=development
PORT=5505
ALLOWED_ORIGINS=http://localhost:5173
# Database
MONGODB_URI=mongodb://localhost:27017/lets-cook
# JWT
ACCESS_TOKEN_SECRET=your-access-secret
ACCESS_TOKEN_EXPIRE_TIME=7d
REFRESH_TOKEN_SECRET=your-refresh-secret
REFRESH_TOKEN_EXPIRE_TIME=7d
# Email
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=you@example.com
EMAIL_PASSWORD=your-email-password
EMAIL_FROM=you@example.com
BREVO_API_KEY=your-brevo-key
# Google OAuth
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CALLBACK_URL=http://localhost:5500/v1/auth/google/callback
# Microsoft OAuth
MICROSOFT_CLIENT_ID=
MICROSOFT_CLIENT_SECRET=
MICROSOFT_CALLBACK_URL=http://localhost:5500/v1/auth/microsoft/callback
# Facebook OAuth
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_CALLBACK_URL=http://localhost:5500/v1/auth/facebook/callback
# OpenAI
OPENAI_API_KEY=
# Stripe
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=# development (watch mode)
npm run start:dev
# production build
npm run build
npm run start:prodThe API listens on PORT (default 5505) and is served under the global prefix /v1.
All routes are prefixed with /v1.
| Method | Path | Description |
|---|---|---|
| POST | /register |
Register a new user |
| POST | /login |
Log in, issue tokens |
| POST | /verify-email |
Verify email address |
| POST | /refresh |
Refresh access token |
| POST | /logout |
Log out |
| GET | /profile |
Current user profile |
| POST | /forgot-password |
Request password reset |
| POST | /reset-password |
Reset password |
| GET | /google, /google/callback |
Google OAuth |
| GET | /microsoft, /microsoft/callback |
Microsoft OAuth |
| GET | /facebook, /facebook/callback |
Facebook OAuth |
| Method | Path | Description |
|---|---|---|
| POST | / |
Create a prediction profile |
| POST | /:id/predict |
Run the AI prediction |
| GET | /me |
Current user's predictions |
| GET | /user/:userId |
Predictions for a user |
| GET | /:id |
Get a prediction |
| DELETE | /:id |
Delete a prediction |
Full CRUD: POST /, GET /, GET /:id, PUT /:id, DELETE /:id.
POST /, GET /, GET /:id, PATCH /:id.
POST /, GET /, GET /:id, PATCH /:id, POST /:id/inactivate, DELETE /:id.
GET /my — current user's subscription.
| Method | Path | Description |
|---|---|---|
| POST | /create-checkout-session |
Create a Stripe Checkout session |
| POST | /webhook |
Stripe webhook receiver |
| GET | /my |
Current user's payments |
src/
├── auth/ # Authentication, OAuth strategies, guards, JWT
├── users/ # User accounts
├── university/ # University catalog
├── predictions/ # Admission-chance predictions (OpenAI)
├── plans/ # Subscription plans
├── subscribtions/ # User subscriptions
├── payments/ # Stripe payments & webhooks
├── common/ # Shared base repository, decorators, guards, services
├── config/ # Environment validation (envalid)
└── main.ts # Bootstrap
Additional module-level documentation lives in the docs/ directory.
npm test # unit tests
npm run test:e2e # end-to-end tests
npm run test:cov # coverageBuild and run with the production compose file (API + MongoDB):
docker compose -f docker-compose-prod.yml up --buildSee docs/DOCKER_DEPLOY.md for deployment details.
UNLICENSED — private project.