Skip to content

Riteek712/LedgerSync

Repository files navigation

LedgerSync Financial Automation Platform

NestJS microservices monorepo — PostgreSQL · Redis · Kafka · Docker

Architecture

┌─────────────────────────────────────────────────────────────┐
│                        Client / Browser                     │
└──────────────────────────┬──────────────────────────────────┘
                           │ HTTP :3000
┌──────────────────────────▼──────────────────────────────────┐
│                      API Gateway                            │
│  • JWT validation (global guard)                            │
│  • Swagger UI  → /api/docs                                  │
│  • Redis cache (CacheInterceptor on GET endpoints)          │
│  • Routes requests via TCP to microservices                 │
└──────────┬──────────────────────────┬───────────────────────┘
           │ TCP :3001                │ TCP :3002
┌──────────▼──────────┐   ┌──────────▼──────────┐
│    auth-service     │   │    user-service      │
│  • Register/Login   │   │  • CRUD users        │
│  • JWT issue/verify │   │  • Redis caching     │
│  • Refresh tokens   │   │  • Soft delete       │
│  • Kafka producer   │   │  • Kafka producer    │
└──────────┬──────────┘   └──────────┬───────────┘
           │                         │
           └────────────┬────────────┘
                        │ Kafka events
                ┌───────▼────────┐
                │     Kafka      │  Topics:
                │                │  • user.created
                │                │  • user.updated
                │                │  • user.deleted
                └────────────────┘  • auth.login / .logout

Quick Start

# 1. Install dependencies
npm install

# 2. Copy and configure environment
cp .env.example .env

# 3. Start infrastructure (Postgres, Redis, Kafka)
make infra

# 4. Start all services in dev mode
npm run start:api-gateway &
npm run start:auth-service &
npm run start:user-service

Or with Docker (full stack):

make up

Services

Service Port Description
api-gateway 3000 HTTP entry point, Swagger UI
auth-service 3001 TCP microservice — auth logic
user-service 3002 TCP microservice — user CRUD
PostgreSQL 5432 Persistent storage
Redis 6379 Caching & token blacklist
Kafka 9092 Event streaming
Kafka UI 8080 Kafka management UI

API Endpoints

All routes prefixed with /api/v1. Swagger at http://localhost:3000/api/docs.

Auth (public)

POST /api/v1/auth/register    Register new user
POST /api/v1/auth/login       Login → returns JWT pair
POST /api/v1/auth/refresh     Refresh access token
POST /api/v1/auth/logout      Invalidate tokens  🔒

Users

GET    /api/v1/users          List all users (admin) 🔒
GET    /api/v1/users/me       Current user profile   🔒
GET    /api/v1/users/:id      Get user by ID         🔒
POST   /api/v1/users          Create user (admin)    🔒
PUT    /api/v1/users/:id      Update user            🔒
DELETE /api/v1/users/:id      Delete user (admin)    🔒

Kafka Topics

Topic Producer Description
user.created auth/user New user registered
user.updated user-service User profile changed
user.deleted user-service User soft-deleted
auth.login auth-service Successful login
auth.logout auth-service User logged out

Useful Commands

make help          # Show all commands
make infra         # Start infra only (for local dev)
make dev           # Infra + all services
make logs          # Tail all logs
make db-shell      # Postgres CLI
make redis-cli     # Redis CLI
make kafka-topics  # List Kafka topics

Project Structure

backend-service/
├── apps/
│   ├── api-gateway/       HTTP gateway, global guards, Swagger
│   ├── auth-service/      JWT auth, refresh tokens, Kafka producer
│   └── user-service/      User CRUD, Redis cache, Kafka consumer
├── libs/
│   └── common/            Shared constants, DTOs, guards, decorators
├── docker/
│   └── postgres/init.sql  DB initialization
├── docker-compose.yml
├── Makefile
└── .env.example

Environment Variables

See .env.example for all configuration options. Key variables:

JWT_SECRET=<change-in-production>
JWT_REFRESH_SECRET=<change-in-production>
POSTGRES_PASSWORD=<change-in-production>
REDIS_PASSWORD=<change-in-production>

About

Financial Automation Platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors