Skip to content

rajaflash/nestjs-graphql-python-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

nestjs-graphql-python-microservices

Outcome is to learn & implement nestjs, graphql, python and docker

--> Generated by GPT for crisp and precise understanding of what this repo is all about 🙂

NestJS + GraphQL + Python Microservices Roadmap

A step-by-step 8-week roadmap to master NestJS, GraphQL, and Python microservices, fully Dockerized.
By the end, you'll have a production-ready backend stack with MongoDB, Redis caching, and optional ML/image processing services.


Tech Stack

  • Backend: NestJS, GraphQL (Apollo)
  • Microservices: Python (FastAPI)
  • Database: MongoDB (Mongoose)
  • Cache & Messaging: Redis, Optional RabbitMQ
  • Containerization: Docker & Docker Compose

8-Week Roadmap

Week 1 – NestJS Fundamentals (Task Tracker API)

Goal: Learn NestJS structure, modules, services, and basic GraphQL CRUD.

Tasks & Subtasks:

  1. Setup Project

    • Install NestJS CLI.
    • Scaffold project: nest new task-tracker.
    • Add GraphQL module (code-first).
    • Setup MongoDB with Mongoose.
  2. Create Modules & Services

    • Create TaskModule.
    • Create TaskService with CRUD methods.
    • Create TaskResolver with queries/mutations.
  3. GraphQL Implementation

    • Define Task schemas using Mongoose.
    • Implement createTask, getTasks, updateTask, deleteTask.
    • Test queries in GraphQL Playground.
  4. Docker Practice

    • Write basic Dockerfile for NestJS.
    • Build image & run container.
    • Verify GraphQL Playground inside container.

Optional Bonus: Add pagination & filtering.


Week 2 – GraphQL Deep Dive (User & Task Relationship)

Goal: Master GraphQL queries, relationships, and nested resolvers.

Tasks & Subtasks:

  1. User Module

    • Create UserModule and UserService.
    • Add User schema and relationships to Task.
  2. Resolvers

    • Add getUserTasks(userId) query.
    • Implement nested resolvers for task details.
  3. Input Validation

    • Use class-validator decorators.
    • Handle errors gracefully in GraphQL.
  4. Docker

    • Add MongoDB container via Docker Compose.
    • Connect NestJS container to MongoDB service.
    • Test queries from NestJS container.

Optional Bonus: Fix N+1 problem using DataLoader.


Week 3 – Authentication & Authorization (JWT Auth)

Goal: Secure GraphQL APIs.

Tasks & Subtasks:

  1. JWT Auth Setup

    • Install Passport.js + JWT packages.
    • Configure JWT strategy and guards.
  2. User Auth

    • Implement signup & login mutations.
    • Hash passwords using bcrypt.
    • Add me query for authenticated user.
  3. Role-based Access

    • Add roles (e.g., admin, user).
    • Create @Roles() decorator.
    • Protect queries/mutations.
  4. Docker

    • Use .env for JWT secret inside container.
    • Rebuild NestJS image with updated config.

Optional Bonus: Add refresh tokens & password reset mutation.


Week 4 – Caching & Middleware

Goal: Improve performance with caching and interceptors.

Tasks & Subtasks:

  1. Integrate Redis

    • Add Redis client to NestJS.
    • Cache GraphQL query results.
  2. Middleware & Interceptors

    • Logging middleware for requests.
    • Interceptor to transform responses.
    • Rate limiting middleware.
  3. Docker

    • Add Redis container in Docker Compose.
    • Connect NestJS container to Redis service.
    • Test cache persistence across container restarts.

Optional Bonus: Add custom decorators to inject metadata for logging.


Week 5 – Python Microservice (FastAPI Analytics)

Goal: Connect Python microservice to NestJS for analytics.

Tasks & Subtasks:

  1. Python FastAPI Setup

    • Scaffold FastAPI project.
    • Create /analyze route.
    • Define Pydantic models for input/output.
  2. NestJS Integration

    • Add Axios module in NestJS.
    • Create service to call Python /analyze endpoint.
    • Expose GraphQL query getUserAnalytics.
  3. Docker

    • Write Dockerfile for Python service.
    • Add Python container to Docker Compose.
    • Verify NestJS ↔ Python container communication.

Optional Bonus: Use RabbitMQ or Redis Streams for async communication.


Week 6 – File Upload & Background Processing

Goal: Handle file uploads and background processing with Python.

Tasks & Subtasks:

  1. GraphQL File Upload

    • Add Upload scalar.
    • Implement uploadImage(file: Upload) mutation.
  2. Python Image Processing

    • Script to resize/compress images (Pillow/OpenCV).
    • Store processed images in volume or S3.
  3. Background Jobs

    • Setup Bull (Redis-based queue).
    • Send image processing tasks to queue.
    • Python worker picks up job and returns result.
  4. Docker

    • Mount local folder as volume for image storage.
    • Ensure Python container can access volume.
    • Test full workflow in Docker Compose.

Week 7 – Real-time Notifications

Goal: Implement WebSockets and GraphQL subscriptions.

Tasks & Subtasks:

  1. NestJS WebSocket Gateway

    • Setup WebSocket gateway.
    • Create onTaskUpdated subscription.
  2. Broadcasting Events

    • Trigger events when tasks are created/updated.
    • Test multiple clients subscribing.
  3. Python Integration (Optional ML)

    • Python service predicts notifications.
    • NestJS broadcasts ML suggestions via subscription.
  4. Docker

    • Verify WebSocket communication between containers.
    • Ensure Redis pub/sub works across containers.

Week 8 – Capstone: Full Stack Integration

Goal: Build a fully Dockerized, production-ready microservice stack.

Tasks & Subtasks:

  1. NestJS GraphQL Gateway

    • Aggregate multiple subgraphs (tasks, users, recommendations).
  2. Python ML Service

    • Serve movie recommendations via ML model.
    • FastAPI route returns recommendations.
  3. Docker Compose Orchestration

    • NestJS container
    • Python ML service container
    • MongoDB
    • Redis
    • Optional RabbitMQ
    • Setup networks, volumes, env files.
  4. Testing

    • Test getRecommendedMovies(userId) query.
    • Test caching, subscriptions, and analytics pipelines.
  5. Optional Frontend

    • Minimal React/Angular dashboard to visualize recommendations & notifications.

Running the Stack with Docker

  1. Copy .env.example to .env and configure variables.
  2. Build and start all services:
docker-compose up --build

About

Outcome is to learn & implement nestjs, graphql, python and docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published