A modern, full-featured Twitter-like backend built with Node.js, Express, Prisma (MongoDB), GraphQL, and TypeScript.
- User Authentication 🔐: Secure registration, login, and session management (Clerk integration).
- GraphQL API 🕸️: Flexible, strongly-typed API for all core features.
- Posts 📝: Create, update, delete, comment, repost, and fetch posts.
- Likes & Saves ❤️🔖: Like/unlike and save/unsave posts.
- Follows 👥: Follow/unfollow users, get followers/following lists.
- Feed 📰: Personalized feed showing posts from followed users.
- Validation ✅: All input validated with Zod.
- Testing 🧪: Jest-based unit and integration tests.
- Type Safety 🛡️: End-to-end TypeScript, strict types, and codegen for GraphQL.
- Logging 📋: Pino for structured logging.
- Security 🛡️: Helmet, CORS, and best practices.
- Node.js / Express
- TypeScript
- Prisma (MongoDB)
- GraphQL (Apollo Server)
- Zod (validation)
- Jest (testing)
- Pino (logging)
- Clerk (authentication)
src/
configs/ # App, DB, GraphQL configs
graphql/ # Schemas, resolvers, context
middlewares/ # Express/GraphQL middlewares
prisma/ # Prisma schema
routes/ # REST routes (if any)
services/ # Business logic
types/ # TypeScript types, Prisma types
utils/ # Utilities (logger, error, etc.)
validators/ # Zod validation schemas
seed.ts # DB seeding script
index.ts # App entry point
__tests__/ # Unit/integration tests
- Install dependencies
npm install
- Configure environment
- Copy
.env.exampleto.envand set your variables (MongoDB, Clerk, etc.)
- Copy
- Generate Prisma Client
npx prisma generate
- Seed the database (optional)
npm run seed
- Start the server
npm run dev
- Run tests
npm test
npm run dev— Start in watch modenpm run build— Compile TypeScriptnpm start— Run compiled servernpm run seed— Seed the databasenpm test— Run testsnpm run lint— Lint and fixnpm run format— Format code
- Schemas are in
src/graphql/schemas/ - Resolvers are in
src/graphql/resolvers/ - Context is in
src/graphql/context.ts
- Schema:
src/prisma/schema.prisma - Generated client:
src/types/prisma/
- Tests are in
__tests__/ - Run with
npm test
Mostafa Hasan
MIT License 🪪