Skip to content

Shubham-Redkar/log-analysis-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Log Analysis Platform

An AI-powered observability backend for log analysis, incident tracking, and operational debugging workflows.

This project is being built incrementally using FastAPI and evolves from a structured CRUD backend into a production-style incident intelligence platform with semantic retrieval, AI-assisted debugging, and RAG-based operational analysis.


Features

Current Features

  • Async FastAPI REST API
  • Layered backend architecture
  • PostgreSQL integration
  • Async SQLAlchemy 2.0 ORM
  • Alembic database migrations
  • Incident CRUD operations
  • Dynamic filtering & querying
  • Pagination support
  • Configurable sorting
  • Tag-based filtering
  • Search functionality
  • Pydantic v2 schema validation
  • Enum-based validation
  • UUID primary keys
  • PostgreSQL ENUM + ARRAY types
  • User registration & authentication
  • Password hashing with pwdlib
  • JWT access token authentication
  • Protected API routes
  • Current user dependency injection
  • Role-Based Access Control (RBAC)
  • User management APIs
  • Audit logging
  • Audit log querying & filtering
  • Custom exception hierarchy
  • Centralized exception handling
  • Request logging middleware
  • Automated async API testing with pytest
  • Dependency injection with AsyncSession
  • Swagger/OpenAPI documentation

Planned Features

Platform & Infrastructure

  • Refresh token support
  • Redis caching
  • Background job processing
  • Log ingestion pipelines
  • Operational analytics dashboard

AI & Observability

  • AI-powered incident summarization
  • Incident root cause analysis
  • Semantic incident search
  • Vector embeddings for incidents and logs
  • Similar incident detection
  • LangChain-powered retrieval workflows
  • LangGraph-based investigation agents
  • LangSmith observability and tracing
  • Retrieval-Augmented Generation (RAG) over incident history
  • AI-assisted operational debugging workflows

Tech Stack

  • Python
  • FastAPI
  • PostgreSQL
  • SQLAlchemy 2.0
  • AsyncPG
  • Alembic
  • Pydantic v2
  • PyJWT
  • pwdlib
  • Pytest
  • Uvicorn

Planned Stack

  • Redis
  • LangChain
  • LangGraph
  • LangSmith
  • FAISS / Vector Database
  • Embedding Models

Project Structure

app/
├── api/
│   ├── routes/
│   └── dependencies/
├── core/
├── db/
│   ├── models/
│   └── database.py
├── middleware/
├── schemas/
├── services/
├── tests/
└── main.py

alembic/
├── versions/
└── env.py

API Endpoints

Authentication

Method Endpoint Description
POST /auth/register Register a new user
POST /auth/login Authenticate user and return JWT
GET /auth/me Get current authenticated user

Incidents

Method Endpoint Description
POST /incidents/ Create incident
GET /incidents/ Get all incidents
GET /incidents/{incident_id} Get incident by ID
PATCH /incidents/{incident_id} Update incident
DELETE /incidents/{incident_id} Delete incident

Users

Method Endpoint Description
GET /users/ Get all users
GET /users/{user_id} Get user by ID
PATCH /users/{user_id}/role Update user role

Audit Logs

Method Endpoint Description
GET /audit-logs/ Get audit logs with filters

Authorization

The platform uses Role-Based Access Control (RBAC).

Roles

Role Permissions
VIEWER Read incidents
ANALYST Read, create, and update incidents
ADMIN Full access including deletion and user management

Route Permissions

Endpoint VIEWER ANALYST ADMIN
GET /incidents
GET /incidents/{id}
POST /incidents
PATCH /incidents/{id}
DELETE /incidents/{id}
GET /audit-logs
GET /users
GET /users/{id}
PATCH /users/{id}/role

Query Features

Supports:

  • Severity filtering
  • Status filtering
  • Environment filtering
  • Service-based filtering
  • Tag filtering
  • Search queries
  • Pagination
  • Configurable sorting

Example Queries

GET /incidents?severity=high

GET /incidents?status=open&environment=production

GET /incidents?tag=database

GET /incidents?search=timeout

GET /incidents?limit=10&offset=0

GET /incidents?sort_by=created_at&order=desc

Audit Log Queries

Supports:

  • Action filtering
  • Entity type filtering
  • Entity ID filtering
  • User ID filtering
  • Pagination
  • Chronological sorting

Example Queries

GET /audit-logs?action=INCIDENT_UPDATED

GET /audit-logs?entity_type=USER

GET /audit-logs?entity_id=<entity_uuid>

GET /audit-logs?user_id=<user_uuid>

GET /audit-logs?limit=10&offset=0

Database Features

  • UUID primary keys
  • PostgreSQL ENUM types
  • PostgreSQL ARRAY columns
  • PostgreSQL JSONB support
  • Timestamp tracking
  • Indexed query fields
  • Audit trail tracking
  • Foreign key relationships
  • Alembic migration management

Running Locally

Clone Repository

git clone <repo-url>
cd log-analysis-platform

Create Virtual Environment

python -m venv .venv

Activate Virtual Environment

Linux/macOS

source .venv/bin/activate

Windows

.venv\Scripts\activate

Install Dependencies

pip install -r requirements.txt

Run Database Migrations

alembic upgrade head

Run Server

uvicorn app.main:app --reload

Running Tests

pytest -v

API Documentation

Swagger UI:

http://127.0.0.1:8000/docs

Learning Goals

This project is focused on learning and implementing:

  • Backend architecture
  • REST API design
  • Async backend engineering
  • Validation and serialization
  • Authentication & authorization
  • Role-Based Access Control (RBAC)
  • Audit logging
  • Database integration
  • Database migrations
  • Query optimization & filtering
  • Automated API testing
  • Observability concepts
  • AI-powered operational workflows
  • Retrieval-Augmented Generation (RAG)
  • Production-style backend engineering

About

AI-powered observability and incident analysis backend for storing logs, tracking production incidents, semantic debugging, and intelligent incident retrieval using FastAPI, PostgreSQL, and LangChain.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors