Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Virtual environments
.venv/
venv/
ENV/
env/

# Environment variables
.env
.env.local

# Database files
*.db
*.sqlite
*.sqlite3

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# Testing
.pytest_cache/
.coverage
htmlcov/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg

# Logs
*.log
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# LifeLine-ICT

![CI](https://github.com/buayism/LifeLine-ICT/actions/workflows/ci.yml/badge.svg)

## Project Summary

LifeLine-ICT is a digital infrastructure management platform that supports the
Expand Down
1 change: 1 addition & 0 deletions backend/app/api/alert_router.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Alert API routes for sensor monitoring and notifications."""

from __future__ import annotations

Expand Down
16 changes: 7 additions & 9 deletions backend/app/api/analytics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Analytics API routes."""
"""Analytics API routes for metrics and reporting."""

from __future__ import annotations

Expand All @@ -8,19 +8,17 @@


@router.get(
"/health",
tags=["health"],
"/dashboard",
tags=["analytics"],
)
async def healthcheck() -> dict[str, str]:
async def get_dashboard_summary() -> dict[str, str]:
"""
Provide a basic health indicator confirming application availability.
Provide a summary of key metrics for the dashboard.

Returns
-------
dict[str, str]
JSON payload with a static status. The endpoint is intentionally
lightweight to support campus monitoring systems and classroom
demonstrations.
Summary statistics for projects, resources, and tickets.
"""

return {"status": "ok"}
return {"status": "dashboard_endpoint_placeholder"}
15 changes: 13 additions & 2 deletions backend/app/api/auth_router.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
"""Authentication API routes for user login and registration."""

from __future__ import annotations

from datetime import timedelta

from fastapi import APIRouter, Depends, HTTPException, status
from fastapi.security import OAuth2PasswordRequestForm
from pydantic import BaseModel
from sqlalchemy.ext.asyncio import AsyncSession

from ..core.database import get_session
from ..repositories.user_repository import UserRepository
from ..services.auth_service import ACCESS_TOKEN_EXPIRE_MINUTES, AuthService


class UserCreate(BaseModel):
"""Schema for user creation."""

username: str
password: str


router = APIRouter(prefix="/api/v1/auth", tags=["Authentication"])


Expand Down Expand Up @@ -40,8 +50,9 @@ async def login_for_access_token(

@router.post("/users")
async def create_user(
form_data: OAuth2PasswordRequestForm = Depends(),
user_data: UserCreate,
auth_service: AuthService = Depends(get_auth_service),
) -> dict[str, str]:
user = await auth_service.create_user(form_data.username, form_data.password)
"""Create a new user with proper credentials."""
user = await auth_service.create_user(user_data.username, user_data.password)
return {"username": user.username}
18 changes: 17 additions & 1 deletion backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from .core.config import settings
from .core.logging import configure_logging
Expand Down Expand Up @@ -56,6 +57,15 @@ def create_app() -> FastAPI:

errors.register_exception_handlers(app)

# Configure CORS for frontend integration
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

app.include_router(projects_router)
app.include_router(resources_router)
app.include_router(locations_router)
Expand All @@ -65,7 +75,13 @@ def create_app() -> FastAPI:
app.include_router(alert_router)
app.include_router(auth_router)

@app.get("/health", tags=["health"])
@app.get("/", tags=["root"])
async def root_redirect():
"""Redirect root URL to API documentation."""
from fastapi.responses import RedirectResponse
return RedirectResponse(url="/docs")

@app.get("/api/v1/health", tags=["health"])
async def healthcheck() -> dict[str, str]:
"""
Provide a basic health indicator confirming application availability.
Expand Down
17 changes: 17 additions & 0 deletions backend/tests/api/test_health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Tests for the health check endpoint."""

from fastapi.testclient import TestClient


def test_health_check_returns_ok(client: TestClient) -> None:
"""Health endpoint should return status ok."""
response = client.get("/api/v1/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}


def test_root_redirects_to_docs(client: TestClient) -> None:
"""Root URL should redirect to API documentation."""
response = client.get("/", follow_redirects=False)
assert response.status_code == 307
assert response.headers["location"] == "/docs"
Loading