Skip to content

A robust, production-ready user authentication and profile management web application built with FastAPI, SQLAlchemy, and Jinja2. This project provides secure registration, login, profile editing, and session management, following best practices for modern Python web development.

Notifications You must be signed in to change notification settings

Legacy-G/gb-technologies-with-fastapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Gb-Technologies User Management System

A robust, production-ready user authentication and profile management web application built with FastAPI, SQLAlchemy, and Jinja2. This project provides secure registration, login, profile editing, and session management, following best practices for modern Python web development.

Features

  • User Registration & Login: Secure authentication using hashed passwords and JWT cookies.
  • Profile Management: Users can view and edit their profile, including personal details and profile image.
  • Session Management: Cookie-based authentication with secure logout.
  • Responsive UI: Modern, mobile-friendly interface using Bootstrap and custom CSS.
  • Asynchronous Database Access: High performance with SQLAlchemy’s async ORM.
  • Extensible Structure: Modular routers, models, and utilities for easy expansion.

Tech Stack

  • Backend: FastAPI, SQLAlchemy (async), FastAPI Users
  • Frontend: Jinja2 templates, Bootstrap 5, custom CSS/JS
  • Database: SQLite (default, easily swappable)
  • Authentication: JWT + Cookie Transport
  • Password Hashing: Passlib (bcrypt)
  • Other: Alembic for migrations

Project Structure

webfa/
├── db.py                # Database setup and session management
├── init_db.py           # DB initialization script
├── main.py              # FastAPI app entry point
├── models/
│   └── user.py          # User and UserProfile SQLAlchemy models
├── routers/
│   └── auth.py          # All authentication and profile routes
├── schemas/
│   └── user.py          # (Optional) Pydantic schemas for user data
├── static/              # CSS, JS, images, assets
├── templates/           # Jinja2 HTML templates
│   ├── base.html
│   ├── index.html
│   ├── login.html
│   ├── register.html
│   ├── profile.html
│   └── edit_profile.html
└── utils.py             # Utility functions for auth, profile, etc.

Setup & Installation

  1. Clone the repository

    git clone https://github.com/Legacy-G/gb-technologies-with-fastapi.git
    cd fastapiproject/fastapi
  2. Create a virtual environment

    python -m venv .venv
    .venv\Scripts\activate  # On Windows
    # Or
    source .venv/bin/activate  # On Mac/Linux
  3. Install dependencies

    pip install -r webfa/requirements.txt
  4. Run database migrations

    alembic upgrade head
  5. Start the development server

    uvicorn webfa.main:app --reload
  6. Access the app

Usage

  • Register: Create a new account via /register.
  • Login: Authenticate via /login.
  • Profile: View your profile at /profile.
  • Edit Profile: Update your details at /edit-profile.
  • Logout: End your session via /logout.

Security Notes

  • Secret Keys: Change SUPER_SECRET_KEY and other secrets in production. Use environment variables.
  • HTTPS: Always deploy behind HTTPS in production.
  • Password Hashing: Uses bcrypt for secure password storage.

Customization

  • Database: Swap SQLite for PostgreSQL or MySQL by updating db.py and your connection string.
  • Templates: Modify Jinja2 templates in templates/ for branding.
  • Static Assets: Place your CSS/JS/images in static/.

Contributing

  1. Fork the repo
  2. Create your feature branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License.

About

A robust, production-ready user authentication and profile management web application built with FastAPI, SQLAlchemy, and Jinja2. This project provides secure registration, login, profile editing, and session management, following best practices for modern Python web development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published