The Life Lessons backend provides a RESTful API for managing users, lessons, and subscriptions. It handles authentication, authorization, data persistence, and payment integration.
- Node.js (v20)
- Express – lightweight web framework
- Prisma – type‑safe ORM for PostgreSQL
- Passport / JWT – authentication with email/password and Google OAuth (Better Auth)
- Stripe – subscription and payment handling
- dotenv – environment configuration
- Jest & Supertest – unit & integration testing
- User Management – register, login, profile updates
- Lesson CRUD – create, read, update, delete lessons; public/private visibility
- Favorites – bookmark lessons for quick access
- Subscription – free vs premium tier enforcement via Stripe webhooks
- Role‑Based Access Control – admin, premium, and regular user permissions
- Rate Limiting & Validation – secure endpoints with
express-rate-limitandjoi
- Install dependencies
cd backend npm install - Configure environment – copy
.env.exampleto.envand fill in values:DATABASE_URLJWT_SECRETSTRIPE_SECRET_KEYGOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET
- Database migration
npx prisma migrate dev --name init
- Run the server
The API will be available at
npm run dev
http://localhost:4000/api.
npm testRuns the Jest test suite with coverage reports.
- Build Docker image:
FROM node:20-alpine WORKDIR /app COPY . . RUN npm ci --omit=dev CMD ["node", "dist/index.js"]
- Push to your container registry and deploy to your cloud provider (e.g., Railway, Render, or Azure App Service).
- Fork the repository
- Create a feature branch
- Submit a pull request with clear description and tests
MIT © Life Lessons Team