Skip to content

Repository files navigation

X-Twitter GraphQL API 🚀

A modern, full-featured Twitter-like backend built with Node.js, Express, Prisma (MongoDB), GraphQL, and TypeScript.

Features ✨

  • 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.

Tech Stack 🛠️

  • Node.js / Express
  • TypeScript
  • Prisma (MongoDB)
  • GraphQL (Apollo Server)
  • Zod (validation)
  • Jest (testing)
  • Pino (logging)
  • Clerk (authentication)

Project Structure 🗂️

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

Getting Started 🚦

  1. Install dependencies
    npm install
  2. Configure environment
    • Copy .env.example to .env and set your variables (MongoDB, Clerk, etc.)
  3. Generate Prisma Client
    npx prisma generate
  4. Seed the database (optional)
    npm run seed
  5. Start the server
    npm run dev
  6. Run tests
    npm test

Scripts 📝

  • npm run dev — Start in watch mode
  • npm run build — Compile TypeScript
  • npm start — Run compiled server
  • npm run seed — Seed the database
  • npm test — Run tests
  • npm run lint — Lint and fix
  • npm run format — Format code

GraphQL 📦

  • Schemas are in src/graphql/schemas/
  • Resolvers are in src/graphql/resolvers/
  • Context is in src/graphql/context.ts

Prisma 🗄️

  • Schema: src/prisma/schema.prisma
  • Generated client: src/types/prisma/

Testing 🧪

  • Tests are in __tests__/
  • Run with npm test

Author ✍️

Mostafa Hasan


MIT License 🪪

About

A modern, full-featured Twitter-like backend built with Node.js, Express, Prisma (MongoDB), GraphQL, and TypeScript. (Clerk intergration)

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages