Text Review is a web application that allows users to analyze and highlight official texts. The aim is to promote a better understanding and detailed analysis of texts.
- Collection of texts from official sources
- Creation of text analyses
- Highlighting of text sections within an analysis
- GraphQL API (Code-First)
- Frontend: NextJS, React, TypeScript, Tailwind CSS
- Backend: NextJS, GraphQL (Pothos & Apollo/Yoga), Prisma ORM
- Database: PostgreSQL
- Data Validation: Zod (with
zod-prisma-types) - State Management: Apollo Client, Zustand
- Testing: Jest, React Testing Library
- Logging: Winston
- NodeJS
- npm
- PostgreSQL
I follow a strict Single Source of Truth (SSoT) approach using Prisma and a layered architecture to ensure type safety and maintainability.
All types are derived automatically to avoid manual duplication (DRY):
- Source of Truth:
schema.prisma(Database Models) - Database Layer:
prisma generatecreates the Prisma Client & Types. - Validation Layer:
prisma-zod-generatorcreates Zod schemas from Prisma models. - API Layer:
Pothosgenerates the GraphQL Schema directly from Prisma Types. - Frontend Layer:
GraphQL Code Generatorcreates typed React Hooks (useQuery) from frontend queries.
We separate logic into three distinct layers to support both GraphQL and Server Components (RSC).
| Layer | Responsibility | Data Flow Rules |
|---|---|---|
Resolver (*.resolver.ts) |
Handles GraphQL specific context (args, info). | Passes the generated PothosQuery object (includes, selects) to the service. |
Service (*.service.ts) |
Contains purely business logic. | Queries: "Transparent" flow. Must pass Prisma args through. DO NOT strictly validate/strip outputs with Zod here, or GraphQL relations will break. Mutations: Strict Zod validation for Inputs. |
Infrastructure (*.infrastructure.ts) |
Direct database access. | Executes prisma.model.find.... Returns implicit types inferred by Prisma to preserve relations. |
- app Pages and App Router
- app/api/graphql GraphQL Endpoint
- components Reusable UI Components
- lib Core configuration (Prisma, Builder, Logger)
- prisma Database Schema and Migrations
- seeds Scripts to seed a Database
- services Domain logic organized by feature
- services/[feature]/[action].resolver.ts (GraphQL Entry)
- services/[feature]/[action].service.ts (Business Logic)
- services/[feature]/[action].infrastructure.ts (DB Access)
- types TypeScript Data Structures
-
Clone Repository
git clone <repository-url> cd text-review
-
Install Dependencies
npm install
-
Setup Environment Variables Create an
.envfile based on.env.example. -
Generate Client & Types Important: Run this whenever
schema.prismachanges.npx prisma generate
-
Run Application
npm run dev
The application is accessible at http://localhost:3000. GraphQL Playground is available at http://localhost:3000/api/graphql.
- error Critical errors, e.g. failed database connection, API errors
- warn Important warnings, e.g. old APIs usage, high resource usage
- info General information, e.g. successful API requests, user login
- http Incoming http requests, e.g. http method and status code
- verbose Detailed information, e.g. process steps
- debug Developer information, e.g. variable values, function steps
- silly Most detailed information, e.g. raw data