Day 1: Install Docker and set up project repos

Lesson 1 60 min

Day 1: Laying the Foundation - Docker; Your First CRM Microservice

Welcome, future architects of hyperscale systems! Today marks the beginning of our ambitious 180-day journey to build an AI-powered CRM from scratch. Forget the theoretical fluff; we're diving straight into practical, production-grade implementation. Our goal isn't just to build a system, but to instill the mindset and practices of big tech engineers who craft systems handling hundreds of millions of requests per second.

Today, we tackle what might seem like a simple task: installing Docker and getting a basic "Hello CRM" service up and running. But make no mistake, the insights we uncover here are foundational. This isn't just about running code; it's about understanding why we start this way, and how this seemingly small step sets the stage for a resilient, scalable, and maintainable system.

Agenda for Day 1:

  1. The "Why" of Docker: Unpacking containerization's critical role in modern distributed systems, especially for a complex CRM.

  2. Project Scaffolding: Setting up a robust project structure that anticipates future growth and microservices.

  3. Your First Microservice: Building a minimal "Hello CRM" Express.js application.

  4. Local vs. Containerized Execution: Running our service directly and then encapsulating it in Docker.

  5. Verification: Ensuring our service is alive and well.

Core Concepts & Architecture: The Hyperscale Mindset from Day One

Containerization with Docker: Your Blueprint for Consistency

At big tech companies, "it works on my machine" is a phrase that can get you laughed out of a meeting. Why? Because consistency across development, testing, and production environments is paramount. This is where Docker, our first core concept, shines.

Insight: Imagine a CRM system with dozens, even hundreds, of microservices, each built with different languages, dependencies, and configurations. Without containerization, managing these environments becomes a nightmare. Docker provides a lightweight, portable, and self-sufficient package (a container) for your application and its dependencies. This ensures that what runs on your laptop will run identically in staging, and critically, in production. For systems pushing 100 million requests per second, environmental drift is a silent killer of reliability and performance. Docker eliminates this.

Microservices: The Building Blocks of Hyperscale

Component Architecture

AI-Powered CRM System (Conceptual) User crm-project services/ hello-crm/ Code pkg.json Dockerfile HTTP Request Day 1 Focus: This single microservice.

Our "Hello CRM" service today is more than just a simple web server; it's our first microservice.

Insight: A hyperscale CRM isn't a single, monolithic application. It's a constellation of small, independent services communicating with each other. Each service focuses on a single responsibility (e.g., lead management, sales pipeline, customer profiles, AI insights). This modularity allows independent development, deployment, and scaling. If your "lead scoring" service needs to handle 10x more load, you scale only that service, not the entire CRM. Starting with a tiny microservice today instills this critical architectural pattern from the very beginning.

How Our "Hello CRM" Fits into the Overall System:

Right now, our system is just one tiny box: the "Hello CRM Service."

Component Architecture (Conceptual):
Think of a large city map. Today, we're building the first small, crucial building. This "Hello CRM Service" is a foundation stone. In the coming weeks, we'll add more services: a LeadManagementService, a SalesPipelineService, an AIScoringService, each running in its own Docker container, communicating over a network. Our initial service might eventually become a simple health check endpoint or a foundational API gateway component. The discipline of isolating it now is key.

Control Flow & Data Flow (Today's Simplicity):

Flowchart

Start Check Dependencies Create Project Structure Generate Source Code Run Local Service Local Path Verify Local Stop Local Service Build Docker Image Docker Path Run Docker Container Verify Docker End
  1. User Request: You (or a curl command) send an HTTP GET request to http://localhost:3000/.

  2. Service Processing: Our hello-crm-service (an Express.js application) receives this request.

  3. Response: The service sends back a "Hello CRM!" message.

When running with Docker, an additional layer is introduced: Your request goes to the Docker host, which then routes it to the specific port of the running hello-crm-service container.

System State Changes:

State Machine

CRM Day 1 - Service Lifecycle Project Not Initialized Project Initialized (Local) Hello CRM Running (Local) Hello CRM Running (Docker) run start.sh start local stop local start docker container run stop.sh (Clean Up All)

Our system will transition through these states today:

  • Initial: No CRM code, no services running.

  • Project Initialized: Directory structure and basic code files are created.

  • Local Service Running: hello-crm-service is running directly on your machine.

  • Containerized Service Running: hello-crm-service is running inside a Docker container.

  • Clean Slate: All services and project files are stopped/removed.

Insight: Understanding these states helps in debugging and deployment. In a production environment, automated tools (like Kubernetes) manage these state transitions at massive scale. We're building that mental model now.

Real-time Production System Application:

Why bother with Docker for a "Hello World"? Because in systems handling 100M RPS, every single service is containerized. Deployments are container-based. Scaling is container-based. Monitoring is container-aware. Learning this workflow now, even with a minimal service, means you're practicing the same fundamental operations that power the largest distributed systems on the planet. This isn't just a tutorial; it's an apprenticeship in big tech's operational excellence.


Assignment: Your First Hands-On Challenge

Now it's your turn to get your hands dirty. After successfully running the provided scripts:

  1. Personalize Your CRM:

  • Locate the server.js file in crm-project/services/hello-crm/.

  • Change the response message from "Hello CRM! This is your first microservice..." to something unique, like "Hello [Your Name]'s CRM! Building the future, one request at a time."

  • Run start.sh again. Did your changes appear? (Hint: You might need to rebuild the Docker image!)

  1. Add a Status Endpoint:

  • In server.js, add a new GET endpoint, /status, that returns a JSON object: { "status": "ok", "service": "hello-crm" }.

  • Verify this new endpoint both locally and via Docker.

  1. Port Experimentation:

  • Modify the Dockerfile to expose and map the service to a different port, say 8080, instead of 3000.

  • Update server.js to listen on 8080.

  • Run start.sh and verify the service on the new port.


Solution Hints:

  1. Personalize Your CRM: For local changes, just save server.js and restart the node server.js process. For Docker, you'll need to re-run docker build -t hello-crm-service . after modifying server.js, and then docker run the new image. Remember to stop and remove the old container first (docker stop hello-crm-container && docker rm hello-crm-container).

  2. Add a Status Endpoint:

javascript
app.get('/status', (req, res) => {
res.json({ "status": "ok", "service": "hello-crm" });
});

Place this before the app.listen() call. Remember to rebuild and rerun your Docker container after this change.

  1. Port Experimentation:

  • In server.js, change const port = 3000; to const port = 8080;.

  • In Dockerfile, change EXPOSE 3000 to EXPOSE 8080.

  • In start.sh, modify the docker run command: -p 8080:8080 (or whichever external port you want to map to the container's internal 8080).

  • Always rebuild the Docker image after Dockerfile changes!

Success for today means you can confidently create a project, run a basic service both locally and in Docker, and perform simple modifications and verifications. This foundational skill is your gateway to building incredibly complex, high-scale systems. Keep pushing!

Need help?