Skip to content

Utkarshalways/LMS_Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learning Management System Backend (.NET Core Web API)

This project is a backend API service for a learning portal, built on ASP.NET Core Web API, using SQL Server and Entity Framework Core, with JWT and Google authentication.


🚀 Getting Started

Prerequisites

  • .NET 6+ SDK
  • SQL Server (local or remote)
  • (Optional but recommended) VS Code or Visual Studio for C#

Setup & Installation

  1. Clone the repository
git clone https://bitbucket.org/dotnetreact/.netreacttraining2025/src/master/
cd AuthCheck
  1. Configure Environment Variables

Create (or update) appsettings.json:

{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SQL_SERVER;Database=LearningPortalDB;User Id=YOUR_USER;Password=YOUR_PASSWORD;TrustServerCertificate=True;"
},
"Jwt": {
"Key": "YOUR_JWT_SECRET_KEY",
"Issuer": "LearningPortal",
"Audience": "LearningPortalUsers"
},
"Google": {
"ClientId": "your-google-client-id.apps.googleusercontent.com"
},
"AllowedHosts": "*"
}
  • Edit connection string for your SQL Server.
  • Set your JWT key (used to sign tokens).
  • Google ClientId: For Google login.
  1. Apply Entity Framework Migrations
dotnet ef database update

If you have not added migrations yet:
dotnet ef migrations add InitialCreate
dotnet ef database update

Running the App

Simply run:

dotnet run

API will be available at:
http://localhost:5000 (default port, see launchSettings.json)


🗂 Project Structure

  • /Controllers — API endpoints (users, courses, assignments, auth, etc.)
  • /Entities — EF Core models
  • /Data — DbContext and data seeders
  • /Services — Business logic/services
  • /Enums — Enum definitions (progress, status, etc.)
  • /Model — DTOs and request/response objects
  • Program.cs — Startup/configuration logic (or just Program.cs for minimal hosting)

🔑 Authentication & Security

  • JWT Authentication:

    • Tokens are generated and required on all protected endpoints.
    • Set Jwt:Key in your config and keep it secret!
    • Pass token in the Authorization: Bearer <token> header.
  • Google Login:

    • Specify your Google ClientId in appsettings.json.
    • Frontend posts Google id_token to /api/Auth/googleAuth.

🛠 Development Tools

  • Swagger UI: Automatic API docs at /swagger when running locally.
  • Entity Framework Core: For migrations and DB schema.
  • CORS: Configurable in Startup.cs or Program.cs.
    Ensure React frontend origin (e.g., http://localhost:3000) is added as an allowed origin.

📦 API Usage

  • Login: POST /api/Auth/login
  • Register: POST /api/Auth/register
  • Google Auth: POST /api/Auth/googleAuth
  • Current user: GET /api/account/me
  • Courses, assignments, submissions, progress: RESTful routes under /api/

See Swagger UI for interactive docs.


🚨 Troubleshooting

  • SQL connection errors: Check your connection string, user/password, and SQL Server status.
  • JWT issues: Make sure your Jwt:Key matches and token is passed as a Bearer header.
  • CORS: Adjust allowed origins in your config.
  • Google login issues: Double check the ClientId and Google Console settings.

👨‍💻 Development

  • Check logs for errors and exceptions; default logging to console in dev mode.
  • You can seed the database through DataSeed.cs or your own scripts.

📄 License

MIT (Or your license here)


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages