Skip to content

API do aplicativo para organização de matérias escolares (ou acadêmicas) para organização de estudos, de acordo com o tema e data.

Notifications You must be signed in to change notification settings

MatheusMottaGit/Study.io-App-backend-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Study.io Backend API Documentation

Overview

Study.io is a backend API service built with Fastify that helps users manage their study materials through subjects, topics, and matters. The API uses JWT authentication and integrates with Google OAuth for user authentication.

Base URL

http://localhost:3333

Authentication

All endpoints (except authentication endpoints) require a valid JWT token in the Authorization header:

Authorization: Bearer <token>

API Endpoints

Authentication

Register/Login with Google

POST /register

Authenticates a user using Google OAuth.

Request Body:

{
  "access_token": "string" // Google OAuth access token
}

Response:

{
  "token": "string" // JWT token for subsequent requests
}

Get Current User

GET /me

Returns information about the currently authenticated user.

Response:

{
  "user": {
    "sub": "string", // User ID
    "name": "string",
    "avatarUrl": "string"
  }
}

Subjects

List Subjects

GET /subjects

Returns a list of all subjects for the authenticated user.

Response:

[
  {
    "id": "string",
    "name": "string",
    "excerpt": "string",
    "createdAt": "string"
  }
]

Create Subject

POST /subjects

Creates a new subject.

Request Body:

{
  "name": "string",
  "description": "string"
}

Response:

{
  "id": "string",
  "name": "string",
  "description": "string",
  "userId": "string",
  "createdAt": "string"
}

Get Subject by ID

GET /subjects/:id

Returns detailed information about a specific subject, including its topics.

Response:

{
  "id": "string",
  "name": "string",
  "description": "string",
  "createdAt": "string",
  "topics": [
    {
      "id": "string",
      "name": "string",
      "description": "string",
      "isCompleted": "boolean",
      "createdAt": "string"
    }
  ]
}

Topics

List Topics

GET /topics

Returns a list of topics for a specific subject.

Request Parameters:

  • id: Subject ID (UUID)

Response:

[
  {
    "id": "string",
    "name": "string",
    "excerpt": "string",
    "isCompleted": "boolean"
  }
]

Create Topic

POST /topics

Creates a new topic within a subject.

Request Parameters:

  • id: Subject ID (UUID)

Request Body:

{
  "name": "string",
  "description": "string",
  "isCompleted": "boolean" // Optional, defaults to false
}

Response:

{
  "id": "string",
  "name": "string",
  "description": "string",
  "isCompleted": "boolean",
  "subjectId": "string",
  "createdAt": "string"
}

Matters

List Matters

GET /matters

Returns a list of matters for a specific topic.

Request Parameters:

  • id: Topic ID (UUID)

Response:

[
  {
    "id": "string",
    "name": "string",
    "isDone": "boolean"
  }
]

Create Matter

POST /matters

Creates a new matter within a topic.

Request Body:

{
  "name": "string"
}

Response:

{
  "id": "string",
  "name": "string",
  "isDone": "boolean",
  "topicId": "string"
}

Data Models

User

  • id: UUID (Primary Key)
  • name: String
  • email: String (Unique)
  • googleId: String (Unique, Optional)
  • avatarUrl: String (Optional)
  • createdAt: DateTime

Subject

  • id: UUID (Primary Key)
  • name: String
  • description: String
  • createdAt: DateTime
  • userId: String (Foreign Key to User)

Topic

  • id: UUID (Primary Key)
  • name: String
  • description: String
  • createdAt: DateTime
  • isCompleted: Boolean
  • subjectId: String (Foreign Key to Subject)

Matter

  • id: UUID (Primary Key)
  • name: String
  • isDone: Boolean
  • topicId: String (Foreign Key to Topic)

Error Handling

The API uses standard HTTP status codes:

  • 200: Success
  • 201: Created
  • 400: Bad Request
  • 401: Unauthorized
  • 404: Not Found
  • 500: Internal Server Error

Development

To run the project locally:

  1. Install dependencies:
npm install
  1. Set up environment variables: Create a .env file with:
DATABASE_URL="file:./dev.db"
  1. Run the development server:
npm run dev

The server will start on port 3333.

About

API do aplicativo para organização de matérias escolares (ou acadêmicas) para organização de estudos, de acordo com o tema e data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •