chore: project context update
This commit is contained in:
+20
-17
@@ -2,7 +2,7 @@
|
||||
|
||||
## What this project is
|
||||
|
||||
A Go-based Backend for Frontend (BFF) API server for [prabhupadasays.org](https://prabhupadasays.org). It sits between the Next.js frontend (and future mobile apps) and the data layer — aggregating content from MongoDB, user data from PostgreSQL, search from Meilisearch, caching from DragonflyDB, and media from S3 into a unified API surface.
|
||||
A Go-based Backend for Frontend (BFF) API server for [prabhupadasays.org](https://prabhupadasays.org). It is the **sole data provider** for the production Next.js frontend (and future mobile apps). The knowledgebase frontend has removed all direct Prisma, MongoDB, and S3 dependencies — everything flows through this BFF. It aggregates content from MongoDB, user data from PostgreSQL, search from Meilisearch, caching from DragonflyDB, and media from S3 into a unified API surface.
|
||||
|
||||
---
|
||||
|
||||
@@ -23,16 +23,18 @@ A Go-based Backend for Frontend (BFF) API server for [prabhupadasays.org](https:
|
||||
|
||||
## Architecture
|
||||
|
||||
> **Note:** The BFF is now the ONLY data path for the frontend. The knowledgebase has no Prisma bypass, no direct MongoDB connections, and no direct S3 access. All content is served exclusively through this API.
|
||||
|
||||
```
|
||||
┌──────────────┐ ┌─────────────────────────────────────────┐
|
||||
│ Next.js │────▶│ Go BFF API (:8080) │
|
||||
│ (frontend) │ │ │
|
||||
├──────────────┤ │ cmd/api/main.go → server.go → handlers │
|
||||
│ Mobile Apps │────▶│ │
|
||||
│ (future) │ │ ┌──────────┐ ┌───────────────┐ │
|
||||
└──────────────┘ │ │ Handlers │──│ Services │ │
|
||||
│ └──────────┘ └───────┬───────┘ │
|
||||
│ │ │
|
||||
│ (sole data │ │ cmd/api/main.go → server.go → handlers │
|
||||
│ path ↑) │ │ │
|
||||
├──────────────┤ │ ┌──────────┐ ┌───────────────┐ │
|
||||
│ Mobile Apps │────▶│ │ Handlers │──│ Services │ │
|
||||
│ (future) │ │ └──────────┘ └───────┬───────┘ │
|
||||
└──────────────┘ │ │ │
|
||||
│ ┌─────────────────────┼──────────┐ │
|
||||
│ ▼ ▼ ▼ ▼ ▼ │
|
||||
│ Mongo Postgres Meili S3 Dragonfly│
|
||||
@@ -119,7 +121,7 @@ All routes are prefixed with `/api/v1`.
|
||||
|
||||
| Method | Route | Description |
|
||||
|--------|-------|-------------|
|
||||
| `GET` | `/api/v1/books` | List all books (lightweight summaries) |
|
||||
| `GET` | `/api/v1/books` | List all books with full metadata (chapters, cantos, parts, volumes, etc.) |
|
||||
| `GET` | `/api/v1/books/sb` | SB book metadata |
|
||||
| `GET` | `/api/v1/books/sb/{canto}` | SB canto chapter listing |
|
||||
| `GET` | `/api/v1/books/sb/{canto}/{chapter}` | SB chapter verse index |
|
||||
@@ -257,7 +259,7 @@ All routes are prefixed with `/api/v1`.
|
||||
| `Essay` | `essays` | 23 standalone essays |
|
||||
| `GlossaryEntry` | `glossary` | 2,749 Sanskrit/Vedic terms |
|
||||
| `Disciple` | `disciples` | 4,747 initiated disciples |
|
||||
| `Transcription` | `transcriptions` | 3,787 lectures, conversations, philosophy discussions, SB dictations |
|
||||
| `Transcription` | `transcriptions` | 3,787 lectures, conversations, philosophy discussions, SB dictations — with audio URLs |
|
||||
|
||||
### User Models (PostgreSQL)
|
||||
|
||||
@@ -391,23 +393,24 @@ make tidy
|
||||
|
||||
## Relationship to Other Projects
|
||||
|
||||
| Project | Path | Description |
|
||||
| Project | Path | Relationship |
|
||||
|---------|------|-------------|
|
||||
| **knowledgebase** | `../knowledgebase/` | Next.js frontend — consumes this BFF's API |
|
||||
| **knowledgebase** | `../knowledgebase/` | Next.js frontend — **depends entirely on this BFF** for all data (books, letters, essays, glossary, disciples, journals, magazines, other documents, transcriptions). Has NO direct database (Prisma/MongoDB) or S3 connections. The BFF must be running for the frontend to function. |
|
||||
| **extractor** | `../extractor/` | Python/TS extraction scripts + raw data + seed scripts |
|
||||
| **spsays-bff** | `./` (this project) | Go BFF API server |
|
||||
| **spsays-bff** | `./` (this project) | Go BFF API server — single source of truth for all content served to clients |
|
||||
|
||||
The frontend currently fetches directly from MongoDB via Prisma. The migration plan:
|
||||
1. ✅ Done — BFF API routes matching current Prisma queries
|
||||
2. Add Meilisearch indexing + search endpoints
|
||||
3. Add PostgreSQL for user features (auth, bookmarks, collections, mentions)
|
||||
4. Switch frontend from Prisma to BFF API calls
|
||||
Migration status (Prisma → BFF):
|
||||
1. ✅ Done — BFF API routes matching all former Prisma queries
|
||||
2. ✅ Done — Frontend migrated from Prisma to BFF API calls (Prisma, MongoDB driver, and S3 SDK removed from knowledgebase)
|
||||
3. Add Meilisearch indexing + search endpoints
|
||||
4. Add PostgreSQL for user features (auth, bookmarks, collections, mentions)
|
||||
5. Add mobile app support (same API, push notifications)
|
||||
|
||||
---
|
||||
|
||||
## Design Principles
|
||||
|
||||
- **Single source of truth** — the BFF is the sole data provider for all content consumed by the frontend and future mobile apps. No client should bypass the BFF to access MongoDB, S3, or any other backing service directly.
|
||||
- **`internal/`** — private to this module (handlers, services, repositories, middleware, models, config)
|
||||
- **`pkg/`** — public packages that could be imported by other projects (response helpers, validators, push sender)
|
||||
- **Repository pattern** — data access isolated behind interfaces (easy to swap Mongo ↔ Postgres, mock for tests)
|
||||
|
||||
Reference in New Issue
Block a user