Backend Developer Guide
Backend Developer Guide
Table of Contents
Python
● Django: A high-level Python web framework that encourages rapid development and
clean, pragmatic design.
○ Installation: pip install django
○ Create a project: django-admin startproject myproject
○ Run server: python manage.py runserver
● Flask: A micro web framework written in Python.
○ Installation: pip install flask
Basic app:
python
Copy code
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello, World!"
if __name__ == "__main__":
app.run()
JavaScript
Basic app:
javascript
Copy code
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello, World!');
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
Java
● Spring Framework:
○ Spring Boot is the most popular framework for building microservices and
web applications in Java.
○ Spring Initializr: start.spring.io
Ruby
PHP
4. Database Management
SQL Databases
● MySQL:
○ Installation: sudo apt-get install mysql-server
Basic commands:
sql
Copy code
CREATE DATABASE mydatabase;
USE mydatabase;
CREATE TABLE users (id INT PRIMARY KEY AUTO_INCREMENT, name
VARCHAR(100));
○
● PostgreSQL:
○ Installation: sudo apt-get install postgresql
Basic commands:
sql
Copy code
CREATE DATABASE mydatabase;
\c mydatabase
CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(100));
NoSQL Databases
● MongoDB:
○ Installation: sudo apt-get install -y mongodb
Basic commands:
javascript
Copy code
use mydatabase
db.users.insert({ name: "John Doe" })
Example in Express.js:
javascript
Copy code
app.get('/api/users', (req, res) => {
res.json(users);
});
○
● GraphQL: A query language for your API.
Example setup:
javascript
Copy code
const { graphqlHTTP } = require('express-graphql');
const { buildSchema } = require('graphql');
const schema = buildSchema(`
type Query {
hello: String
}
`);
const root = { hello: () => 'Hello world!' };
app.use('/graphql', graphqlHTTP({
schema: schema,
rootValue: root,
graphiql: true,
}));
○
● OAuth: Protocol for token-based authentication and authorization.
○ Libraries: Passport.js for Node.js, Devise for Rails.
● Unit Testing:
○ Python: unittest, pytest
○ JavaScript: Jest, Mocha
● Integration Testing: Test how components work together.
● Debugging Tools:
○ Python: pdb
○ JavaScript: node --inspect
● Basic Commands:
○ ls - list directory contents
○ cd - change directory
○ cp - copy files and directories
○ mv - move/rename files and directories
○ rm - remove files or directories
○ chmod - change file modes or Access Control Lists
○ chown - change file owner and group
● Process Management:
○ ps - report a snapshot of current processes
○ top - display Linux tasks
○ kill - send a signal to a process
○ nohup - run a command immune to hangups, with output to a non-tty
● Networking:
○ ping - send ICMP ECHO_REQUEST to network hosts
○ curl - transfer a URL
○ wget - non-interactive network downloader
○ netstat - network statistics
○ ssh - OpenSSH SSH client
Elasticsearch
● Installation:
○ docker pull elasticsearch
○ docker run -p 9200:9200 -e "discovery.type=single-node"
elasticsearch
Basic Usage:
json
Copy code
PUT /myindex/_doc/1
{
"name": "John Doe"
}
Message Queues
● RabbitMQ:
○ Installation: sudo apt-get install rabbitmq-server
○ Basic Usage: Publish/Subscribe model
● Kafka:
○ Installation: brew install kafka
○ Basic Usage: Produce/Consume model
Scheduling
● Cron Jobs:
○ Syntax: * * * * * command
○ Example: 0 0 * * * /path/to/script.sh
● Celery:
○ Installation: pip install celery
Basic Usage:
python
Copy code
from celery import Celery
app = Celery('tasks', broker='pyamqp://guest@localhost//')
@app.task
def add(x, y):
return x + y
Microservices Architecture
● Design Principles:
○ Single Responsibility Principle
○ API Gateway
○ Service Registry
● Implementation:
○ Use Docker and Kubernetes for container orchestration.
Containerization
● Docker:
○ Basic Commands:
■ docker build -t myapp .
■ docker run -p 3000:3000 myapp
● Kubernetes:
○ Basic Commands:
■ kubectl apply -f deployment.yaml
■ kubectl get pods