https://github.com/samioksanen/chat-app
Chat App
https://github.com/samioksanen/chat-app
docker-compose graphql hasura passport react
Last synced: 2 months ago
JSON representation
Chat App
- Host: GitHub
- URL: https://github.com/samioksanen/chat-app
- Owner: SamiOksanen
- License: mit
- Created: 2022-07-29T20:47:08.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-09-24T23:08:29.000Z (9 months ago)
- Last Synced: 2025-10-27T14:45:52.936Z (8 months ago)
- Topics: docker-compose, graphql, hasura, passport, react
- Language: TypeScript
- Homepage:
- Size: 2.59 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 54
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Chat App











Application for having conversations with other users individually and in groups. Uses React and Ant Design for the user interface, Postgres as the database, Node.js Passport for authentication and Hasura GraphQL engine for connecting everything together. Database migrations are handled with Hasura migrations. This is a hobby project I have used for trying out things like Hasura, Ant Design and developing with Claude Code. **This project is not meant for any real production use.**
๐ง In Progress ๐ง
## Setup ๐ช
### Install:
- Node.js
- Docker
- Hasura CLI
### Install dependencies
Install root dependencies (ESLint, Prettier, shared tooling) and service-specific dependencies
```bash
npm i
```
### Required environment variables
- Add a `.env.development.local`, `.env.test.local` and `.env.production.local` files at the `chat-app-auth`, `chat-app-front` and `chat-app-graphql-engine` directories of the repo, by copying the `.env.development.example`, `.env.test.example` and `.env.production.example` files.
- Add a `.env.local` file at the `chat-app-db` directory of the repo, by copying the `.env.example` file.
- Set values to the environment variables in the `.env` files.
## Run the app in development mode ๐
```bash
npm run start
```
### Cleanup in development mode ๐งน
```bash
npm run stop
```
## Run the app in production mode ๐
```bash
npm run start:prod
```
### Cleanup in production mode ๐งน
```bash
npm run stop:prod
```
## Code Quality & Development ๐ง
### Unified Linting & Formatting
The project uses centralized ESLint and Prettier configurations for consistent code quality across all services.
```bash
# Run from project root (applies to all services)
npm run lint # Check code quality with ESLint
npm run lint:fix # Fix ESLint issues automatically
npm run format # Format all files with Prettier
npm run format:check # Check formatting without changes
# Service-specific commands (uses shared config)
cd chat-app-front
npm run lint # Frontend linting only
npm run format # Frontend formatting only
cd chat-app-auth
npm run lint # Backend linting only
npm run format # Backend formatting only
```
## Testing ๐งช
### Unit Tests (Frontend)
```bash
cd chat-app-front
npm test # Run unit tests with Vitest
npm run test:ui # Run tests with Vitest UI
npm run test:coverage # Generate test coverage report
```
### Unit & Integration Tests (Backend)
The backend includes comprehensive testing with both unit tests (fast, mocked dependencies) and integration tests (real database, HTTP requests).
```bash
cd chat-app-auth
# Unit Tests (61 tests across 7 suites)
npm test # Fast unit tests with mocked dependencies
npm run test:watch # Unit tests in watch mode
npm run test:coverage # Unit tests with coverage report
# Integration Tests (23 tests across 2 suites)
npm run test:integration # Full integration tests with Docker
npm run test:integration:watch # Integration tests in watch mode
npm run test:integration:coverage # Integration tests with coverage
# All Tests
npm run test:all # Run both unit and integration tests
```
**Backend test coverage includes:**
- ๐ง **Unit Tests**: User models, controllers, authentication strategies, error handling
- ๐ **Integration Tests**: Real HTTP API endpoints with SuperTest and PostgreSQL
- ๐ **Authentication Testing**: Registration, login, JWT tokens, Hasura webhooks
- ๐๏ธ **Database Testing**: Real database operations, constraints, migrations
### End-to-End Tests (Frontend)
The application includes comprehensive e2e tests using Playwright that test the full application stack.
```bash
cd chat-app-front
npm run test:e2e # Run e2e tests (auto-starts test environment)
npm run test:e2e:ui # Run with Playwright UI
npm run test:e2e:headed # Run in headed browser mode
npm run test:e2e:debug # Run in debug mode
npm run test:e2e:setup # Start test environment only
npm run test:e2e:cleanup # Stop test environment
npm run test:e2e:complete # Full cycle: setup โ test โ cleanup
```
**What the e2e tests cover:**
- ๐ Authentication flows (login, logout, session management)
- ๐งญ UI navigation between different views
- ๐ฌ Conversation management (create, view, manage)
- ๐ Message functionality (send, receive, display)
- โก Real-time features via GraphQL subscriptions
The e2e tests use a dedicated test environment with separate Docker services running on different ports to avoid conflicts with development.
## Hasura migrations (`cd chat-app-graphql-engine`)
Open console from CLI with `hasura console --endpoint http://localhost:8081 --admin-secret chatappadminsecretkey` and it should handle creating the migration files automatically. After creating new migration files, move them to chat-app-db/migrations and export new changes to hasura metadata using `hasura metadata export --endpoint http://localhost:8081 --admin-secret chatappadminsecretkey`.
### Manual operations
- pull new changes to metadata
- `hasura metadata export --endpoint --admin-secret `
- apply metadata changes
- `hasura metadata apply --endpoint --admin-secret `
- Initialise the migration from ground up (use only when you know what you are doing)
- `hasura migrate create init --from-server --endpoint --admin-secret `
- apply migrations
- https://hasura.io/docs/latest/hasura-cli/commands/hasura_migrate_apply/
- `hasura migrate apply --endpoint --admin-secret --version --up --skip-execution`
- apply migrations manually
- `hasura migrate apply --database-name default --endpoint --admin-secret && hasura metadata apply --endpoint --admin-secret `
- squash the migration files
- `hasura migrate squash --from `
- reset migrations on server
- `hasura migrate delete --all --server --database-name --endpoint --admin-secret `