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.
http://localhost:3333
All endpoints (except authentication endpoints) require a valid JWT token in the Authorization header:
Authorization: Bearer <token>
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 /me
Returns information about the currently authenticated user.
Response:
{
"user": {
"sub": "string", // User ID
"name": "string",
"avatarUrl": "string"
}
}
GET /subjects
Returns a list of all subjects for the authenticated user.
Response:
[
{
"id": "string",
"name": "string",
"excerpt": "string",
"createdAt": "string"
}
]
POST /subjects
Creates a new subject.
Request Body:
{
"name": "string",
"description": "string"
}
Response:
{
"id": "string",
"name": "string",
"description": "string",
"userId": "string",
"createdAt": "string"
}
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"
}
]
}
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"
}
]
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"
}
GET /matters
Returns a list of matters for a specific topic.
Request Parameters:
id
: Topic ID (UUID)
Response:
[
{
"id": "string",
"name": "string",
"isDone": "boolean"
}
]
POST /matters
Creates a new matter within a topic.
Request Body:
{
"name": "string"
}
Response:
{
"id": "string",
"name": "string",
"isDone": "boolean",
"topicId": "string"
}
id
: UUID (Primary Key)name
: Stringemail
: String (Unique)googleId
: String (Unique, Optional)avatarUrl
: String (Optional)createdAt
: DateTime
id
: UUID (Primary Key)name
: Stringdescription
: StringcreatedAt
: DateTimeuserId
: String (Foreign Key to User)
id
: UUID (Primary Key)name
: Stringdescription
: StringcreatedAt
: DateTimeisCompleted
: BooleansubjectId
: String (Foreign Key to Subject)
id
: UUID (Primary Key)name
: StringisDone
: BooleantopicId
: String (Foreign Key to Topic)
The API uses standard HTTP status codes:
- 200: Success
- 201: Created
- 400: Bad Request
- 401: Unauthorized
- 404: Not Found
- 500: Internal Server Error
To run the project locally:
- Install dependencies:
npm install
- Set up environment variables:
Create a
.env
file with:
DATABASE_URL="file:./dev.db"
- Run the development server:
npm run dev
The server will start on port 3333.