Skip to content

Backend prasanna - #15

Open
Prasannaganesann wants to merge 15 commits into
mainfrom
backend-prasanna
Open

Backend prasanna#15
Prasannaganesann wants to merge 15 commits into
mainfrom
backend-prasanna

Conversation

@Prasannaganesann

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI lite review requested due to automatic review settings August 11, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors backend configuration and database wiring (moving from app.core.config / app.db.* to app.config.* / app.database.*), and tightens user role handling so clients can’t self-assign roles during registration or profile updates.

Changes:

  • Enforce server-side default user role (analyst) during registration and prohibit role updates via profile edits.
  • Introduce new app/config and app/database modules (Postgres engine/session + shared SQLAlchemy Base) and update imports accordingly.
  • Add .env ignoring and a simple authentication-flow diagram file.

Reviewed changes

Copilot reviewed 16 out of 32 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
backend/app/services/auth_service.py Enforces default analyst role on registration; blocks role changes in profile update.
backend/app/schemas/user.py Removes role from create/update inputs; ensures role appears in API responses.
backend/app/models/user.py Switches model to use the new authoritative SQLAlchemy Base.
backend/app/middleware/auth_middleware.py Updates imports to new settings and database session modules.
backend/app/main.py Switches to new settings/db imports; wraps table auto-create in a try/except.
backend/app/db/session.py Removes legacy DB session/Base/engine module.
backend/app/db/init.py Removes legacy DB re-exports.
backend/app/database/session.py Adds new get_db() dependency provider using SessionLocal.
backend/app/database/postgres.py Adds Postgres engine/session configuration and dotenv loading.
backend/app/database/base.py Adds single authoritative SQLAlchemy declarative Base.
backend/app/database/init.py Re-exports new database primitives (Base, SessionLocal, engine, get_db).
backend/app/core/security.py Updates settings import to new config module.
backend/app/core/init.py Updates settings import re-export to new config module.
backend/app/config/settings.py Adds settings object for project metadata + JWT config.
backend/app/config/init.py Adds config package re-export for settings.
backend/app/authentication flow Adds a plaintext authentication flow diagram.
backend/app/api/auth.py Updates imports and docs around default role; minor login comment adjustment.
.gitignore Ignores .env, venvs, caches, and local DB files.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread backend/app/database/postgres.py Outdated
Comment on lines +6 to +7
# Load variables from backend/.env
load_dotenv()
Comment thread backend/app/database/postgres.py Outdated
Comment on lines +9 to +12
DATABASE_URL = os.getenv(
"DATABASE_URL",
"postgresql://postgres:postgres@localhost:5432/malware_db"
)
Comment thread backend/app/main.py Outdated
Comment on lines +9 to +13
# Initialize database tables on startup if database is reachable
try:
Base.metadata.create_all(bind=engine)
except Exception as e:
print(f"[Warning] Database table auto-creation skipped: {e}")
@@ -0,0 +1,28 @@
User
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants