How rituraj2003/bitesize-backend works
BiteSize is a backend for developer micro-learning: a client authenticates, manages searchable code snippets, and reviews eligible flashcards; it can also request AI-generated explanations. The main API routes own database and AI calls, while authentication middleware verifies tokens and Prisma connects to PostgreSQL. The README documents PostgreSQL full-text search and spaced-repetition scheduling, and the sampled snippet routes show those operations. The optional AI microservice and in-process Gemini fallback are visible in source. The frontend and hosted database are documented external systems; unsampled schema details are not expanded here.
Main entry points: app.ts Express app · auth.routes.ts Auth routes · ai.routes.ts AI explain route · snippet.routes.ts Snippet and review routes
Components 13
API runtime
- HTTP server
src/server.ts - Express app
src/app.ts - Error handling
src/middleware/errorHandler.ts
Identity
- Auth routes
src/routes/auth.routes.ts - Token middleware
src/middleware/authMiddleware.ts - Password and JWT
src/utils/auth.ts
Learning features
- Snippet and review routes
src/routes/snippet.routes.ts - Prisma client
src/db/prisma.ts - PostgreSQL database
AI analysis
- AI explain route
src/routes/ai.routes.ts - AI microservice
services/ai-service/src/index.ts - Google Gemini
Other components
- Frontend client
Connections 20
- Frontend client → HTTP server: sends REST requests
- HTTP server → Express app: starts
- Express app → Auth routes: dispatches auth
- Express app → Snippet and review routes: dispatches learning
- Express app → AI explain route: dispatches AI
- Express app → Error handling: registers handler
- Auth routes → Prisma client: reads and writes users
- Auth routes → Password and JWT: hashes and signs
- Token middleware → Password and JWT: verifies tokens
- Auth routes → Token middleware: protects profile
- Snippet and review routes → Token middleware: protects endpoints
- Snippet and review routes → Prisma client: searches and updates snippets
- Prisma client → PostgreSQL database: queries
- AI explain route → Token middleware: protects endpoint
- AI explain route → AI microservice: forwards analysis
- AI explain route → Google Gemini: generates fallback analysis
- AI microservice → Google Gemini: generates analysis
- Auth routes → Error handling: forwards failures
- Snippet and review routes → Error handling: forwards failures
- AI explain route → Error handling: forwards failures