A robust service built with Fastify and TypeScript for managing user authentication, authorization, and profile management in the TickTuk application.
- User registration and authentication
- JWT-based authorization
- RESTful API endpoints
- Swagger documentation
- Redis for state synchronization
- Load balancing with Nginx
- Docker containerization
- Clean architecture with repository pattern
- Runtime: Node.js (>=20.0.0)
- Framework: Fastify
- Language: TypeScript
- State Store: Redis
- Authentication: JWT (@fastify/jwt)
- Documentation: Swagger/OpenAPI
- Container: Docker & Docker Compose
- Load Balancer: Nginx
- Code Quality: ESLint, Prettier
src/
├── config/ # Configuration files (Redis, etc.)
├── repositories/ # Data access layer with generic repository pattern
├── services/ # Business logic layer
├── routes/ # API endpoints and request handlers
├── plugins/ # Fastify plugins (auth, cors, etc.)
├── schemas/ # Request/Response validation schemas
├── types/ # TypeScript type definitions
└── index.ts # Application entry point
- Node.js >= 20.0.0
- Redis
- Docker & Docker Compose (for containerized deployment)
-
Clone the repository:
git clone https://github.com/Danimaxpd/TickTuk-BackEnd cd ticktuk-user-management -
Install dependencies:
npm install
-
Create a
.envfile:- Docker already has the variables
REDIS_URL=redis://localhost:6379 JWT_SECRET=your-secret-key API_KEY=your-api-key
-
Start development server:
npm run dev
Deploy the entire stack with load balancing:
docker-compose up -dThis will start:
- 2 API instances for high availability
- Redis instance for state synchronization
- Nginx load balancer
Once running, access the Swagger documentation at: http://localhost/documentation
POST /users- Create new userGET /users- List all usersDELETE /users/:id- Delete user
npm run dev- Start development servernpm run build- Build for productionnpm start- Start production servernpm test- Run testsnpm run lint- Run ESLintnpm run format- Format code with Prettiernpm run clean- Clean build directory
- JWT-based authentication
- Password hashing
- Input validation with JSON schemas
- CORS protection
- Environment variable configuration
- Secure HTTP headers with Nginx
The service is containerized with:
- Multi-container setup using Docker Compose:
- 2 API instances for high availability
- Redis for in-memory state synchronization
- Nginx load balancer with round-robin distribution
- Isolated network with internal service discovery
- Health monitoring for all services
- Automatic container restart on failure
This project is licensed under the MIT License - see the LICENSE file for details.
David Jimenez
- Email: danimax.com@gmail.com
- GitHub: @danimaxpd