Skip to content
Siddharth Sriram edited this page Jan 12, 2026 · 23 revisions

!(https://drive.google.com/file/d/1UWPiqkaPggvSxw2i1KjGVJspL-4kTDr8/view?usp=sharing)

[Brief one-line description of what your project does]


Purpose

[Your Project Name] is designed to [main problem it solves]. It helps [target users] to [key benefit] by [how it works].

Key Benefits

  • [Benefit 1] - [Brief explanation]
  • [Benefit 2] - [Brief explanation]
  • [Benefit 3] - [Brief explanation]

Quick Start

# Installation command
npm install your-project-name
# or
pip install your-project-name
// Quick example code
const YourProject = require('your-project-name');

// Basic usage example
const instance = new YourProject({
  option1: 'value1',
  option2: 'value2'
});

[Link to Full Installation Guide β†’](./Installation)


Table of Contents

Getting Started

Core Concepts

Guides

API Reference

Additional Resources


Features

πŸš€ [Feature Name 1]

[Brief description of this feature and why it matters]

Feature 1 Diagram

πŸ’‘ [Feature Name 2]

[Brief description of this feature and why it matters]

⚑ [Feature Name 3]

[Brief description of this feature and why it matters]


How It Works

[Your Project Name] works by [explanation of core mechanism]:

  1. [Step 1] - [What happens in this step]
  2. [Step 2] - [What happens in this step]
  3. [Step 3] - [What happens in this step]

Architecture Diagram

[Learn more about the architecture β†’](./Architecture)


Use Cases

[Use Case 1 Title]

[Description of when and why you'd use this approach]

// Example code for this use case

[Use Case 2 Title]

[Description of when and why you'd use this approach]

[Use Case 3 Title]

[Description of when and why you'd use this approach]

[See more examples β†’](./Examples)


Community & Support


Contributing

We welcome contributions! Please see our [Contributing Guide](./Contributing) for details.

Quick Links


License

[Your Project Name] is released under the [License Name] License. See [LICENSE](../LICENSE) file for details.


Credits

Created and maintained by [Your Name/Organization].

Acknowledgments

  • [Person/Project 1] - [Their contribution]
  • [Person/Project 2] - [Their contribution]

[⬆ Back to Top](#your-project-name)

Interceptor Documentation:

main.py documentation:

Notes:

from fastapi import FastAPI, Request
from fastapi refers specifically to the FastAPI framework
"import FastAPI" indicates that the FastAPI class imported from the fastapi module
"import Request" indicates that the Request class is also imported from the fastapi module

"import CORSMiddleware" indicates that the CORSMiddleware class is imported from the fastapi.middleware.cors module

CORSMiddleware is used to handle Cross-Origin Resource Sharing (CORS) in FastAPI applications (security feature) that controls which websites are allowed to talk to your application

"import logging" library that helps track whats happening in program, records messages about errors, warnings, or just general information "import os" library that lets program interact with OS, can read environment variables, work with file paths, etc

"logging.basicConfig(" Configuring or setting up how logging your system will work (remember Cassandra and setting up logs on there so actions be tracked and basicConfig (basic configuration) means your choosing you setting

"level=logging.INFO" Sets what level of messages you want to record Different levels:

  • DEBUG (very detailed)
  • ERROR (actual problems)
  • INFO (general info)
  • WARNING (potential problems)
  • CRITICAL (serious problem)

logging.INFO "record INFO messages and anything more serious)

Logging message format:

format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'

  • %(asctime)s ; time
  • %(name)s : which part of application or program sent this
  • %(levelname)s : the level (INFO, WARNING, ERROR, etc)
  • %(message)s : Actual message (Server started successfully)

Example: 2024-12-29 10:30:45 - my_app - INFO - Server started successfully

logger = logging.getLogger(name)

  • Creates actual logger object that you'll use to write messages
  • "getLogger(name)" - create a logger with the name of this file/module
  • name is a special Python variable that contains the name of your current file
  • Now you can use logger.info("something happened") to record messages!

app = FastAPI(title="Interceptor", description="API Security Gateway with Behavior Analysis", version="1.0.0", docs_url="/api/docs", )

Add the CORS middleware (allows dashboard to connect)

app.add_middleware( CORSMiddleware, # React dashboard allow_origins=["http://localhost:3000"], allow_credentials=True, allow_methods=[""], allow_headers=[""], )

Starting up and shutting down interceptor tool

@app.on_event("startup") async def startup_event(): """Run when the application starts""" logger.info("=" * 50) logger.info("Interceptor Gateway Starting Up") logger.info("=" * 50) # TODO: Initialize database connections logger.info("Gateway ready to accept requests")

@app.on_event("shutdown") async def shutdown_event(): """Run when the application shuts down""" logger.info("Interceptor Gateway Shutting Down") # TODO: Close database connections

Basic Endpoint

@app.get("/") async def root(): """Root endpoint - welcome message""" return { "message": "Welcome to Interceptor Gateway", "version": "1.0.0", "docs": "/docs", "health": "/health" }

@app.get("/health") async def health_check(): """Health check endpoint""" return { "status": "healthy", "service": "interceptor-gateway", "timestamp": datetime.utcnow().isoformat() }

@app.get("/api/test") async def test_endpoint(request: Request): """Test endpoint to verify gateway is working""" return { "message": "Gateway is working!", "client_ip": request.client.host, "path": request.url.path, "method": request.method, "timestamp": datetime.utcnow().isoformat() }

Create the database configuration

init.py

Empty file to make it a python packet

Now create database.py

Clone this wiki locally