Machat Server is a backend designed for a real-time chat platform. It is built using modern technologies like TypeScript, Prisma, and GraphQL, ensuring scalability, performance, and developer productivity.
Frontend source: https://github.com/moustaxx/machat
- Supports real-time communication between users using GraphQL subscriptions.
- Efficiently handles message creation and delivery.
- User registration and login with secure password hashing using Argon2.
- Session management with cookies and secure sessions.
- Active status tracking for users with automatic status updates after inactivity.
- Create and manage group conversations.
- Add or remove participants dynamically.
- Enforce access control to ensure only authorized users can interact with conversations.
- Tracks the last read message for each user in a conversation.
- Provides a seamless experience for users to resume conversations.
- Fully typed GraphQL API using TypeGraphQL.
- Supports queries, mutations, and subscriptions for all core functionalities.
- PostgreSQL database with Prisma ORM for efficient data modeling and querying.
- Schema migrations and type-safe database access.
- Comprehensive unit and integration tests using Jest.
- Mocked PubSub for testing real-time features.
- Built with TypeScript for type safety and better developer experience.
- Modular architecture for easy maintenance and scalability.
- Includes ESLint for code quality and consistency.
- TypeScript: Strongly typed programming language for better code quality.
- Prisma: ORM for database management and type-safe queries.
- GraphQL: API query language for efficient data fetching.
- Fastify: High-performance web framework for Node.js.
- Jest: Testing framework for reliable and maintainable tests.
- Node.js (v16 or higher)
- PostgreSQL database
pnpmpackage manager
-
Clone the repository:
git clone https://github.com/moustaxx/machat-server.git cd machat-server -
Install dependencies:
pnpm install
-
Set up environment variables: Create a
.envfile in the root directory and configure the following:DATABASE_URL=your_database_url SESSION_SECRET=your_session_secret SESSION_SALT=your_session_salt COOKIE_TTL=3600 -
Push the database schema:
pnpm prisma db push
-
Start the server:
pnpm dev
Run the test suite using Jest:
pnpm test